- Categories:
String & binary functions (AI Functions)
COMPLETE (SNOWFLAKE.CORTEX) (multimodal)¶
Note
is the latest version of this function. Use AI_COMPLETE for the latest functionality. You can continue to use COMPLETE (SNOWFLAKE.CORTEX).
使用语言模型,为给定图像和提示生成响应(补全)。此函数变体支持图像模型和文本模型,并处理存储在内部 Snowflake 暂存区或外部暂存区中的图像。COMPLETE 可用于批量处理单个图像、多个图像、对每张图像应用相同或不同的提示,或者在单个操作(例如,比较)中应用多个图像。
语法
使用下列之一:
实参
model指定要使用模型的字符串。指定以下模型之一:
claude-sonnet-4-6pixtral-large
支持的模型可能具有不同的成本和上下文窗口。可能会不时添加新模型。
promptA string containing a question about the image and optionally specifying an output format, such as JSON. Either this or the
prompt_objectargument is required.prompt_objectA SQL OBJECT containing a string prompt with numbered placeholders ({0}, {1}, and so on) and one or more text or FILE valuse that are inserted into the prompt. The PROMPT function is a convenient way to create an object with the required layout. Either this argument or
promptis required.file_objectA FILE object that contains an image file to be processed. Use the TO_FILE function to create FILE objects from a stage path. Required when using a string prompt.
FROM table一个可选表,其中包含图像路径和每个图像的可选提示,允许在一次调用中对图像进行批处理至 COMPLETE。
返回
包含语言模型响应的字符串。
使用说明
- 超过上下文窗口限制的输入会导致错误。超出上下文窗口限制的输出将被截断。
- To process multiple images, the prompt must be an object (typically created using the PROMPT function) that specifies a prompt template and the files to be processed.
- 仅支持文本和图像。不支持视频和音频文件。
- Images with filename extensions
.jpg,.jpeg,.png,.gif, and.webpare supported.pixtral-largealso supports.bmp. - Maximum image size is 10 MB for
pixtral-largeand 3.75 MB forclaude-sonnet-4-6. Additionally,claude-sonnet-4-6does not support images with a resolution greater than 8000x8000. - 包含图像的暂存区必须启用服务器端加密。不支持客户端加密暂存区。
- 该函数不支持自定义网络策略。
- 暂存区名称不区分大小写,但路径区分大小写。
示例
以下示例演示了带图像的 COMPLETE 函数的基本功能。
视觉问答
通货膨胀率图表用于回答有关数据的问题。

Comparison between inflation rates in 2023 and in2024 (Statista (https://www.statista.com/))
响应:
图像分类
此示例对单个图像中识别的地标进行了分类。

响应:
从图像中提取实体
此示例从图像中提取实体(对象)并以 JSON 格式返回结果。

响应:
批量处理目录或表中的图像
要批量处理多个图像,对每个图像执行相同的操作,将图像文件存储在同一个暂存区。将 COMPLETE 函数应用于表的每一行。
Note
The stage must have a directory table to retrieve the paths to its files.
首先,通过从目录中检索图像位置,将其转换为 FILE 对象,并将生成的 FILE 对象存储在表列中来创建表。使用如下 SQL 语句:
然后,将 COMPLETE 函数应用于包含 FILE 对象的列。以下示例对表中的每张图像进行了分类:
响应:
If you already have a table with paths to the images, you can use the TO_FILE function to construct the FILE objects within the query:
您也可以直接从暂存区的目录中检索要处理的图像,如下所示:
在表中提供图像和提示
To perform a different operation on each image in a table, provide the images and their corresponding prompts in a
table. In the following example, the table contains the stage path of each image in the img_path column and the
prompt in the prompt column.
法律声明
Refer to Snowflake AI and ML.