Skip to content
DuckDB community extension

flock

LLM & RAG extension to combine analytics and semantic analysis

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 Β· SQL
INSTALL flock FROM community;
LOAD flock FROM community;

Try it in a temporary SQL session with flock already loaded. Queries run in this tab; examples using files or services need their own setup.

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

After loading, any function call will throw an error if the provider's secret doesn't exist

SQL session and output
-- After loading, any function call will throw an error if the provider's secret doesn't exist

-- Create your provider secret by following the [documentation](https://dais-labo.github.io/flock). For example, you can create a default OpenAI API key as follows:
D CREATE SECRET (TYPE OPENAI, API_KEY 'your-api-key');

-- Call an OpenAI model with a predefined prompt ('Tell me hello world') and default model ('gpt-4o-mini')
D SELECT llm_complete({'model_name': 'default'}, {'prompt_name': 'hello-world'});
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 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', 'openai');

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

Provided by dais-labo. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

Flock is an experimental DuckDB extension that enables seamless integration of large language models (LLMs) and retrieval-augmented generation (RAG) directly within SQL.

It introduces MODEL and PROMPT objects as first-class SQL entities, making it easy to define, manage, and reuse LLM interactions. Core functions like llm_complete, llm_filter, and llm_rerank allow you to perform generation, semantic filtering, and rankingβ€”all from SQL.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
dais-labo/flock
License
MIT
Maintainers
anasdorbani, queryproc, iZarrios
Written in
SQL & C++
Build source
f83d73cee9ac
Build definition
Community descriptor