Cortex Agents REST API

您可以使用 Cortex Data Agent REST API 在 Snowflake 账户中创建、管理 Cortex Data Agent 并与之交互。使用此 API 来构建对话数据应用程序、自动进行数据分析并集成代理驱动的工作流程。

Create Cortex Agent

POST /api/v2/databases/{database}/schemas/{schema}/agents

创建具有指定属性和规范的新 Cortex Data Agent。

请求

路径参数

参数

描述

database

(必填)您的 Snowflake 账户 URL。

schema

(必需)架构标识符。

Query parameters

参数

描述

createMode

(可选)资源创建模式。有效值:模型监视器名称字符串。

  • errorIfExists

  • orReplace

  • ifNotExists

请求标头

标头

描述

Authorization

(必需)授权令牌。有关更多信息,请参阅 身份验证

Content-Type

(必需)应用程序/json

请求正文

The request body defines the agent's name, profile, model configuration, orchestration, instructions, tools, and tool resources.

字段

类型

描述

name

字符串

(必需)代理的名称。

comment

字符串

Optional comment about the agent.

profile

对象

代理的配置信息(显示名称、头像、颜色等)。

models

对象

代理的模型配置。包括编排模型(例如 llama3.3-70B)。如果未提供,则自动选择模型。

orchestration

对象

编排配置,包括预算约束(例如 secondstokens)。

instructions

对象

代理的行为指令,包括响应、编排、系统和示例问题。

tools

数组

代理可用的工具列表。每个工具包含一个 tool_spec,其中包括类型、名称、描述和输入架构。

tool_resources

对象

对工具数组中每个引用工具的配置。键必须与工具 name 匹配。

profile

The profile field configures tool selection behavior.

字段

类型

描述

display_name

字符串

Display name for the agent.

avatar

字符串

代理的头像图片。

color

字符串

代理的颜色主题。

models

The models field configures models for the agent.

字段

类型

描述

orchestration

字符串

用于编排的模型。如果未提供,则自动选择模型。

orchestration

The orchestration field configures orchestration settings for the agent.

字段

类型

描述

budget

对象

Budget constraints for the agent.

budget

budget 对象指定代理的资源限制。

字段

类型

描述

seconds

整数

时间预算(秒)。

tokens

整数

令牌预算。

instructions

instructions 字段用于定义代理的行为指令,包括响应生成、工具编排、系统指令以及示例问题。

字段

类型

描述

response

字符串

响应生成的指令。

orchestration

字符串

用于编排不同工具的指令。

system

字符串

代理的系统指令。

sample_questions

数组

代理的示例问题及可选答案。

sample_questions

sample_questions 数组中的每个元素都是一个对象,包含以下字段:

字段

类型

描述

question

字符串

Sample question.

answer

字符串

可选示例答案。

tools

tools 字段定义代理可使用的工具列表。工具提供特定功能,如数据分析、搜索或通用功能。每个工具可能在 tool_resources 对象中有对应的配置。

字段

类型

描述

tool_spec

对象

(必需)工具的类型、配置及输入要求的规范。

tool_spec

tool_spec 对象描述工具的功能和配置。

字段

类型

描述

type

字符串

(必需)工具功能类型。可为特定类型,如 cortex_analyst_text_to_sql,或通用工具 generic

  • cortex_search

  • cortex_analyst_text_to_sql

  • data_to_chart

  • generic

name

字符串

(必需)工具实例的唯一标识符。用于在 tool_resources 中匹配配置。

description

字符串

待考虑使用工具的描述。

input_schema

对象

此工具期望输入参数的 JSON 架构定义。对于通用工具,此字段必填,用于指定输入要求。

input_schema

The input_schema object defines the input parameters for the tool.

字段

类型

描述

type

字符串

输入架构对象的类型。

properties

对象

每个输入参数的定义。

required

数组

必填输入参数名称列表。

tool_resources

tool_resources 对象定义 tools 数组中每个引用工具的配置。每个键必须与工具 name 匹配。值可以是以下对象之一:

Cortex Analyst analysis tool configuration

Cortex Analyst 分析工具的配置。提供用于 SQL 查询生成和执行的参数。

字段

类型

描述

semantic_model_file

字符串

存储在 Snowflake Stage 中的文件路径,该文件包含语义模型 yaml。

semantic_view

字符串

Snowflake 原生语义模型对象的名称。示例:db.schema.semantic_view

Search tool configuration

搜索功能的配置。定义文档搜索和检索的方式。

字段

类型

描述

search_service

字符串

搜索服务的名称。必须采用以下格式:database.schema.service_name

name

字符串

保留字段。

max_results

整数

用于 LLM 提示的搜索结果数量。

title_column

字符串

The title column of the document.

id_column

字符串

The ID column of the document.

filter

对象

搜索结果的筛选查询。对象由字段和值对组成。

两种配置对象均允许添加额外属性。

Example request body

{
 "name": "my_agent",
 "comment": "Sample agent",
 "profile": {
  "display_name": "My Data Agent",
  "avatar": "AiIcon",
  "color": "#00AEEF"
 },
 "models": {
  "orchestration": "llama3.3-70B"
 },
 "orchestration": {
  "budget": {
   "seconds": 200,
   "tokens": 5000
   }
  },
 "instructions": {
  "response": "Always provide a concise response and maintain a friendly tone.",
  "orchestration": "<orchestration instructions>",
  "system": "You are a helpful data agent.",
  "sample_questions": [
    {
      "question": "Sample question",
      "answer": "sample answer"
    }
  ]
 },
 "tools": [
  {
   "tool_spec": {
          "description": "Analyst to analyze price",
    "type": "cortex_analyst_text_to_sql",
    "name": "Analyst1"
   }
  },
  {
   "tool_spec": {
    "type": "cortex_search",
    "name": "Search1"
   }
  }
 ],
 "tool_resources": [
  {
    "Search1": {
        "search_service": "db.schema.service_name",
        "filter": {"@eq": {"region": "North America"} },
        "max_results": 5
    }
  },
  {
    "Analyst1": {
     "semantic_view": "my_db.my_sch.my_sem_view_1"
    }
  }
 ]
}
Copy

响应

成功的响应会返回一个 JSON 对象,其中包含有关 Cortex Agent 创建状态的详细信息。

Response body

{"status": "Agent xxxx successfully created."}
Copy

描述 Cortex Agent

GET /api/v2/databases/{database}/schemas/{schema}/agents/{name}

描述 Cortex Agent。

请求

路径参数

参数

描述

database

(必需)资源所属数据库的标识符。您可以使用 /api/v2/databases GET 请求来获取可用数据库的列表。

schema

(必需)资源所属架构的标识符。您可以使用 /api/v2/databases/{database}/schemas GET 请求来获取指定数据库的可用架构列表。

name

(Required) Identifier for the agent.

请求标头

标头

描述

Authorization

(必需)授权令牌。有关更多信息,请参阅 身份验证

Content-Type

(必需)应用程序/json

响应

成功的响应会返回一个描述 Cortex Agent 的 JSON 对象。

Response headers

标头

描述

X-Snowflake-Request-ID

Unique ID of the API request.

Link

结果页的链接(例如首页、尾页等)。该标头可以包含多个具有不同 rel 属性值的 URL 条目,用于指定返回的页面(first、next、prev 和 last)。

Response body

响应正文包含 Cortex Agent 的详细信息。

{
 "name": "my_agent",
 "database": "TEST_DB",
 "schema": "TEST_SCHEMA",
 "created_on": "2024-06-01T12:00:00Z",
 "owner": "ACCOUNTADMIN",
 "comment": "Sample agent",
 "profile": {
  "display_name": "My Data Agent",
  "avatar": "AiIcon",
  "color": "#00AEEF"
 },
 "models": {
  "orchestration": "llama3.3-70B"
 },
 "instructions": {
  "response": "Always provide a concise response and maintain a friendly tone.",
  "system": "You are a helpful data agent."
 },
 "tools": [
  {
    "tool_spec": {
     "type": "cortex_analyst_text_to_sql",
     "name": "Analyst1"
    }
  }
 ],
}
Copy

更新 Cortex Agent

PUT /api/v2/databases/{database}/schemas/{schema}/agents/{name}

使用指定的属性和规范更新现有的 Cortex Agent。

请求

路径参数

参数

描述

database

(必填)您的 Snowflake 账户 URL。可使用 /api/v2/databases GET 请求获取可用数据库列表。

schema

(必需)架构标识符。可使用 /api/v2/databases/{database}/schemas GET 请求获取指定数据库的可用架构列表。

name

(必需)代理的名称。

请求标头

标头

描述

Authorization

(必需)授权令牌。有关更多信息,请参阅 身份验证

Content-Type

(必需)应用程序/json

请求正文

The request body defines the agent's name, profile, model configuration, orchestration, instructions, tools, and tool resources.

字段

类型

描述

comment

字符串

Optional comment about the agent.

profile

对象

代理的配置信息(显示名称、头像、颜色等)。

models

对象

代理的模型配置。包括编排模型(例如 llama3.3-70B)。如果未提供,则自动选择模型。

orchestration

对象

编排配置,包括预算约束(例如 secondstokens)。

instructions

对象

代理的行为指令,包括响应、编排、系统和示例问题。

tools

数组

代理可用的工具列表。每个工具包含一个 tool_spec,其中包括类型、名称、描述和输入架构。

tool_resources

对象

对工具数组中每个引用工具的配置。键必须与工具 name 匹配。

profile

The profile field configures tool selection behavior.

字段

类型

描述

display_name

字符串

Display name for the agent.

avatar

字符串

代理的头像图片。

color

字符串

代理的颜色主题。

models

The models field configures models for the agent.

字段

类型

描述

orchestration

字符串

用于编排的模型。如果未提供,则自动选择模型。

orchestration

The orchestration field configures orchestration settings for the agent.

字段

类型

描述

budget

对象

Budget constraints for the agent.

budget

budget 对象指定代理的资源限制。

字段

类型

描述

seconds

整数

时间预算(秒)。

tokens

整数

令牌预算。

instructions

instructions 字段用于定义代理的行为指令,包括响应生成、工具编排、系统指令以及示例问题。

字段

类型

描述

response

字符串

响应生成的指令。

orchestration

字符串

用于编排不同工具的指令。

system

字符串

代理的系统指令。

sample_questions

数组

代理的示例问题及可选答案。

sample_questions

sample_questions 数组中的每个元素都是一个对象,包含以下字段:

字段

类型

描述

question

字符串

Sample question.

answer

字符串

可选示例答案。

tools

tools 字段定义代理可使用的工具列表。工具提供特定功能,如数据分析、搜索或通用功能。每个工具可能在 tool_resources 对象中有对应的配置。

字段

类型

描述

tool_spec

对象

(必需)工具的类型、配置及输入要求的规范。

tool_spec

tool_spec 对象描述工具的功能和配置。

字段

类型

描述

type

字符串

(必需)工具功能类型。可为特定类型,如 cortex_analyst_text_to_sql,或通用工具 generic

  • cortex_search

  • cortex_analyst_text_to_sql

  • data_to_chart

  • generic

name

字符串

(必需)工具实例的唯一标识符。用于在 tool_resources 中匹配配置。

description

字符串

待考虑使用工具的描述。

input_schema

对象

此工具期望输入参数的 JSON 架构定义。对于通用工具,此字段必填,用于指定输入要求。

input_schema

The input_schema object defines the input parameters for the tool.

字段

类型

描述

type

字符串

输入架构对象的类型。

properties

对象

每个输入参数的定义。

required

数组

必填输入参数名称列表。

example

对象

省略输入参数的示例。

tool_resources

tool_resources 对象定义 tools 数组中每个引用工具的配置。每个键必须与工具 name 匹配。值可以是以下对象之一:

Cortex Analyst analysis tool configuration

Cortex Analyst 分析工具的配置。提供用于 SQL 查询生成和执行的参数。

字段

类型

描述

semantic_model_file

字符串

存储在 Snowflake Stage 中的文件路径,该文件包含语义模型 yaml。

semantic_view

字符串

Snowflake 原生语义模型对象的名称。示例:db.schema.semantic_view

Search tool configuration

搜索功能的配置。定义文档搜索和检索的方式。

字段

类型

描述

search_service

字符串

搜索服务的名称。必须采用以下格式:database.schema.service_name

name

字符串

保留字段。

max_results

整数

用于 LLM 提示的搜索结果数量。

title_column

字符串

The title column of the document.

id_column

字符串

The ID column of the document.

filter

对象

搜索结果的筛选查询。对象由字段和值对组成。

两种配置对象均允许添加额外属性。

Example request body

{
 "name": "my_agent",
 "comment": "Sample agent",
 "profile": {
  "display_name": "My Data Agent",
  "avatar": "AiIcon",
  "color": "#00AEEF"
 },
 "models": {
  "orchestration": "llama3.3-70B"
 },
 "orchestration": {
  "budget": {
   "seconds": 200,
   "tokens": 5000
   }
  },
 "instructions": {
  "response": "Always provide a concise response and maintain a friendly tone.",
  "orchestration": "<orchestration instructions>"
  "system": "You are a helpful data agent."
  "sample_questions": [
    {
      "question": "Sample question",
      "answer": "sample answer"
    }
  ]
 },
 "tools": [
  {
   "tool_spec": {
          "description": "Analyst to analyze price",
    "type": "cortex_analyst_text_to_sql",
    "name": "Analyst1"
   }
  },
  {
   "tool_spec": {
    "type": "cortex_search",
    "name": "Search1"
   }
  }
 ],
 "tool_resources": [
  {
    "Search1": {
        "search_service": "db.schema.service_name",
        "filter": {"@eq": {"region": "North America"} },
        "max_results": 5
    }
  },
  {
    "Analyst1": {
     "semantic_view": "my_db.my_sch.my_sem_view_1"
    }
  }
 ]
}
Copy

响应

成功的响应会返回一个 JSON 对象,其中包含有关 Cortex Agent 更新状态的详细信息。

Response body

{"status": "Agent xxxx successfully updated."}
Copy

List Cortex Agents

GET /api/v2/databases/{database}/schemas/{schema}/agents

列出指定数据库和模式下的 Cortex Agent。

请求

路径参数

参数

描述

database

(必需)资源所属数据库的标识符。您可以使用 /api/v2/databases GET 请求来获取可用数据库的列表。

schema

(必需)资源所属架构的标识符。您可以使用 /api/v2/databases/{database}/schemas GET 请求来获取指定数据库的可用架构列表。

Query parameters

参数

描述

like

(可选)按资源名称筛选输出。使用不区分大小写的模式匹配,并支持 SQL 通配符。

fromName

(可选)仅从第一个对象名称匹配指定字符串的行之后开始获取行。区分大小写,不必是完整名称。

showLimit

(可选)限制命令返回的最大行数。最小值:1.最大值:10000。

请求标头

标头

描述

Authorization

(必需)授权令牌。有关更多信息,请参阅 身份验证

Content-Type

(必需)应用程序/json

响应

成功响应会返回一个包含 Cortex Agent 资源的 JSON 数组。

Response headers

标头

描述

X-Snowflake-Request-ID

Unique ID of the API request.

Link

结果页的链接(例如首页、尾页等)。该标头可以包含多个具有不同 rel 属性值的 URL 条目,用于指定返回的页面(first、next、prev 和 last)。

Response body

[
 {
  "name": "my_agent",
  "database": "TEST_DB",
  "schema": "TEST_SCHEMA",
  "created_on": "2024-06-01T12:00:00Z",
  "owner": "ACCOUNTADMIN",
  "comment": "Sample agent"
 },
 {
  "name": "another_agent",
  "database": "TEST_DB",
  "schema": "TEST_SCHEMA",
  "created_on": "2024-06-02T08:30:00Z",
  "owner": "SYSADMIN",
  "comment": ""
 }
]
Copy

删除 Cortex Agent

DELETE /api/v2/databases/{database}/schemas/{schema}/agents/{name}

删除具有指定名称的 Cortex Agent。如果 ifExists 参数设置为 true,即使该代理不存在,操作仍然会成功。否则,如果代理无法删除,操作将失败。

请求

路径参数

参数

描述

database

(必需)资源所属数据库的标识符。您可以使用 /api/v2/databases GET 请求来获取可用数据库的列表。

schema

(必需)资源所属架构的标识符。您可以使用 /api/v2/databases/{database}/schemas GET 请求来获取指定数据库的可用架构列表。

name

(Required) Identifier for the agent.

Query parameters

参数

描述

ifExists

(可选)指定当代理不存在时如何处理请求。

  • true:选择使用 时默认使用的角色和仓库。如果代理不存在,端点不会报错。它会返回 200 成功响应,但不执行任何操作。

  • false:选择使用 时默认使用的角色和仓库。如果代理不存在,端点会报错。

请求标头

标头

描述

Authorization

(必需)授权令牌。有关更多信息,请参阅 身份验证

Content-Type

(必需)应用程序/json

响应

成功的响应会返回一条确认消息。

Response body

{
 "status": "Request successfully completed"
}
Copy

Run agent object

POST /api/v2/databases/{database}/schemas/{schema}/agents/{name}:run

Sends a user query to the Cortex Agent object and returns its response as a stream of events.

请求

路径参数

参数

描述

database

(必需)包含该代理的数据库。可使用 /api/v2/databases GET 请求获取可用数据库列表。

schema

(必需)包含该代理的架构。可使用 /api/v2/databases/{database}/schemas GET 请求获取指定数据库的可用架构列表。

name

(必需)代理的名称。

请求标头

标头

描述

Authorization

(Required) Authorization token. See 身份验证.

Content-Type

(必需)应用程序/json

请求正文

请求正文包含对话历史记录、工具配置和可选的执行设置。

字段

类型

描述

thread_id

整数

可选。对话的线程标识符。如果使用 thread_id,则必须同时传递 parent_message_id

parent_message_id

整数

可选。本次运行应从消息 ID 开始。初始 parent_message_id 应为 0

messages

数组

(必需)如果存在 thread_idparent_message_id,则表示本次会话轮次中当前用户的消息。否则,表示会话历史和当前消息。包含按时间顺序排列的用户查询和助手响应。

execution_trace

对象

可选。执行追踪的配置。

tool_choice

对象

Optional. Configures tool selection behavior.

messages

The messages array contains the conversation history between the user and assistant. If a thread is used, only user message is needed.

字段

类型

描述

role

字符串

(必需)确定是谁发送了消息,即用户或助手。用户消息通常包含查询,而助手消息包含响应和工具结果。

有效值:模型监视器名称字符串。

  • "user"

  • "assistant"

content

数组

(必需)组成消息的内容元素数组。可以包含文本、工具结果或自定义内容类型。

schema_version

数组

可选。架构的版本。

消息内容结构

每条消息的 content 数组可以包含多个不同类型的内容元素。

字段

类型

描述

type

字符串

内容类型。

有效值:模型监视器名称字符串。

"text"

type"text" 时:

字段

类型

描述

annotations

数组

附加到文本结果的注释数组。可以是 cortex_search_citationweb_search_citation

is_elicitation

布尔

此文本内容是否表示代理正在向终端用户请求更多信息。

cortex_search_citation

cortex_search_citation 对象包含以下字段:

字段

类型

描述

index

整数

(必需)搜索结果中引用的索引。

search_result_id

字符串

(Required) The unique identifier for the search result.

doc_id

字符串

(Required) The unique identifier for the document.

doc_title

字符串

(必需)文档的标题。

text

字符串

必填)文档中作为引用使用的文本片段。

web_search_citation

The web_search_citation object contains the following fields:

字段

类型

描述

start_index

整数

(必需)文本中引用的起始索引。

end_index

整数

(必需)文本中引用的结束索引。

source_url

字符串

(必需)源文档的 URL。

text

字符串

(必需)源文档中作为引用使用的文本片段。

"thinking"

When type is "thinking":

字段

类型

描述

type

字符串

消息的文本内容。

thinking

字符串

代理的思考令牌。

"tool_use"

When type is "tool_use":

字段

类型

描述

tool_use

对象

工具使用请求详细信息的容器。

tool_use.tool_use_id

字符串

Unique identifier for this tool use request. Can be used to associated tool results.

tool_use.type

字符串

工具的类型。例如,cortex_searchcortex_analyst_text2sql

tool_use.name

字符串

The unique identifier for this tool instance.

tool_use.input

对象

The structured input for this tool.

"tool_result"

When type is "tool_result":

字段

类型

描述

tool_result

对象

(Required) Container for tool execution results and metadata.

tool_result.tool_use_id

字符串

(Required) Unique identifier for this tool use. Can be used to associated tool results.

tool_result.type

字符串

(必需)工具的类型。例如,cortex_searchcortex_analyst_text2sql

tool_result.name

字符串

(Required) The unique identifier for this tool instance.

tool_result.status

字符串

(Required) Tool execution status.

有效值:模型监视器名称字符串。

  • "success"

  • "error"

tool_result.result

对象

其他结果数据。

tool_result.content

数组

(Required) Array of content elements produced by the tool execution.

可以包含以下类型的元素:

类型

字段

描述

text

type: "text"
text: string

工具返回的纯文本内容。

json

type: "json"
json: object

Structured JSON data returned by the tool. The schema varies depending on the tool type.

"table"

When type is "table":

字段

类型

描述

table

对象

(Required) The table content of the message.

table.tool_use_id

字符串

(Required) The ID of the tool use that generated this table.

table.query_id

字符串

(必需)生成该数据的 SQL 查询的查询 ID。

table.result_set

字符串

(必需)生成该数据的 SQL 查询的查询 ID。

table.result_set

ResultSet 对象表示 SQL 查询执行的结果。此对象与 ResultSet 的架构匹配。

字段

类型

描述

statementHandle

字符串

(Required) The unique identifier for the executed statement.

resultSetMetaData

对象

(必需)描述结果集结构的元数据。

data

字符串数组的数组

(必需)实际的结果数据,以行数组的形式表示。每一行是一个字符串值的数组。

resultSetMetaData

ResultSetMetaData 对象描述 SQL 查询结果集的元数据。

字段

类型

描述

partition

整数

(必需)结果集的分区号。

numRows

整数

(必需)结果集中的行数。

format

字符串

(必需)结果集的格式。

rowType

数组

(必需)描述每一行类型的数组。每个元素都是一个 rowType 对象。

rowType

RowType 对象描述 SQL 查询结果集中单行的元数据。

字段

类型

描述

name

整数

(必需)行的名称。

type

整数

(必需)行的数据类型。

length

字符串

(必需)长度。

precision

数组

(Required) The precision.

scale

数组

(必需)小数位数。

nullable

数组

(必需)指示该行是否可以包含空值。

"chart"

When type is "chart"`:

字段

类型

描述

chart

对象

消息的图表内容。

Chart content structure

chart 对象包含以下字段:

字段

类型

描述

tool_use_id

字符串

(Required) The ID of the tool use that generated this chart.

chart_spec

字符串

(必需)以字符串形式序列化的 vega-lite 图表规范。

analyst_tool_use_id

字符串

(已弃用)生成该图表数据的 Cortex Analyst 工具调用的 tool_use_id。客户端应使用 tool_use_id 获取图表工具使用,并在需要时从中找到 Analyst tool_use_id

"suggested_queries"

When type is "suggested_queries"`:

字段

类型

描述

suggested_queries

数组

(必需):code:query 数组的数组。

execution_trace

The execution_trace object configures execution tracing for the agent:

字段

类型

描述

enabled

布尔

(必需)是否启用执行追踪。

tool_choice

The tool_choice object configures how tools should be selected and used during the interaction.

字段

类型

描述

type

字符串

(必需)确定工具的选择方式:

  • auto - 自动选择工具(默认)

  • required - Must use at least one tool

  • tool - Use specific named tools

name

字符串数组

List of specific tool names to use when type is tool.

Example request

{
  "thread_id": "1234567890",
  "parent_message_id": "1234567890",
  "tool_choice": {
    "type": "auto"
  },
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What are the top three customers by revenue?"
        }
      ]
    }
  ]
}
Copy

响应

When streaming, each event arrives in Server-Sent Events (SSE) format, with the following primary patterns:

response events

字段

类型

描述

event

字符串

response for the final response event.

data

对象

Contains response data.

data.role

字符串

The role of the message sender. Must be assistant.

data.content

数组

构成响应的内容元素数组。内容元素遵循 content 的架构。

response.text events

字段

类型

描述

event

字符串

response.text,用于文本内容块事件。

data

对象

Contains the text event data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.content

数组

构成响应的内容元素数组。内容元素遵循 content 的架构。

data.text

字符串

A text result from the agent.

data.annotations

数组

附加在文本结果上的注释数组(例如引用)。可以是 cortex_search_citationweb_search_citation

data.is_elicitation

布尔

此文本内容是否表示代理正在向终端用户请求更多信息。

response.text.delta events

字段

类型

描述

event

字符串

response.text.delta for a text delta event.

data

对象

Contains the text delta data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.text

字符串

来自代理的文本增量。

data.is_elicitation

布尔

此文本内容是否表示代理正在向终端用户请求更多信息。

response.text.annotation events

字段

类型

描述

event

字符串

response.text.annotation,用于注释事件。

data

对象

Contains the annotation data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.annotation_index

整数

此事件在注释内容数组中所代表的索引。

data.annotations

数组

附加在文本结果上的注释数组(例如引用)。可以是 cortex_search_citationweb_search_citation

response.thinking events

字段

类型

描述

event

字符串

response.thinking,用于思考内容块事件。

data

对象

包含思考内容块数据。

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.text

字符串

代理的思考令牌。

response.thinking.delta events

字段

类型

描述

event

字符串

response.thinking.delta for a thinking delta event.

data

对象

Contains the thinking delta data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.text

字符串

思考令牌。

response.tool_use events

字段

类型

描述

event

字符串

response.tool_use,用于思考内容块事件。

data

对象

Contains the tool use request data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.text

字符串

代理的思考令牌。

data.tool_use_id

字符串

Unique identifier for this tool use.

data.type

字符串

The type of the tool.

data.name

字符串

The unique identifier for this tool instance.

data.input

对象

此工具的结构化输入。此对象的架构会根据工具规范而有所不同。

response.tool_result events

字段

类型

描述

event

字符串

response.tool_result for a tool result event.

data

对象

Contains the tool result data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.text

字符串

代理的思考令牌。

data.tool_use_id

字符串

Unique identifier for this tool use.

data.type

字符串

The type of the tool.

data.name

字符串

The unique identifier for this tool instance.

data.content

数组

工具执行生成的内容元素的数组。每个元素都遵循 "tool_result" 架构。

response.tool_result.status events

字段

类型

描述

event

字符串

response.tool_result.status,用于工具结果状态事件。

data

对象

Contains the tool result status data.

data.tool_use_id

字符串

Unique identifier for this tool use.

data.tool_type

字符串

The type of the tool.

data.status

字符串

当前状态的枚举。

data.message

字符串

扩展说明当前状态的更详细消息。

response.tool_result.analyst.delta events

字段

类型

描述

event

字符串

response.tool_result.analyst.delta,用于 Cortex Analyst 工具执行增量事件。

data

对象

Contains the Cortex Analyst tool execution delta data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.tool_use_id

字符串

Unique identifier for this tool use. Can be used to associate tool results.

data.tool_type

字符串

工具的类型(此事件始终为 cortex_analyst_text2sql)。

data.tool_name

字符串

The unique identifier for this tool instance.

data.delta

对象

Cortex Analyst 工具执行的增量结果。

data.delta.text

字符串

来自 Cortex Analyst 最终响应的文本增量。

data.delta.think

字符串

来自 Cortex Analyst 推理步骤的文本增量。

data.delta.sql

字符串

来自 Cortex Analyst SQL 输出的增量。当前,整个 SQL 查询在单个事件中返回。

data.delta.sql_explanation

字符串

来自 Cortex Analyst 对 SQL 查询作用解释的增量。

data.delta.query_id

字符串

在 SQL 执行开始后生成的查询 ID。

data.delta.verified_query_used

布尔

是否使用了已验证的查询来生成此响应。

data.delta.result_set

对象

SQL 执行的结果。与 Snowflake 的 SQL API ResultSet 架构匹配。请参阅 Snowflake SQL API 引用

data.delta.suggestions

对象

来自 Cortex Analyst 推荐问题的增量。当 Analyst 因信息缺失或其他错误无法回答问题时发送。

data.delta.suggestions.index

对象

此增量在推荐数组中所代表的索引。

data.delta.suggestions.delta

对象

此索引推荐问题的文本增量。

response.table events

字段

类型

描述

event

字符串

response.table for a table content block event.

data

对象

Contains the table content block event data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.tool_use_id

字符串

The ID of the tool use that generated this table.

data.query_id

字符串

生成此数据的 SQL 查询的查询 ID。

data.result_set

对象

此表格的结果集。遵循 table.result_set 的架构。

data.title

字符串

此表格的标题。

response.chart events

字段

类型

描述

event

字符串

response.table,用于图表内容块事件。

data

对象

Contains the chart content block event data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.tool_use_id

字符串

The ID of the tool use that generated this chart.

data.chart_spec

字符串

以字符串序列化的 vega-lite 图表规范。

data.analyst_tool_use_id

对象

生成此图表数据的 Cortex Analyst 工具调用的工具使用 ID。此字段已弃用。客户端应使用 tool_use_id 获取图表工具使用,并在需要时从中找到 Analyst tool_use_id

response.status events

字段

类型

描述

event

字符串

response.status,用于状态更新事件。

data

对象

Contains the status update event data.

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.status

字符串

当前状态的枚举。

data.message

字符串

扩展说明当前状态的更详细消息。

response.suggested_queries events

字段

类型

描述

event

字符串

response.suggested_queries,用于推荐查询内容块事件。

data

对象

包含推荐查询内容块事件数据。

data.status

字符串

当前状态的枚举。

data.content_index

整数

此事件在响应内容数组中所代表的索引。

data.suggested_queries

数组

推荐查询的数组。请参阅 "suggested_queries"

error events

字段

类型

描述

event

字符串

错误事件的 error

data

对象

包含错误详细信息。

data.code

字符串

Snowflake 错误代码。例如 "399505"

data.message

字符串

对所发生错误的描述。例如 "Internal server error"

Error responses

API 返回标准错误响应,用于处理无效请求、未授权访问、禁止操作、资源未找到、方法不允许、超时、冲突以及服务器错误。每个错误响应包括一条消息、代码和请求 ID。

Example response

event: response.status
data: {"message":"Planning the next steps","status":"planning"}

event: response.thinking.delta
data: {"content_index":0,"text":"\nThe user is asking for a"}

event: response.thinking.delta
data: {"content_index":0,"text":" chart showing the"}

...
...
...

event: response.status
data: {"message":"Reviewing the results","status":"reasoning_agent_stop"}

event: response.status
data: {"message":"Forming the answer","status":"proceeding_to_answer"}

event: done
data: [DONE]
Copy

运行代理

:code:` POST <account_url>/api/v2/cortex/agent:run`

Sends a user query to the Cortex Agents service provided in the request body and returns its response. Interacts with the agent without creating an agent object.

请求

路径参数

参数

描述

account_url

(必填)您的 Snowflake 账户 URL。有关查找您的账户 URL 的说明,请参阅 查找账户的组织和账户名称

请求标头

标头

描述

Authorization

(必需)授权令牌。有关更多信息,请参阅 身份验证

Content-Type

(必需)应用程序/json

请求正文

请求正文包含模型、响应指令、实验字段、工具、工具资源和消息。

字段

类型

描述

model

字符串

Agent 用于生成响应的模型的名称。有关支持的模型列表,请参阅 模型

response_instruction

字符串

模型生成响应时遵循的指令。

experimental

对象

实验旗标已传递给代理。

tools

数组

代理可用的工具规格数组。

tool_resources

对象

工具所需的资源。

tool_choice

对象

用于选择工具的配置。

messages

数组

对话中的消息数组。

响应指令

response_instruction 字段是一个字符串,用于向模型提供生成响应的指令。

工具配置

本节详细介绍了支持的工具类型、其配置选项以及如何为每个工具指定必要的资源。

工具规格

tools 字段包含一系列可用的工具:

字段

类型

描述

tool_spec.type

字符串

工具的类型。类型和名称的组合是唯一的标识符。

tool_spec.name

字符串

工具名称。类型和名称的组合是唯一的标识符。

支持的 tool_spec.type 值包括以下内容:

  • cortex_search:用于 Cortex 搜索功能

  • cortex_analyst_text_to_sql:用于 Cortex Analyst 文本转 SQL

  • sql_exec:选择使用 时默认使用的角色和仓库。您负责执行 SQL 查询并以工具结果的形式提供结果。有关更多详细信息,请参阅下面的 示例答案请求

  • data_to_chart:用于生成图表

工具资源

tool_resources 对象为每个工具提供配置对象。

tool_resources: {
    "toolName1": {configuration object for toolName1},
    "toolName2": {configuration object for toolName2},
    // ...
}
Copy

每种工具类型的配置如下所述。

cortex_search

SearchName 对象包含 Cortex Search 工具的配置。

"SearchName": {
    // Required: The Snowflake search service identifier
    "name": "database.schema.service_name",
    // Optional: Number of search results to include
    "max_results": 5,
    // Optional: Column to use as document title
    "title_column": "title",
    // Optional: Column to use as document identifier
    "id_column": "id",
     // Optional: Filters to apply to search results (such as @eq for equality)
    "filter": {
      "@eq": {"<column>": "<value>"}
    }
}
Copy
cortex_analyst_text_to_sql

AnalystName 对象包含 Cortex Analyst 文本转 SQL 工具的配置。配置必须包括要使用的语义模型或视图。例如:

"AnalystName": {
    // Stage path to semantic model file in `semantic_model_file`
    "semantic_model_file": "@database.schema.stage/my_semantic_model.yaml"
}
Copy

或使用 语义视图概述

"AnalystName": {
    // Fully qualified name of the semantic view object
    "semantic_view": "database.schema.semantic_view"
}
Copy
工具选择

tool_choice 字段配置工具选择行为。

字段

类型

描述

type

字符串

应如何选择工具。

有效值:模型监视器名称字符串。

  • :code:`"auto"``(默认值)

  • :code:`"required"`(使用至少一个工具)

  • :code:`"tool"`(使用指定的工具)

name

数组

要使用的可选工具名称数组。仅在 type = "tool" 时有效。

消息

messages 数组包含用户和助理之间的对话历史记录:

字段

类型

描述

messages[].role

字符串

消息发送者的角色。

有效值:模型监视器名称字符串。

  • "system"

  • "user"

  • "assistant"

messages[].content

数组

组成消息的内容元素数组。

消息内容结构

每条消息的 content 数组可以包含多个不同类型的内容元素。

字段

类型

描述

messages[].content[].type

字符串

内容类型。

有效值:模型监视器名称字符串。

文本内容

type"text" 时:

字段

类型

描述

messages[].content[].text

字符串

消息的文本内容。

示例:

{
  "type": "text",
  "text": "Show me sales by region for Q1 2024"
}
Copy
图表内容

type 为“图表”时:

字段

类型

描述

messages[].content[].chart

对象

消息的图表内容。

messages[].content[].chart.chart_spec

字符串

图表为 Vega-Lite 规格。

示例:

{
  "type": "chart",
  "chart": {
    "chart_spec": "{\"$schema\":\"https://vega.github.io/schema/vega-lite/v5.json\",\"data\":{\"values\":[{\"REGION\":\"NORTH_AMERICA\",\"SUM(SALES)\":\"2000.00\"},{\"REGION\":\"EUROPE\",\"SUM(SALES)\":\"1700.00\"},{\"REGION\":\"SAUTH_AMERICA\",\"SUM(SALES)\":\"1500.00\"}]},\"encoding\":{\"x\":{\"field\":\"REGION\",\"sort\":null,\"type\":\"nominal\"},\"y\":{\"field\":\"SUM(SALES)\",\"sort\":null,\"type\":\"quantitative\"}},\"mark\":\"bar\"}",
  }
}
Copy
文本内容

type 为“表”时:

字段

类型

描述

messages[].content[].table

对象

消息的表内容。

messages[].content[].table.query_id

字符串

已执行的查询的 ID。

示例:

{
  "type": "table",
  "table": {
    "query_id": "01bbff92-0304-c8c7-0022-b7869a076c22"
  }
}
Copy
工具使用

type 为“tool_use”时:

字段

类型

描述

messages[].content[].tool_use

对象

工具使用请求详细信息的容器。

messages[].content[].tool_use.tool_use_id

字符串

此工具使用请求的唯一标识符。

messages[].content[].tool_use.name

字符串

要执行的工具的名称。必须与工具数组中的工具名称匹配。

messages[].content[].tool_use.input

对象

输入工具执行参数。

示例:

{
  "type": "tool_use",
  "tool_use": {
    "tool_use_id": "tu_01",
    "name": "Analyst1",
    "input": {
      "query": "Show me sales by region for Q1 2024"
    }
  }
}
Copy
工具结果

type"tool_results" 时:

字段

类型

描述

messages[].content[].tool_results

对象

工具执行结果和元数据的容器。

messages[].content[].tool_results.tool_use_id

字符串

参照生成这些结果的 tool_use_id。

messages[].content[].tool_results.name

字符串

已执行的工具的名称。必须与工具数组中的工具名称匹配。

messages[].content[].tool_results.status

字符串

工具执行状态。

有效值:模型监视器名称字符串。

  • "success"

  • "error"

messages[].content[].tool_results.content

数组

工具执行生成的内容元素的数组。

可以包含以下类型的元素:

类型

字段

描述

text

type: "text"
text: string

工具返回的纯文本内容。

json

type: "json"
json: object

工具返回的结构化 JSON 数据。

示例:

{
  "type": "tool_results",
  "tool_results": {
    "tool_use_id": "tu_01",
    "status": "success",
    "content": [
      {
        "type": "json",
        "json": {
          "sql": "SELECT region, SUM(sales) FROM sales_data WHERE quarter='Q1' AND year=2024 GROUP BY region"
          "text": "This is our interpretation of your question: Show me sales by region for Q1 2024. We have generated the following SQL query for you: SELECT region, SUM(sales) FROM sales_data WHERE quarter='Q1' AND year=2024 GROUP BY region"
        }
      }
    ]
  }
}
Copy
完整消息示例

此示例显示一条包含用户查询(roleuser)和响应(roleassistant)的完整消息。响应包括名为 Analyst1 的工具的工具使用事件和同一工具的工具结果事件。

{
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Show me sales by region for Q1 2024"
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "tool_use",
          "tool_use": {
            "tool_use_id": "tu_01",
            "name": "Analyst1",
            "input": {
              "query": "Show me sales by region for Q1 2024"
            }
          }
        },
        {
          "type": "tool_results",
          "tool_results": {
            "tool_use_id": "tu_01",
            "name": "Analyst1",
            "status": "success",
            "content": [
              {
                "type": "json",
                "json": {
                  "sql": "SELECT region, SUM(sales) FROM sales_data WHERE quarter='Q1' AND year=2024 GROUP BY region"
                  "text": "This is our interpretation of your question: Show me sales by region for Q1 2024. We have generated the following SQL query for you: SELECT region, SUM(sales) FROM sales_data WHERE quarter='Q1' AND year=2024 GROUP BY region"
                }
              }
            ]
          }
        }
      ]
    }
  ]
}
Copy

响应

进行流式传输时,各个事件以服务器发送的事件 (SSE) 格式到达,主要模式如下:

  • 输出块的增量 message.delta 事件

  • error 事件(如果出了问题)。

message.delta 事件

字段

类型

描述

event

字符串

部分消息数据的 message.delta

data

对象

包含增量更新数据。

data.id

字符串

消息的唯一标识符。

data.object

字符串

message.delta 或类似的描述符。

data.delta.content

数组

块或部分消息段的列表。

data.delta.content[].index

整数

此块在当前消息中的位置。

data.delta.content[].type

字符串

内容类型。有效值:模型监视器名称字符串。

  • "text"

  • "chart"

  • "table"

  • "tool_use"

  • "tool_results"

data.delta.content[].text

字符串

如果 type = "text",则为部分文本字符串。

data.delta.content[].chart

对象

如果 type = "chart",则为消息的图表内容。

data.delta.content[].chart.chart_spec

字符串

图表为 Vega-Lite 规格。

data.delta.content[].table

对象

如果为 type = "table",则为消息的表内容。

data.delta.content[].table.query_id

字符串

已执行的查询的 ID。

data.delta.content[].tool_use

对象

如果 type = "tool_use",表示正在进行工具调用。包含 tool_use_id、名称、输入。

data.delta.content[].tool_use.tool_use_id

字符串

工具调用的唯一标识符。

data.delta.content[].tool_use.name

字符串

正在调用的工具的名称。

data.delta.content[].tool_use.input

对象

工具的 JSON 有效负载。

data.delta.content[].tool_results

对象

如果 type = "tool_results",则包含工具输出。

data.delta.content[].tool_results.tool_use_id

字符串

工具输出的唯一标识符。

data.delta.content[].tool_results.status

字符串

工具执行状态。有效值:模型监视器名称字符串。

  • "success"

  • "error"

data.delta.content[].tool_results.content

数组

描述工具的返回数据的项目列表。

data.delta.content[].tool_results.content[].type

字符串

工具返回的内容类型。有效值:模型监视器名称字符串。

  • "text/csv"

  • "application/json"

  • "application/pdf"

data.delta.content[].tool_results.content[].json

对象

如果 type = "application/json",工具返回的 JSON 数据。

data.delta.content[].tool_results.content[].text

字符串

如果 type = "text",工具返回的文本数据。

error 事件

字段

类型

描述

event

字符串

错误事件的 error

data

对象

包含错误详细信息。

data.code

字符串

Snowflake 错误代码。例如 "399505"

data.message

字符串

对所发生错误的描述。例如 "Internal server error"

示例对话流

本部分显示用户和助手之间使用 Cortex Agents REST API 的示例对话流。

请求示例

{
  "model": "llama3.3-70b",
  "response_instruction": "You will always maintain a friendly tone and provide concise response.",
  "experimental": {},
  "tools": [
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "Analyst1"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "Analyst2"
      }
    },
    {
      "tool_spec": {
        "type": "sql_exec",
        "name": "sql_execution_tool"
      }
    },
    {
      "tool_spec": {
        "type": "data_to_chart",
        "name": "data_to_chart"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_search",
        "name": "Search1"
      }
    }
  ],
  "tool_resources": {
    "Analyst1": { "semantic_model_file": "stage1"},
    "Analyst2": { "semantic_model_file": "stage2"},
    "Search1": {
      "name": "db.schema.service_name",
      "filter": {"@eq": {"region": "North America"} }
    }
  },
  "tool_choice": {
    "type": "auto"
  },
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What are the top three customers by revenue?"
        }
      ]
    }
  ]
}
Copy

响应示例

{
  "id": "msg_001",
  "object": "message.delta",
  "delta": {
    "content": [
      {
        "index": 0,
        "type": "tool_use",
        "tool_use": {
          "tool_use_id": "toolu_XXXXXX",
          "name": "analyst1",
          "input": {
            "messages": [
              "role:USER content:{text:{text:\"What are the top three customers by revenue?\"}}"
            ],
            "model": "snowflake-hosted-semantic",
            "experimental": ""
          }
        }
      },
      {
        "index": 0,
        "type": "tool_results",
        "tool_results": {
          "tool_use_id": "toolu_XXXXXX",
          "content": [
            {
              "type": "json",
              "json": {
                "suggestions": [],
                "sql": "WITH __customers AS (\n  SELECT\n    customer_id,\n    revenue\n  FROM user_database.user_schema.user_table\n)\nSELECT\n  customer_id, revenue FROM __customers ORDER BY revenue DESC LIMIT 3\n -- Generated by Cortex Analyst\n;",
                "text": "This is our interpretation of your question:\n\n__What are the top three customers by revenue?\n\n"
              }
            }
          ],
          "status": "success"
        }
      },
        {
          "type": "tool_use",
          "tool_use": {
            "tool_use_id": "tool_002",
            "name": "sql_execution_tool",
            "input": {
              "sql": "WITH __customers AS (SELECT customer_id, revenue FROM user_database.user_schema.user_table) SELECT customer_id, revenue FROM __customers ORDER BY revenue DESC LIMIT 3"
            }
          }
        }
    ]
  }
}
Copy

示例答案请求

Cortex 代理可以根据已执行的 SQL 查询生成文本和图表答案。以下示例显示如何使用 Cortex Agent API 生成此类答案。

为了获得答案,客户向 Cortex Agent API 提出后续请求,并在客户端执行 SQL 的 query_id。最新响应消息中 sql_exec 工具类型的 tool_use 事件中提供要执行的 SQL。

请求必须使用 cortex_analyst_text_to_sqlsql_exec 工具来获得文本答案,而且还必须使用 data_to_chart 工具来获得图表答案。只有当代理认为图表是呈现答案的好方法时,才会返回图表。

备注

对于超过 4000 个单元格的结果集,将返回 table 响应,而不是 textchart 答案。

{
  "model": "llama3.3-70b",
  "response_instruction": "You will always maintain a friendly tone and provide concise response.",
  "experimental": {},
  "tools": [
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "Analyst1"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "Analyst2"
      }
    },
    {
      "tool_spec": {
        "type": "sql_exec",
        "name": "sql_execution_tool"
      }
    },
    {
      "tool_spec": {
        "type": "data_to_chart",
        "name": "data_to_chart"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_search",
        "name": "Search1"
      }
    }
  ],
  "tool_resources": {
    "Analyst1": { "semantic_model_file": "stage1"},
    "Analyst2": { "semantic_model_file": "stage2"},
    "Search1": {
      "name": "db.schema.service_name",
      "filter": {"@eq": {"region": "North America"} }
    }
  },
  "tool_choice": {
    "type": "auto"
  },
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What are the top three customers by revenue?"
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "tool_use",
          "tool_use": {
            "tool_use_id": "tool_001",
            "name": "Analyst1",
            "input": {
              "messages": [
                "role:USER content:{text:{text:\"What are the top three customers by revenue?\"}}"
              ],
              "model": "snowflake-hosted-semantic",
            }
          }
        },
        {
          "type": "tool_results",
          "tool_results": {
            "status": "success",
            "tool_use_id": "tool_001",
            "content": [
              {
                "type": "json",
                "json": {
                  "sql": "select * from table",
                  "text": "This is our interpretation of your question: What are the top three customers by revenue? \n\n"
                }
              }
            ]
          }
        }
      ]
    },
    {
      "role": "user",
      "content": [
      {
        "type": "tool_results",
        "tool_results": {
          "tool_use_id": "tool_001", // must match the previous tool use id sent back from the "assistant" role
          "name": "sql_execution_tool", // must match the name of the sql_exec tool previously sent in the request
          "content": [{
            "type": "json",
            "json": {
              "query_id": "01bcfcde-0100-0001-0000-000000102549"
            }
          }]
    }
  ]
}
Copy

示例答案响应

{
  "id": "msg_001",
  "object": "message.delta",
  "delta": {
    "content": [
      {
        "index": 0,
        "type": "text",
        "text": "This is a textual answer to your question"
      },
      {
        "index": 0,
        "type": "chart",
        "chart": {
          "chart_spec": "{\"$schema\": \"https://vega.github.io/schema/vega-lite/v5.json\", \"title\": \"Example chart\", \"mark\": \"bar\", \"encoding\": {\"x\": {\"field\": \"column_x\", \"type\": \"nominal\", \"sort\": null}, \"y\": {\"field\": \"column_y\", \"type\": \"quantitative\"}}, \"data\": {\"values\": [{\"column_x\": \"A\", \"column_y\": \"1\"}, {\"column_x\": \"A\", \"column_y\": \"1\"}]}}"
        }
      }
    ]
  }
}
Copy

Cortex 代理的局限性

  • 由于 Streamlit in Snowflake (SiS) 应用程序在 所有者权限 下运行,因此不支持在 SiS 应用程序内执行 SQL 语句。

  • 不支持 Azure OpenAI 模型。

语言: 中文