Skip to content

Commit

Permalink
fix: the object field is empty string in some openAI api compatible m…
Browse files Browse the repository at this point in the history
…odel (langgenius#3506)
  • Loading branch information
liuzhenghua authored Apr 16, 2024
1 parent 443fee8 commit 5e02a83
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
except json.JSONDecodeError as e:
raise CredentialsValidateFailedError('Credentials validation failed: JSON decode error')

if (completion_type is LLMMode.CHAT and json_result['object'] == ''):
json_result['object'] = 'chat.completion'
if (completion_type is LLMMode.CHAT
and ('object' not in json_result or json_result['object'] != 'chat.completion')):
raise CredentialsValidateFailedError(
Expand Down Expand Up @@ -807,4 +809,4 @@ def _extract_response_function_call(self, response_function_call) \
function=function
)

return tool_call
return tool_call

0 comments on commit 5e02a83

Please sign in to comment.