- 类别:
:doc:`/sql-reference/functions-string`(大型语言模型)
AI_COMPLETE(单张图像)¶
备注
AI_COMPLETE 是 COMPLETE (SNOWFLAKE.CORTEX) 的更新版本。要获得最新功能,请使用 AI_COMPLETE。
使用支持的语言模型,根据文本提示生成响应(补全)。
语法¶
该函数有两个必需实参和四个可选实参。该函数可以与位置或命名实参语法一起使用。
将 AI_COMPLETE 与单张图像输入一起使用
AI_COMPLETE(
<model>, <predicate>, <file> [, <model_parameters> ] )
实参¶
model
指定要使用模型的字符串。指定以下模型之一:
claude-4-opus
claude-4-sonnet
claude-3-7-sonnet
claude-3-5-sonnet
llama4-maverick
llama4-scout
openai-o4-mini
openai-gpt-4.1
pixtral-large
受支持的模型可能会产生不同的 费用。
predicate
字符串提示符。
file
代表图像的 FILE 类型对象。
model_parameters
一个 对象,包含下列影响模型超参数的零个或多个选项。请参阅 LLM 设置 (https://www.promptingguide.ai/introduction/settings)。
temperature
:一个从 0 到 1(含)的值,用于控制语言模型输出的随机性。温度越高(例如 0.7),输出就越多样和随机,而温度越低(例如 0.2),输出就越确定和集中。默认值:0
top_p
:一个从 0 到 1(含)的值,用于控制语言模型的随机性和多样性,t通常用作temperature
的替代项。不同的是,top_p
限制模型输出的可能令牌集,而temperature
影响每个步骤选择哪些令牌。默认值:0
max_tokens
:设置响应中输出令牌的最大数量。数值小会导致响应截断。默认值:4096。最大允许值:8192
guardrails
:使用 Cortex Guard 筛选来自语言模型的潜在不安全和有害的响应。TRUE
或FALSE
。默认值为FALSE
。
返回¶
返回来自语言模型的字符串响应。
示例¶
以下示例演示了带图像的 COMPLETE 函数的基本功能。
视觉问答¶
通货膨胀率图表用于回答有关数据的问题。

2023 年和 2024 年通货膨胀率的比较 (Statista (https://www.statista.com/))¶
SELECT AI_COMPLETE('claude-3-5-sonnet',
'Which country will observe the largest inflation change in 2024 compared to 2023?',
TO_FILE('@myimages', 'highest-inflation.png'));
响应:
Looking at the data, Venezuela will experience the largest change in inflation rates between 2023 and 2024.
The inflation rate in Venezuela is projected to decrease significantly from 337.46% in 2023 to 99.98% in 2024,
representing a reduction of approximately 237.48 percentage points. This is the most dramatic change among
all countries shown in the chart, even though Zimbabwe has higher absolute inflation rates.
从图像中提取实体¶
此示例从图像中提取实体(对象)并以 JSON 格式返回结果。

SELECT AI_COMPLETE('claude-3-5-sonnet',
'Extract the kitchen appliances identified in this image. Respond in JSON only with the identified appliances.',
TO_FILE('@myimages', 'kitchen.png'));
响应:
{
"appliances": [ "microwave","electric stove","oven","refrigerator" ]
}
关于处理图像的使用说明¶
仅支持文本和图像。不支持视频和音频文件。
支持的图像格式:
.jpg
.jpeg
.png
.gif
.webp
pixtral
和llama4
模型也支持.bmp
。
大多数模型的最大图像大小为 10 MB,
claude
模型的最大图像大小为 3.75 MB。claude
模型不支持分辨率高于 8000x8000 的图像。包含图像的暂存区必须启用服务器端加密。不支持客户端加密暂存区。
该函数不支持自定义网络策略。
暂存区名称不区分大小写;路径区分大小写。