函式呼叫可讓您建立以 Gemini 為基礎的應用程式和代理程式,與即時資訊和服務互動,例如資料庫、客戶關係管理系統和文件存放區。這可強化應用程式提供相關且符合情境的回應能力。
透過監督式精細調整,您可以使用自訂的調整資料集,改善應用程式以函式呼叫為基礎的回應的整體準確度。
支援的模型
下列 Gemini 模型支援函式呼叫調整:
gemini-2.0-flash-001
調整用資料集格式
精細調整資料集的 fileUri
可以是 Cloud Storage 值區中檔案的 URI,也可以是公開的 HTTP 或 HTTPS 網址。
如要查看通用格式範例,請參閱 Gemini 的資料集範例。
以下各節會提供函式呼叫資料集的範例,供您在建立函式呼叫的調整工作時使用。
調整函式呼叫以產生文字
以下是用於微調函式呼叫以產生單一文字回應的資料集範例。
{
"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"
}
}
}
}
]
}
]
}
調整函式呼叫以支援即時通訊工作階段
以下是用於調整支援即時通訊工作階段的函式呼叫的資料集範例。
{
"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"
}
}
}
}
]
}
]
}
調整並行函式呼叫
以下是用於微調平行函式呼叫的資料集範例。
{
"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"
}
}
}
}
]
}
]
}
後續步驟
- 如要瞭解如何建立調整作業,以及如何測試已調整的模型,請參閱「使用監督式精細調整功能調整 Gemini 模型」。
- 如要瞭解 Gemini 模型調整作業,請參閱「調整作業簡介」。
- 如要瞭解函式呼叫,請參閱「函式呼叫簡介」。