googleapis / googleapis/python-genai

URL context tool not working together with Google Search on Vertex AI

Aperta
#941 13 commenti 1 reazione 1 assegnatario Assegnata a @kkorpal Vedi su GitHub
priority: p2 type: bug
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 12h
PR unite (30g)
41

Descrizione

When using the Gemini API, the URL context tool works fine together with Google Search, as documented here:
https://ai.google.dev/gemini-api/docs/url-context

However, on Vertex AI, I'm getting the following error:
```
{'error': {'code': 400, 'message': 'Multiple tools are supported only when they are all search tools.', 'status': 'INVALID_ARGUMENT'}}
```

Test code:
```python
from google import genai
from google.genai import types

def generate():
client = genai.Client(
vertexai=True,
project="XXX",
location="global",
)

model = "gemini-2.5-flash-preview-05-20"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""Summarize this page: https://ai.google.dev/gemini-api/docs/url-context"""),
],
),
]
tools = [
types.Tool(url_context=types.UrlContext()),
types.Tool(google_search=types.GoogleSearch()),
]
generate_content_config = types.GenerateContentConfig(
tools=tools,
response_mime_type="text/plain",
)

for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")

if __name__ == "__main__":
generate()
```

If I change client to use the Gemini API with an API key, the same code works.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.