בקשה להפעלת פונקציה מאפשרת ליצור אפליקציות וסוכנים מבוססי Gemini שיכולים לקיים אינטראקציה עם מידע ושירותים בזמן אמת, כמו מסדי נתונים, מערכות לניהול קשרי לקוחות ומאגרי מסמכים. כך האפליקציה יכולה לספק תשובות רלוונטיות ותלויות-הקשר.
באמצעות כוונון מפוקח (SFT), אתם יכולים להשתמש במערך נתונים משלכם לכוונון כדי לשפר את הדיוק הכולל של התגובות של האפליקציה שלכם שמבוססות על קריאה להפעלת פונקציות.
פורמט של מערך נתונים לכוונון
ה-fileUri של מערך הנתונים לכוונון העדין יכול להיות URI של קובץ בקטגוריה של Cloud Storage, או כתובת URL של 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 באמצעות כוונון מפוקח (SFT).
- מידע נוסף על כוונון מודל Gemini זמין במאמר מבוא לכוונון.
- מידע נוסף על קריאה לפונקציות זמין במאמר מבוא לקריאה לפונקציות.