Skip to content

Commit

Permalink
add ernie-turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
Southpika committed Jan 11, 2024
1 parent 0c8a796 commit 540c8b6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions erniebot-agent/src/erniebot_agent/chat_models/erniebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ async def chat(
cfg_dict = self._generate_config(messages, functions=functions, **kwargs)

response = await self._generate_response(cfg_dict, stream, functions)

if not stream:
assert isinstance(response, ChatCompletionResponse)
return convert_response_to_output(response, AIMessage)
Expand Down Expand Up @@ -279,8 +280,8 @@ async def _generate_response(

def convert_response_to_output(response: ChatCompletionResponse, output_type: Type[_T]) -> _T:
clarify = False
if response["finish_reason"] == "plugin_clarify":
# clarify would not occur in function call
# ernie-turbo has no `finish_reason`
if hasattr(response, "finish_reason") and response["finish_reason"] == "plugin_clarify":
clarify = True

if hasattr(response, "function_call"):
Expand Down

0 comments on commit 540c8b6

Please sign in to comment.