Tool(
function_declarations: typing.List[
vertexai.generative_models._generative_models.FunctionDeclaration
],
)
Una raccolta di funzioni che il modello può utilizzare per generare la risposta.
Utilizzo: crea lo strumento dalle dichiarazioni delle funzioni:
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"},
}
),
))
```