Skip to content

Commit

Permalink
fix: GenAI - Fixed handling of multiple tools in `AutomaticFunctionCa…
Browse files Browse the repository at this point in the history
…llingResponder`

PiperOrigin-RevId: 632316936
  • Loading branch information
Ark-kun authored and Copybara-Service committed May 10, 2024
1 parent 5a300c1 commit 58e6ac9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vertexai/generative_models/_generative_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,13 @@ def respond_to_model_response(
)
callable_function = None
for tool in tools:
callable_function = tool._callable_functions.get(function_call.name)
new_callable_function = tool._callable_functions.get(function_call.name)
if new_callable_function and callable_function:
raise ValueError(
"Multiple functions with the same name are not supported."
f" Found {callable_function} and {new_callable_function}."
)
callable_function = new_callable_function
if not callable_function:
raise RuntimeError(
f"""Model has asked to call function "{function_call.name}" which was not found."""
Expand Down

0 comments on commit 58e6ac9

Please sign in to comment.