interface GsRagConfig {
/** LLM and embedding providers */
providers: LightRAGProviderRegistry;
/** Storage registry (pre-built or custom) */
storages?: ExtendedStorageRegistry;
/** Storage factory (for multi-workspace) */
storageFactory?: (ctx: { workspace: string }) => ExtendedStorageRegistry;
/** Workspace name (default: "default") */
workspace?: string;
/** Document readers (auto-created if omitted) */
readers?: DocumentReader[];
/** Password for encrypted PDFs */
pdfDecryptPassword?: string;
/** Document processing config */
document?: DocumentConfig;
/** Query config */
query?: QueryConfig;
/** Tokenizer model name */
tokenizerModel?: string;
/** Max concurrent file reads (default: 4) */
maxConcurrentFileReads?: number;
}interface DocumentConfig {
/** Chunk size in tokens (default: 1200) */
chunkTokenSize?: number;
/** Overlap between chunks in tokens (default: 100) */
chunkOverlapTokenSize?: number;
/** Max documents processed in parallel (default: 4) */
maxConcurrentDocuments?: number;
/** Split by character delimiter instead of token count */
splitByCharacter?: string;
/** Don't split large sections further when splitByCharacter is set */
splitByCharacterOnly?: boolean;
/** Max entity name length */
maxEntityNameLength?: number;
/** Language for extraction prompts */
language?: string;
/** Enable LLM response cache for entity extraction */
enableLlmCacheForEntityExtract?: boolean;
/** Max concurrent LLM calls during extraction */
llmModelMaxAsync?: number;
}interface QueryConfig {
/** Enable LLM response cache for queries */
enableLlmCache?: boolean;
}QueryParam can be constructed with partial overrides. All fields have sensible defaults:
| Field | Default | Env Override | Description |
|---|---|---|---|
mode |
"mix" |
— | Query mode |
onlyNeedContext |
false |
— | Return raw context only (no LLM) |
onlyNeedPrompt |
false |
— | Return rendered prompt only |
responseType |
"Multiple Paragraphs" |
— | LLM response format |
stream |
false |
— | Stream response via AsyncIterable |
topK |
40 |
TOP_K |
Top entities/relations to retrieve |
chunkTopK |
20 |
CHUNK_TOP_K |
Top chunks to retrieve |
maxEntityTokens |
6000 |
MAX_ENTITY_TOKENS |
Entity context token limit |
maxRelationTokens |
8000 |
MAX_RELATION_TOKENS |
Relation context token limit |
maxTotalTokens |
30000 |
MAX_TOTAL_TOKENS |
Total context token limit |
hlKeywords |
[] |
— | Pre-set high-level keywords |
llKeywords |
[] |
— | Pre-set low-level keywords |
conversationHistory |
[] |
— | Chat history for multi-turn |
historyTurns |
0 |
HISTORY_TURNS |
Turns of history to include |
userPrompt |
"" |
— | Additional LLM instructions |
enableRerank |
true |
RERANK_BY_DEFAULT |
Enable reranking |
includeReferences |
false |
— | Include references in response |
useLlmKeywordExtraction |
true |
— | Use LLM for keyword extraction |
| Variable | Default | Used By |
|---|---|---|
OPENAI_API_KEY |
— | OpenAI provider |
ANTHROPIC_API_KEY |
— | Anthropic provider |
GOOGLE_API_KEY |
— | Gemini provider |
OLLAMA_HOST |
http://localhost:11434 |
Ollama provider |
DATABASE_URL |
— | Postgres storage |
POSTGRES_URL |
— | Postgres storage (fallback) |
TOP_K |
40 |
QueryParam |
CHUNK_TOP_K |
20 |
QueryParam |
MAX_ENTITY_TOKENS |
6000 |
QueryParam |
MAX_RELATION_TOKENS |
8000 |
QueryParam |
MAX_TOTAL_TOKENS |
30000 |
QueryParam |
HISTORY_TURNS |
0 |
QueryParam |
RERANK_BY_DEFAULT |
true |
QueryParam |
WORKSPACE |
default |
Workspace selection |
LIGHTRAG_FAST_LOCAL_PIPELINE |
— | Skip extraction + KG merge |
All completion providers accept these common options:
{
model: string;
apiKey?: string; // or set via env var
baseURL?: string; // custom API endpoint
timeoutMs?: number; // default: 30_000
maxRetries?: number; // default: 3
temperature?: number;
maxTokens?: number;
}See Providers for provider-specific options.