Created
April 22, 2024 00:20
-
-
Save donbcolab/f9d848c729f5b0499367626c1433d41f to your computer and use it in GitHub Desktop.
intro_function_calling_with_gemini_and_python_output.ipynb
Following error occurs when function calls are made out of sequence:
---------------------------------------------------------------------------
_InactiveRpcError Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py](https://localhost:8080/#) in error_remapped_callable(*args, **kwargs)
71 try:
---> 72 return callable_(*args, **kwargs)
73 except grpc.RpcError as exc:
8 frames
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Please ensure that function response turn comes immediately after a function call turn."
debug_error_string = "UNKNOWN:Error received from peer ipv4:172.217.194.95:443 {created_time:"2024-04-22T00:26:46.692657746+00:00", grpc_status:3, grpc_message:"Please ensure that function response turn comes immediately after a function call turn."}"
>
The above exception was the direct cause of the following exception:
InvalidArgument Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py](https://localhost:8080/#) in error_remapped_callable(*args, **kwargs)
72 return callable_(*args, **kwargs)
73 except grpc.RpcError as exc:
---> 74 raise exceptions.from_grpc_error(exc) from exc
75
76 return error_remapped_callable
InvalidArgument: 400 Please ensure that function response turn comes immediately after a function call turn.
I also encountered this error :
ERROR:root:Error in chat: 400 Please ensure that function response turn comes immediately after a function call turn. And the number of function response parts should be equal to number of function call parts of the function call turn.
but I've made sure the call response is returned right after function is called. I wonder what's the issue?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Notebook is a simplified version of https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/function-calling/intro_function_calling.ipynb
Copy of this Notebook without responses: https://gist.github.com/donbcolab/4f59845328b8341314a3ef1eb39bf07c
The pattern from this Python example uses lists to preserve prompt and summary order: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/generative_ai/function_calling_chat.py