Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/studio/chat/chat_function_calling_multiple_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_sunset_hour(place: str, date: str) -> str:

""" AI models can be error-prone, it's crucial to ensure that the tool calls align with the expectations.
The below code snippet demonstrates how to handle tool calls in the response and invoke the tool function
to get the delivery date for the user's order. After retrieving the delivery date, we pass the response back
to get the weather forcast and expected sunset hour. After retrieving them, we pass the responses back
to the AI model to continue the conversation, using the ToolMessage object. """

assistant_message = response.choices[0].message
Expand All @@ -100,7 +100,7 @@ def get_sunset_hour(place: str, date: str) -> str:
print(f"Got unexpected arguments in function call - {args}")

elif tool_call.function.name == "get_sunset_hour":
"""Verify get_sunset_hour tool call arguments and invoke the function to get the weather forecast:"""
"""Verify get_sunset_hour tool call arguments and invoke the function to get the sunset hour:"""
func_arguments = tool_call.function.arguments
args = json.loads(func_arguments)

Expand All @@ -116,7 +116,7 @@ def get_sunset_hour(place: str, date: str) -> str:
print("No tool calls found")

if too_call_id_to_result:
"""Continue the conversation by passing the sunset and weather back to the AI model:"""
"""Continue the conversation by passing the sunset and weather info back to the AI model:"""

for tool_id_called, result in too_call_id_to_result.items():
tool_message = ToolMessage(role="tool", tool_call_id=tool_id_called, content=str(result))
Expand Down