Hi there,
In the past I have used the OpenAI Assistants API, but I want to give Gemini a try.
So I tried this basic code:
from google import genai
from google.genai.types import GenerateContentConfig, Tool, GoogleSearch, ToolCodeExecution
client = genai.Client(vertexai=True, project=MY-PROJECT-ID, location="us-central1")
search_tool = Tool(google_search=GoogleSearch())
code_execution_tool = Tool(code_execution=ToolCodeExecution())
config = GenerateContentConfig(
tools=[search_tool, code_execution_tool],
)
chat_session = client.chats.create(model="gemini-2.0-flash-001", config=config)
while True:
user_input = input("User: ")
if user_input == "exit":
break
response = chat_session.send_message(user_input)
print("Model:", response.text)
But this does not work, I get the Error
{'error': {'code': 400, 'message': 'At most one tool is supported.', 'status': 'INVALID_ARGUMENT'}}
Instead creating one tool with both enabled results in
tool = Tool(google_search=GoogleSearch(), code_execution=ToolCodeExecution())
{'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}
Is there any way to enable both? I did not find anything in the documentation or GitHub Repo.
Any help would be appreciated
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |