From fbd3ef8752a39c79317e67ee92729acdaedffd1e Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Tue, 16 Apr 2024 13:36:02 +0800 Subject: [PATCH] fix: add completion mode object check (#3515) --- .../model_providers/openai_api_compatible/llm/llm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py index 54f4405de1..45a5b49a8b 100644 --- a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py +++ b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py @@ -152,6 +152,9 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel): if (completion_type is LLMMode.CHAT and json_result['object'] == ''): json_result['object'] = 'chat.completion' + elif (completion_type is LLMMode.COMPLETION and json_result['object'] == ''): + json_result['object'] = 'text_completion' + if (completion_type is LLMMode.CHAT and ('object' not in json_result or json_result['object'] != 'chat.completion')): raise CredentialsValidateFailedError(