Skip to content

Commit

Permalink
✨ Update search tool integration in get_vertex_gemini_payload: stream…
Browse files Browse the repository at this point in the history
…line tool assignment based on model type for improved functionality.
  • Loading branch information
yym68686 committed Jan 16, 2025
1 parent 483c528 commit b9b5443
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions request.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,14 @@ async def get_vertex_gemini_payload(request, engine, provider):
gemini_stream = "streamGenerateContent"
model_dict = get_model_dict(provider)
model = model_dict[request.model]
search_tool = None

if "gemini-2.0" in model or "gemini-exp" in model:
location = gemini2
search_tool = {"googleSearch": {}}
else:
location = gemini1
search_tool = {"googleSearchRetrieval": {}}

url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/google/models/{MODEL_ID}:{stream}".format(LOCATION=await location.next(), PROJECT_ID=project_id, MODEL_ID=model, stream=gemini_stream)

Expand Down Expand Up @@ -507,13 +510,9 @@ async def get_vertex_gemini_payload(request, engine, provider):

if request.model.endswith("-search"):
if "tools" not in payload:
payload["tools"] = [{
"googleSearch": {}
}]
payload["tools"] = [search_tool]
else:
payload["tools"].append({
"googleSearch": {}
})
payload["tools"].append(search_tool)

return url, headers, payload

Expand Down

0 comments on commit b9b5443

Please sign in to comment.