Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
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.
Usage example
After loading, any function call will throw an error if the provider's secret doesn't exist
-- 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 & setupAbout 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