Method: projects.locations.apps.executeTool

使用指定引數執行指定工具。

HTTP 要求

POST https://ces.googleapis.com/v1/{parent=projects/*/locations/*/apps/*}:executeTool

這個網址使用 gRPC 轉碼語法。

路徑參數

參數
parent

string

這是必要旗標,工具/工具集所屬應用程式的資源名稱。格式:projects/{project}/locations/{location}/apps/{app}

要求主體

要求主體包含下列結構的資料:

JSON 表示法
{
  "args": {
    object
  },
  "mockConfig": {
    object (MockConfig)
  },

  // The following is a list of mutually exclusive fields. At most one of the
  // fields will be set in a response:
  "tool": string,
  "toolsetTool": {
    object (ToolsetTool)
  }
  // End of mutually exclusive fields.

  // The following is a list of mutually exclusive fields. At most one of the
  // fields will be set in a response:
  "variables": {
    object
  },
  "context": {
    object
  }
  // End of mutually exclusive fields.
}
欄位
args

object (Struct format)

選用。工具的輸入參數和值,格式為 JSON 物件。

mockConfig

object (MockConfig)

選用。工具執行的模擬設定。如果設定這個欄位,呼叫其他工具的工具會根據提供的模式和回應進行模擬。

要執行的工具 ID。可以是持續性工具,也可以是工具集中的工具。以下列出互斥欄位。回應中最多會設定一個欄位:
tool

string

選用。要執行的工具名稱。格式:projects/{project}/locations/{location}/apps/{app}/tools/{tool}

toolsetTool

object (ToolsetTool)

選用。要執行的工具集工具。工具集中只能有一個工具符合述詞。否則會傳回錯誤。

互斥欄位的結尾。
為工具執行作業提供的額外脈絡資訊。以下是互斥欄位清單。回應中最多會設定一個欄位:
variables

object (Struct format)

選用。工具執行時可用的變數。

context

object (Struct format)

選用。要傳遞至 Python 工具的 [ToolCallContext](詳情請參閱 https://docs.cloud.google.com/customer-engagement-ai/conversational-agents/ps/tool/python#environment)。

互斥欄位的結尾。

回應主體

ToolService.ExecuteTool 的回應訊息。

如果成功,回應主體會含有以下結構的資料:

JSON 表示法
{
  "response": {
    object
  },
  "variables": {
    object
  },
  "citations": {
    object (Citations)
  },
  "googleSearchSuggestions": {
    object (GoogleSearchSuggestions)
  },

  // The following is a list of mutually exclusive fields. At most one of the
  // fields will be set in a response:
  "tool": string,
  "toolsetTool": {
    object (ToolsetTool)
  }
  // End of mutually exclusive fields.
}
欄位
response

object (Struct format)

JSON 物件格式的工具執行結果。使用「output」鍵指定工具回應,並使用「error」鍵指定錯誤詳細資料 (如有)。如果未指定「output」和「error」鍵,系統會將整個「response」視為工具執行結果。

variables

object (Struct format)

工具執行完畢時的變數值。

citations

object (Citations)

提供工具執行來源資訊的引文。

googleSearchSuggestions

object (GoogleSearchSuggestions)

在工具執行期間呼叫 Google 搜尋工具後,Google 搜尋傳回的建議。

已執行的工具 ID。以下列出互斥欄位。回應中最多會設定一個欄位:
tool

string

執行的工具名稱。格式:projects/{project}/locations/{location}/apps/{app}/tools/{tool}

toolsetTool

object (ToolsetTool)

執行的工具集工具。

互斥欄位的結尾。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/ces

詳情請參閱Authentication Overview。

IAM 權限

需要 parent 資源的下列 IAM 權限:

  • ces.tools.execute

詳情請參閱 IAM 說明文件。

MockConfig

工作階段的模擬工具呼叫設定。

JSON 表示法
{
  "mockedToolCalls": [
    {
      object (MockedToolCall)
    }
  ],
  "unmatchedToolCallBehavior": enum (MockConfig.UnmatchedToolCallBehavior)
}
欄位
mockedToolCalls[]

object (MockedToolCall)

選用。在工作階段期間模擬的所有工具呼叫。

unmatchedToolCallBehavior

enum (MockConfig.UnmatchedToolCallBehavior)

這是必要旗標,工具呼叫的行為,不符合 mockToolCalls 中的任何引數模式。

MockedToolCall

模擬工具呼叫。

表示目標工具 + 用於比對該工具引數 / 輸入內容的模式。如果模式相符,系統就會傳回模擬回應。

JSON 表示法
{
  "tool": string,
  "expectedArgsPattern": {
    object
  },
  "mockResponse": {
    object
  },

  // The following is a list of mutually exclusive fields. At most one of the
  // fields will be set in a response:
  "toolId": string,
  "toolset": {
    object (ToolsetTool)
  }
  // End of mutually exclusive fields.
}
欄位
tool
(deprecated)

string

選用。已淘汰,請改用 tool_identifier。

expectedArgsPattern

object (Struct format)

這是必要旗標,用來比對所有已調度工具呼叫的 args / inputs。如果工具呼叫輸入內容符合這個模式,系統就會傳回模擬輸出內容。

mockResponse

object (Struct format)

選用。如果工具呼叫引數 / 輸入內容符合模式,要傳回的模擬回應 / 輸出內容。

要模擬的工具 ID。以下列出互斥欄位。回應中最多會設定一個欄位:
toolId

string

選用。要模擬的工具名稱。格式:projects/{project}/locations/{location}/apps/{app}/tools/{tool}

toolset

object (ToolsetTool)

選用。要模擬的工具集。

互斥欄位的結尾。

MockConfig.UnmatchedToolCallBehavior

如果工具呼叫與任何模擬工具呼叫都不相符,該怎麼辦?

列舉
UNMATCHED_TOOL_CALL_BEHAVIOR_UNSPECIFIED 預設值。這個值不會使用。
FAIL 針對不符合模擬預期輸入模式的任何工具呼叫擲回錯誤。
PASS_THROUGH 如果工具呼叫不相符,請將工具呼叫傳遞至實際工具。