| json_result['object'] = 'chat.completion' | json_result['object'] = 'chat.completion' | ||||
| elif (completion_type is LLMMode.COMPLETION and json_result['object'] == ''): | elif (completion_type is LLMMode.COMPLETION and json_result['object'] == ''): | ||||
| json_result['object'] = 'text_completion' | json_result['object'] = 'text_completion' | ||||
| if (completion_type is LLMMode.CHAT | if (completion_type is LLMMode.CHAT | ||||
| and ('object' not in json_result or json_result['object'] != 'chat.completion')): | and ('object' not in json_result or json_result['object'] != 'chat.completion')): | ||||
| raise CredentialsValidateFailedError( | raise CredentialsValidateFailedError( | ||||
| finish_reason = 'Unknown' | finish_reason = 'Unknown' | ||||
| for chunk in response.iter_lines(decode_unicode=True, delimiter=delimiter): | for chunk in response.iter_lines(decode_unicode=True, delimiter=delimiter): | ||||
| chunk = chunk.strip() | |||||
| if chunk: | if chunk: | ||||
| # ignore sse comments | # ignore sse comments | ||||
| if chunk.startswith(':'): | if chunk.startswith(':'): |