Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (Gen AI): Add sample for Gemini parallel function calling example #12637

Prev Previous commit
Next Next commit
Update model version
  • Loading branch information
Valeriy-Burlaka committed Sep 27, 2024
commit f46e0845820a5ed8df71e17e7851b188609b7996
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def generate_parallel_function_calls() -> ChatSession:
import vertexai
from vertexai.generative_models import (
FunctionDeclaration,
GenerationConfig,
GenerativeModel,
Part,
Tool,
Expand Down Expand Up @@ -63,14 +62,13 @@ def mock_weather_api_service(location: str) -> str:

# Initialize Gemini model
model = GenerativeModel(
model_name="gemini-1.5-pro-001",
generation_config=GenerationConfig(temperature=0),
model_name="gemini-1.5-pro-002",
tools=[tools],
)

# Start a chat session
chat = model.start_chat()
response = chat.send_message("Compare the weather in New Delhi and San Francisco")
response = chat.send_message("Get weather details in New Delhi and San Francisco?")

function_calls = response.candidates[0].function_calls
print("Suggested finction calls:\n", function_calls)
Expand Down Expand Up @@ -99,7 +97,7 @@ def mock_weather_api_service(location: str) -> str:

print(response.text)
# Example response:
# The weather in New Delhi is 35 degrees Celsius and the weather in San Francisco is 25 degrees Celsius. New Delhi is warmer than San Francisco.
# The current weather in New Delhi is 35°C. The current weather in San Francisco is 25°C.

# [END generativeaionvertexai_gemini_parallel_function_calling_example]
return response
Expand Down