/** * LlmRagPlugin * * Adds RAG (Retrieval-Augmented Generation) query support to PostGraphile v5. * * When enabled, this plugin: * 1. Discovers tables with @hasChunks smart tag during schema build * 2. Adds a `ragQuery` root query field that orchestrates: * embed prompt → pgvector search chunks → assemble context → call chat LLM → return answer * 3. Adds an `embedText` root query field for standalone text-to-vector conversion * * Uses the extendSchema + grafast lambda pattern (same as bucket-provisioner * and presigned-url plugins) for async operations at execution time. * * RAG is a consumer of graphile-search's pgvector adapter — it uses the existing * chunk-aware tables but orchestrates the full LLM synthesis pipeline. * * Resolution order for embedder and chat completer: * 1. build.llmEmbedder / build.llmChatCompleter (from LlmModulePlugin) * 2. Falls back to error if not configured */ import type { GraphileConfig } from 'graphile-config'; import type { RagDefaults } from '../types'; declare global { namespace GraphileConfig { interface Plugins { LlmRagPlugin: true; } } } /** * Creates the LlmRagPlugin. * * @param ragDefaults - Default configuration for RAG queries */ export declare function createLlmRagPlugin(ragDefaults?: RagDefaults): GraphileConfig.Plugin;