La chiamata di funzione ti consente di creare applicazioni e agenti basati su Gemini che possono interagire con informazioni e servizi in tempo reale come database, sistemi di gestione delle relazioni con i clienti e repository di documenti. In questo modo migliora la capacità dell'applicazione di fornire risposte pertinenti e contestuali.
Con l'ottimizzazione supervisionata, puoi utilizzare il tuo set di dati di ottimizzazione per migliorare l'accuratezza complessiva delle risposte basate sulla chiamata di funzione della tua applicazione.
Modelli supportati
I seguenti modelli Gemini supportano l'ottimizzazione della chiamata di funzioni:
gemini-2.0-flash-001
Formato del set di dati per l'ottimizzazione
Il fileUri
per il set di dati di perfezionamento può essere l'URI di un file in un bucket Cloud Storage oppure un URL HTTP o HTTPS disponibile pubblicamente.
Per visualizzare l'esempio di formato generico, consulta l'esempio di set di dati per Gemini.
Le sezioni seguenti presentano esempi di set di dati per la chiamata di funzione da utilizzare per creare un job di ottimizzazione per la chiamata di funzione.
Ottimizzazione delle chiamate di funzione per generare testo
Di seguito è riportato un esempio di set di dati per la messa a punto della chiamata di funzione per generare una singola risposta di testo.
{
"system_instruction": {
"role": "system",
"parts": [
{
"text": "You are an assistant that helps users find the best product for them."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Do you have the White Pixel 8 Pro 128GB in stock in the US?"
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "get_product_sku",
"args": {
"product_name": "Pixel 8 Pro 128GB"
}
}
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_product_sku",
"description": "Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc",
"parameters": {
"type": "OBJECT",
"properties": {
"product_name": {
"type": "STRING",
"description": "Product name",
"enum": [
"Pixel 8 Pro 128GB",
"Pixel 8 Pro 256GB",
"Pixel 8 Pro 512GB",
"Pixel 8 Pro 1TB"
]
}
}
}
},
{
"name": "get_store_location",
"description": "Get the location of the closest store",
"parameters": {
"type": "OBJECT",
"properties": {
"location": {
"type": "STRING",
"description": "Location"
}
}
}
}
]
}
]
}
Ottimizzare la chiamata di funzione per supportare una sessione di chat
Di seguito è riportato un esempio di un set di dati per la messa a punto della chiamata di funzione per supportare una sessione di chat.
{
"system_instruction": {
"role": "system",
"parts": [
{
"text": "You are an assistant that helps users find the best product for them."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Do you have the Porcelain Pixel 8 Pro 128GB in stock in the US?"
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "get_product_sku",
"args": {
"product_name": "Pixel 8 Pro 128GB"
}
}
}
]
},
{
"parts": [
{
"functionResponse": {
"name": "get_product_sku",
"response": {
"output": "True"
}
}
}
]
},
{
"role": "model",
"parts": [
{
"text": "Yes, we have the Porcelain Pixel 8 Pro 128GB in stock in the US."
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_product_sku",
"description": "Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc",
"parameters": {
"type": "OBJECT",
"properties": {
"product_name": {
"type": "STRING",
"description": "Product name",
"enum": [
"Pixel 8 Pro 128GB",
"Pixel 8 Pro 256GB",
"Pixel 8 Pro 512GB",
"Pixel 8 Pro 1TB"
]
}
}
}
},
{
"name": "get_store_location",
"description": "Get the location of the closest store",
"parameters": {
"type": "OBJECT",
"properties": {
"location": {
"type": "STRING",
"description": "Location"
}
}
}
}
]
}
]
}
Ottimizzazione della chiamata di funzione parallela
Di seguito è riportato un esempio di set di dati per la messa a punto della chiamata di funzioni parallela.
{
"system_instruction": {
"role": "system",
"parts": [
{
"text": "You are an assistant that helps users find the best product for them."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Where is the closest Google Store to Mountain View, CA that has Pixel 8 Pro 128GB in stock?"
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "get_product_sku",
"args": {
"product_name": "Pixel 8 Pro 128GB"
}
}
},
{
"functionCall": {
"name": "get_store_location",
"args": {
"location": "Mountain View, CA"
}
}
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_product_sku",
"description": "Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc",
"parameters": {
"type": "OBJECT",
"properties": {
"product_name": {
"type": "STRING",
"description": "Product name",
"enum": [
"Pixel 8 Pro 128GB",
"Pixel 8 Pro 256GB",
"Pixel 8 Pro 512GB",
"Pixel 8 Pro 1TB"
]
}
}
}
},
{
"name": "get_store_location",
"description": "Get the location of the closest store",
"parameters": {
"type": "OBJECT",
"properties": {
"location": {
"type": "STRING",
"description": "Location"
}
}
}
}
]
}
]
}
Passaggi successivi
- Per scoprire come creare un job di ottimizzazione e come testare il modello ottimizzato, consulta Ottimizzare i modelli Gemini utilizzando il fine-tuning supervisionato.
- Per scoprire di più sull'ottimizzazione del modello Gemini, consulta Introduzione all'ottimizzazione.
- Per scoprire di più sulla chiamata di funzione, consulta Introduzione alla chiamata di funzione.