Skip to content

pg_ai_sdk

Translate natural language to SQL using Clickhouse ai-sdk-cpp

pg_ai_sdk · Translate natural language to SQL using Clickhouse ai-sdk-cpp

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101514pg_ai_sdkpg_ai_sdk1.0RAGUnknownC++

Usage

Sources:

pg_ai_sdk — This project is a PostgreSQL extension that translates natural language queries into SQL using the ClickHouse/ai-sdk-cpp. It allows users to query their database by asking questions in plain English. Use it for the corresponding vector, model, or retrieval workflow. Use the pinned upstream revision linked above as the API boundary and test it on the target PostgreSQL build.

Core Workflow

CREATE EXTENSION pg_ai_sdk;

-- Generate SQL query from natural language
SELECT generate_sql_from_text('how many matches were won by Royal Challengers Bangalore is 2023');

Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.

Important Objects

  • generate_sql_from_text(natural_language_query TEXT) is an extension function and returns TEXT.
  • generate_sql_from_text(natural_language_query TEXT, model_name TEXT) is an extension function and returns TEXT.
  • pg_ai_sdk_execute_json(natural_language_query text) is an extension function and returns text.
  • pg_ai_sdk_execute_json(natural_language_query text, model_name TEXT) is an extension function and returns text.

Requirements and Caveats

  • The reviewed control file declares default version 1.0.
  • The control file marks the extension as relocatable.
  • Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.

Table reader