Search Shortcut cmd + k | ctrl + k

- Overview
- Documentation
- Development
- Download Metrics
- FAQ
- Core Extensions
- List of Community Extensions

- prql
- crypto
- flockmtl
- sheetreader
- magic

flockmtl
Downloads 337this week

LLM & RAG extension to combine analytics and semantic analysis

Extension repository on GitHub
Extension descriptor (YAML)

### Installing and Loading

    INSTALL flockmtl FROM community;
    LOAD flockmtl;

### Example

    -- 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://dsg-polymtl.github.io/flockmtl/docs/supported-providers). 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', {'context_window': 128000, 'max_output_tokens': 16400);

    -- Summarize text and pass it as parameter
    D SELECT llm_complete({'model_name': 'summarizer-model'}, {'prompt_name': 'summarize'}, {'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
--- | --- | --- | --- | ---
fusion_relative | scalar |  |  |
llm_complete | scalar |  |  |
llm_complete_json | scalar |  |  |
llm_embedding | scalar |  |  |
llm_filter | scalar |  |  |
llm_first | aggregate |  |  |
llm_last | aggregate |  |  |
llm_reduce | aggregate |  |  |
llm_rerank | aggregate |  |  |

### Overloaded Functions

function_name | function_type | description | comment | example
--- | --- | --- | --- | ---
array_append | macro |  |  |
array_intersect | macro |  |  |
array_pop_back | macro |  |  |
array_pop_front | macro |  |  |
array_prepend | macro |  |  |
array_push_back | macro |  |  |
array_push_front | macro |  |  |
array_reverse | macro |  |  |
array_to_string | macro |  |  |
array_to_string_comma_default | macro |  |  |
col_description | macro |  |  |
count_if | macro |  |  |
current_catalog | macro |  |  |
current_database | macro |  |  |
current_query | macro |  |  |
current_role | macro |  |  |
current_schema | macro |  |  |
current_schemas | macro |  |  |
current_user | macro |  |  |
date_add | macro |  |  |
fdiv | macro |  |  |
fmod | macro |  |  |
format_pg_type | macro |  |  |
format_type | macro |  |  |
generate_subscripts | macro |  |  |
geomean | macro |  |  |
geometric_mean | macro |  |  |
get_block_size | macro |  |  |
has_any_column_privilege | macro |  |  |
has_column_privilege | macro |  |  |
has_database_privilege | macro |  |  |
has_foreign_data_wrapper_privilege | macro |  |  |
has_function_privilege | macro |  |  |
has_language_privilege | macro |  |  |
has_schema_privilege | macro |  |  |
has_sequence_privilege | macro |  |  |
has_server_privilege | macro |  |  |
has_table_privilege | macro |  |  |
has_tablespace_privilege | macro |  |  |
histogram | table_macro |  |  |
histogram_values | table_macro |  |  |
inet_client_addr | macro |  |  |
inet_client_port | macro |  |  |
inet_server_addr | macro |  |  |
inet_server_port | macro |  |  |
list_any_value | macro |  |  |
list_append | macro |  |  |
list_approx_count_distinct | macro |  |  |
list_avg | macro |  |  |
list_bit_and | macro |  |  |
list_bit_or | macro |  |  |
list_bit_xor | macro |  |  |
list_bool_and | macro |  |  |
list_bool_or | macro |  |  |
list_count | macro |  |  |
list_entropy | macro |  |  |
list_first | macro |  |  |
list_histogram | macro |  |  |
list_intersect | macro |  |  |
list_kurtosis | macro |  |  |
list_kurtosis_pop | macro |  |  |
list_last | macro |  |  |
list_mad | macro |  |  |
list_max | macro |  |  |
list_median | macro |  |  |
list_min | macro |  |  |
list_mode | macro |  |  |
list_prepend | macro |  |  |
list_product | macro |  |  |
list_reverse | macro |  |  |
list_sem | macro |  |  |
list_skewness | macro |  |  |
list_stddev_pop | macro |  |  |
list_stddev_samp | macro |  |  |
list_string_agg | macro |  |  |
list_sum | macro |  |  |
list_var_pop | macro |  |  |
list_var_samp | macro |  |  |
map_contains_entry | macro |  |  |
map_contains_value | macro |  |  |
map_to_pg_oid | macro |  |  |
md5_number_lower | macro |  |  |
md5_number_upper | macro |  |  |
nullif | macro |  |  |
obj_description | macro |  |  |
pg_collation_is_visible | macro |  |  |
pg_conf_load_time | macro |  |  |
pg_conversion_is_visible | macro |  |  |
pg_function_is_visible | macro |  |  |
pg_get_constraintdef | macro |  |  |
pg_get_expr | macro |  |  |
pg_get_viewdef | macro |  |  |
pg_has_role | macro |  |  |
pg_is_other_temp_schema | macro |  |  |
pg_my_temp_schema | macro |  |  |
pg_opclass_is_visible | macro |  |  |
pg_operator_is_visible | macro |  |  |
pg_opfamily_is_visible | macro |  |  |
pg_postmaster_start_time | macro |  |  |
pg_size_pretty | macro |  |  |
pg_table_is_visible | macro |  |  |
pg_ts_config_is_visible | macro |  |  |
pg_ts_dict_is_visible | macro |  |  |
pg_ts_parser_is_visible | macro |  |  |
pg_ts_template_is_visible | macro |  |  |
pg_type_is_visible | macro |  |  |
pg_typeof | macro |  |  |
regexp_split_to_table | macro |  |  |
round_even | macro |  |  |
roundbankers | macro |  |  |
session_user | macro |  |  |
shobj_description | macro |  |  |
split_part | macro |  |  |
user | macro |  |  |