mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-03 01:03:59 +00:00
fix tool calling by not relying on finish reason but tool_calls
This commit is contained in:
parent
a1524390b9
commit
7323d8e86f
2 changed files with 6 additions and 3 deletions
|
@ -143,7 +143,7 @@ class OpenAIResponsesImpl:
|
||||||
stream=stream,
|
stream=stream,
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(chat_response, AsyncIterator):
|
if stream:
|
||||||
# TODO: refactor this into a separate method that handles streaming
|
# TODO: refactor this into a separate method that handles streaming
|
||||||
chat_response_id = ""
|
chat_response_id = ""
|
||||||
chat_response_content = []
|
chat_response_content = []
|
||||||
|
@ -175,10 +175,10 @@ class OpenAIResponsesImpl:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# dump and reload to map to our pydantic types
|
# dump and reload to map to our pydantic types
|
||||||
chat_response = OpenAIChatCompletion.model_validate_json(chat_response.model_dump_json())
|
chat_response = OpenAIChatCompletion(**chat_response.model_dump())
|
||||||
|
|
||||||
output_messages: List[OpenAIResponseOutput] = []
|
output_messages: List[OpenAIResponseOutput] = []
|
||||||
if chat_response.choices[0].finish_reason == "tool_calls":
|
if chat_response.choices[0].message.tool_calls:
|
||||||
output_messages.extend(
|
output_messages.extend(
|
||||||
await self._execute_tool_and_return_final_output(model, stream, chat_response, messages)
|
await self._execute_tool_and_return_final_output(model, stream, chat_response, messages)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# This is a temporary run file because model names used by the verification tests
|
||||||
|
# are not quite consistent with various pre-existing distributions.
|
||||||
|
#
|
||||||
version: '2'
|
version: '2'
|
||||||
image_name: openai-api-verification
|
image_name: openai-api-verification
|
||||||
apis:
|
apis:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue