Search Shortcut cmd + k | ctrl + k
flockmtl

DuckDB LLM Extension

Installing and Loading

INSTALL flockmtl FROM community;
LOAD flockmtl;

Example

-- After loading, any function call will throw an error if an OPENAI_API_KEY environment variable is not set

-- Call an OpenAI model with a predefined prompt ('Tell me hello world') and default model ('gpt-4o-mini')
D SELECT llm_complete('hello-world', 'default');
┌──────────────────────────────────────────┐
 llm_complete(hello_world, default_model) 
                 varchar                  
├──────────────────────────────────────────┤
                Hello world               
└──────────────────────────────────────────┘

-- Check the prompts and supported models
D GET PROMPTS;
D GET MODELS;

-- Create a new prompt for summarizing text
D CREATE PROMPT('summarize', 'summarize the text into 1 word: {{text}}');

-- Create a variable name for the model to do the summarizing
D CREATE MODEL('summarizer-model', 'gpt-4o', 128000);

-- Summarize text and pass it as parameter 
D SELECT llm_complete('summarize', 'summarizer-model', {'text': 'We support more functions and approaches to combine relational analytics and semantic analysis. Check our repo for documentation and examples.'});

About flockmtl

This extension is experimental and potentially unstable. Do not use it in production.

Added Functions

function_name function_type description comment example
llm_complete scalar      
llm_complete_json scalar      
llm_embedding scalar      
llm_filter scalar