SInce I am using Gemini, I might as well leverage the same API instead of using any other third party search engine API with my chat bot
Hi,
Tried the new genai
package already? Adding Google Search is “just” a tool
away.
However, AFAIK Vertex AI might not be open to query Search. Although I haven’t tested it recently. Maybe it has changed since then.
Cheers
client = genai.Client(api_key=os.environ.get("GEMINI_API_KEY"))
model_id = "gemini-2.0-flash"
google_search_tool = Tool(
google_search = GoogleSearch()
)
response = client.models.generate_content(
model=model_id,
contents=query,
config=GenerateContentConfig(
tools=[google_search_tool],
response_modalities=["TEXT"],
)
)
Error:
Error: TypeError("BaseTool.__call__() missing 1 required positional argument: 'tool_input'")
I suddenly hit the following error:
Error: ValueError('Missing key inputs argument! To use the Google AI API,provide (`api_key`) arguments. To use the Google Cloud API, provide (`vertexai`, `project` & `location`) arguments.')
What happen?
Resolve this by putting a copy of .env
in the subfolder which contains the python module file run with python
Hi,
Did you set that environment variable prior to using it?
Cheers
This is fixed already
Any documentation for GenerateContentConfig
response_modalities
? The example uses TEXT
and it is markdown text which is.
Hi @khteh
See here: Generate images | Gemini API | Google AI for Developers
Or use the API reference: Generating content | Gemini API | Google AI for Developers
Cheers.