함수 호출 조정

함수 호출을 사용하면 데이터베이스, 고객 관계 관리 시스템, 문서 저장소와 같은 실시간 정보 및 서비스와 상호작용할 수 있는 Gemini 기반 애플리케이션과 에이전트를 만들 수 있습니다. 이를 통해 애플리케이션이 관련성 높은 상황별 응답을 제공하는 기능이 향상됩니다.

지도 세부 조정을 사용하면 자체 조정 데이터 세트를 사용하여 애플리케이션의 함수 호출 기반 응답의 전반적인 정확성을 개선할 수 있습니다.

지원되는 모델

다음 Gemini 모델은 함수 호출 조정을 지원합니다.

  • gemini-2.0-flash-001

조정 데이터 세트 형식

세부 조정 데이터 세트의 fileUri는 Cloud Storage 버킷의 파일 URI이거나 공개적으로 사용 가능한 HTTP 또는 HTTPS URL일 수 있습니다.

일반적인 형식 예시는 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"
              }
            }
          }
        }
      ]
    }
  ]
}

다음 단계