snowflake-cortex-ai

Installation
SKILL.md

Snowflake Cortex AI

This skill covers Snowflake Cortex — the SQL-callable AI layer of Snowflake, including Cortex AI Functions for LLM/ML tasks and Cortex Search for managed hybrid (vector + keyword) search — all running inside Snowflake with no data leaving the platform.

Workflow for Building a Cortex-Powered Feature

  1. Pick the narrowest function for the task — Use AI_CLASSIFY for categorization, AI_FILTER for natural-language row filtering, AI_EXTRACT for structured field pulls, and reserve AI_COMPLETE for open-ended generation — narrower functions are cheaper and more reliable than routing everything through AI_COMPLETE.
  2. Check token cost before batch jobs — Run AI_COUNT_TOKENS(model, text) on a sample before running a function over a large table.
  3. Prototype in SQL — Call the function on a small LIMIT-ed sample and inspect results before running it over a full table.
  4. Structure prompts explicitly — Use PROMPT('template {0}', arg) for parameterized prompts and cast JSON output to VARIANT when you need structured fields back.
  5. For RAG, stand up Cortex Search — Create a CORTEX SEARCH SERVICE over the source table, query it via the Python or REST API to retrieve context, then pass that context into AI_COMPLETE.
  6. Use dedicated compute — Size Cortex Search's backing warehouse no larger than MEDIUM, and separate it from other pipeline warehouses.
  7. Guard against failures — Use TRY_COMPLETE in place of AI_COMPLETE for batch jobs where a single failure shouldn't fail the whole run; it returns NULL instead of raising an error.

Cortex AI Functions

Available functions (use these current names — do not use deprecated names like COMPLETE or CLASSIFY_TEXT):

Installs
19
GitHub Stars
259
First Seen
14 days ago
snowflake-cortex-ai — mindrally/skills