Skip to content

Commit

Permalink
Add unit tests for tool calling; and integration tests for openai and…
Browse files Browse the repository at this point in the history
… gemini
  • Loading branch information
ekzhu committed Jan 21, 2025
1 parent 9ac1cb6 commit d7e3b8f
Show file tree
Hide file tree
Showing 2 changed files with 332 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,15 @@ async def create(
elif choice.message.tool_calls is not None:
if choice.finish_reason != "tool_calls":
warnings.warn(
f"finish reason mismatch: {choice.finish_reason} != tool_calls "
"when tool_calls are present. Finish reason may not be accurate.",
f"Finish reason mismatch: {choice.finish_reason} != tool_calls "
"when tool_calls are present. Finish reason may not be accurate. "
"This may be due to the API used that is not returning the correct finish reason.",
stacklevel=2,
)
if choice.message.content is not None and choice.message.content != "":
warnings.warn(
"Both tool_calls and content are present in the message. "
"This is unexpected. content will be ignored.",
"This is unexpected. content will be ignored, tool_calls will be used.",
stacklevel=2,
)
# NOTE: If OAI response type changes, this will need to be updated
Expand All @@ -574,7 +575,7 @@ async def create(
)
for x in choice.message.tool_calls
]
finish_reason = "function_calls"
finish_reason = "tool_calls"
else:
finish_reason = choice.finish_reason
content = choice.message.content or ""
Expand Down
Loading

0 comments on commit d7e3b8f

Please sign in to comment.