Tool(
function_declarations: typing.List[
vertexai.generative_models._generative_models.FunctionDeclaration
],
)
A collection of functions that the model may use to generate response.
Usage: Create tool from function declarations:
```
get_current_weather_func = generative_models.FunctionDeclaration(...)
weather_tool = generative_models.Tool(
function_declarations=[get_current_weather_func],
)
```
Use tool in `GenerativeModel.generate_content`:
```
model = GenerativeModel("gemini-pro")
print(model.generate_content(
"What is the weather like in Boston?",
# You can specify tools when creating a model to avoid having to send them with every request.
tools=[weather_tool],
))
```
Use tool in chat:
```
model = GenerativeModel(
"gemini-pro",
# You can specify tools when creating a model to avoid having to send them with every request.
tools=[weather_tool],
)
chat = model.start_chat()
print(chat.send_message("What is the weather like in Boston?"))
print(chat.send_message(
Part.from_function_response(
name="get_current_weather",
response={
"content": {"weather_there": "super nice"},
}
),
))
```