QuestionQ82

Snowflake Gen AI & LLM Functions

A Gen AI Specialist is building a pipeline in Snowflake to gather data that will be used to summarize customer chat messages.

The following table, CHAT_MESSAGES, was created:

Question Image

The Specialist wants to use the Snowflake Cortex COMPLETE function with the llama3-8b model to generate a summary of each conversation. The prompt should begin with: "Summarize this chat:" followed by the full text of all messages in that chat conversation.

Which query will achieve this?

  • A
  • B
  • C
  • D
Explanation

Because each conversation spans multiple rows in CHAT_MESSAGES, the message text for a given conversation_id must first be aggregated into a single string using LISTAGG(message_text), grouped by conversation_id via GROUP BY conversation_id, before being concatenated onto the required 'Summarize this chat:' prefix and passed into SNOWFLAKE.CORTEX.COMPLETE('llama3-8b', ...). This produces one row per conversation containing an AI-generated summary of the entire conversation's text, which matches the documented usage pattern for the COMPLETE function combined with SQL aggregation to build multi-row prompts (see Snowflake's COMPLETE function reference).

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!