Skip to content

Commit 58e6ac9

Browse files
Ark-kuncopybara-github
authored andcommitted
fix: GenAI - Fixed handling of multiple tools in AutomaticFunctionCallingResponder
PiperOrigin-RevId: 632316936
1 parent 5a300c1 commit 58e6ac9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

vertexai/generative_models/_generative_models.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,13 @@ def respond_to_model_response(
23782378
)
23792379
callable_function = None
23802380
for tool in tools:
2381-
callable_function = tool._callable_functions.get(function_call.name)
2381+
new_callable_function = tool._callable_functions.get(function_call.name)
2382+
if new_callable_function and callable_function:
2383+
raise ValueError(
2384+
"Multiple functions with the same name are not supported."
2385+
f" Found {callable_function} and {new_callable_function}."
2386+
)
2387+
callable_function = new_callable_function
23822388
if not callable_function:
23832389
raise RuntimeError(
23842390
f"""Model has asked to call function "{function_call.name}" which was not found."""

0 commit comments

Comments
 (0)