@retrivora-ai/rag-engine 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/DocumentChunker-Dh9TvmGG.d.mts +45 -0
  2. package/dist/DocumentChunker-Dh9TvmGG.d.ts +45 -0
  3. package/dist/{RagConfig-DRJO4hGU.d.mts → RagConfig-BEmz4hVP.d.mts} +58 -1
  4. package/dist/{RagConfig-DRJO4hGU.d.ts → RagConfig-BEmz4hVP.d.ts} +58 -1
  5. package/dist/{chunk-3JR3SAWX.mjs → chunk-MWL4AGQI.mjs} +216 -108
  6. package/dist/handlers/index.d.mts +2 -2
  7. package/dist/handlers/index.d.ts +2 -2
  8. package/dist/handlers/index.js +218 -110
  9. package/dist/handlers/index.mjs +11 -3
  10. package/dist/index-CSfaCeux.d.ts +206 -0
  11. package/dist/index-DFSy0CG6.d.mts +206 -0
  12. package/dist/index.d.mts +3 -4
  13. package/dist/index.d.ts +3 -4
  14. package/dist/index.js +103 -89
  15. package/dist/index.mjs +91 -95
  16. package/dist/server.d.mts +45 -97
  17. package/dist/server.d.ts +45 -97
  18. package/dist/server.js +298 -225
  19. package/dist/server.mjs +78 -167
  20. package/package.json +12 -10
  21. package/src/components/ChatWindow.tsx +2 -2
  22. package/src/components/ConfigProvider.tsx +2 -2
  23. package/src/components/MessageBubble.tsx +2 -2
  24. package/src/components/SourceCard.tsx +1 -1
  25. package/src/components/ThemeToggle.tsx +1 -1
  26. package/src/config/ConfigBuilder.ts +86 -211
  27. package/src/config/uiConstants.ts +23 -0
  28. package/src/core/ConfigResolver.ts +57 -29
  29. package/src/core/LangChainAgent.ts +73 -40
  30. package/src/core/Pipeline.ts +63 -7
  31. package/src/core/ProviderRegistry.ts +2 -2
  32. package/src/core/QueryProcessor.ts +9 -8
  33. package/src/handlers/index.ts +138 -49
  34. package/src/hooks/useRagChat.ts +71 -32
  35. package/src/rag/EntityExtractor.ts +40 -13
  36. package/src/server.ts +12 -2
  37. package/dist/DocumentChunker-C-sCZPhi.d.mts +0 -102
  38. package/dist/DocumentChunker-C-sCZPhi.d.ts +0 -102
  39. package/dist/index-B2mutkgp.d.ts +0 -116
  40. package/dist/index-Bjy0es5a.d.mts +0 -116
@@ -5,7 +5,12 @@
5
5
  *
6
6
  * Use this when you want to build a COMPLETELY CUSTOM UI but still leverage
7
7
  * the RAG backend. The hook handles all state: messages, loading, errors,
8
- * localStorage persistence, and the /api/chat round-trip via Axios.
8
+ * localStorage persistence, and the /api/chat round-trip.
9
+ *
10
+ * Consumes the SSE stream format produced by `createStreamHandler`:
11
+ * data: { type: "text", text: "..." }
12
+ * data: { type: "metadata", sources: [...] }
13
+ * data: { type: "error", error: "..." }
9
14
  *
10
15
  * Usage:
11
16
  * const { messages, send, clear, isLoading, error } = useRagChat('my-project');
@@ -14,7 +19,7 @@
14
19
  */
15
20
 
16
21
  import { useState, useCallback, useRef, useEffect } from 'react';
17
- import { VectorMatch } from '@/types';
22
+ import { VectorMatch } from '../types';
18
23
  import { useStoredMessages } from './useStoredMessages';
19
24
 
20
25
  // ─── Types ────────────────────────────────────────────────────────────────────
@@ -61,6 +66,36 @@ export interface UseRagChatReturn {
61
66
  setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
62
67
  }
63
68
 
69
+ // ─── SSE Frame Parser ──────────────────────────────────────────────────────────
70
+
71
+ interface SseTextFrame { type: 'text'; text: string }
72
+ interface SseMetaFrame { type: 'metadata'; sources?: VectorMatch[] }
73
+ interface SseErrorFrame { type: 'error'; error: string }
74
+ type SseFrame = SseTextFrame | SseMetaFrame | SseErrorFrame;
75
+
76
+ /**
77
+ * Parse all complete SSE frames from a raw chunk string.
78
+ * Handles cases where a single `read()` value contains multiple frames.
79
+ */
80
+ function parseSseChunk(raw: string): SseFrame[] {
81
+ const frames: SseFrame[] = [];
82
+ // Split on double-newline (SSE frame boundary)
83
+ for (const block of raw.split('\n\n')) {
84
+ for (const line of block.split('\n')) {
85
+ if (!line.startsWith('data: ')) continue;
86
+ try {
87
+ const frame = JSON.parse(line.slice(6)) as SseFrame;
88
+ if (frame && typeof frame === 'object' && 'type' in frame) {
89
+ frames.push(frame);
90
+ }
91
+ } catch {
92
+ // Ignore malformed frames
93
+ }
94
+ }
95
+ }
96
+ return frames;
97
+ }
98
+
64
99
  // ─── Hook ─────────────────────────────────────────────────────────────────────
65
100
 
66
101
  export function useRagChat(
@@ -88,13 +123,13 @@ export function useRagChat(
88
123
 
89
124
  // ── Core send function ────────────────────────────────────────────────────
90
125
  const sendMessage = useCallback(
91
- async (text: string, options?: { skipUserMessage?: boolean }) => {
126
+ async (text: string, opts?: { skipUserMessage?: boolean }) => {
92
127
  const trimmed = text.trim();
93
128
  if (!trimmed || isLoading) return;
94
129
 
95
130
  lastInputRef.current = trimmed;
96
131
 
97
- if (!options?.skipUserMessage) {
132
+ if (!opts?.skipUserMessage) {
98
133
  const userMessage: RagMessage = {
99
134
  id: `user_${Date.now()}`,
100
135
  role: 'user',
@@ -133,8 +168,10 @@ export function useRagChat(
133
168
  const decoder = new TextDecoder();
134
169
  let assistantContent = '';
135
170
  let sources: VectorMatch[] = [];
171
+ // Buffer for partial SSE frames that arrive split across reads
172
+ let buffer = '';
136
173
 
137
- // Add a placeholder assistant message that we will update
174
+ // Add a placeholder assistant message that we will update incrementally
138
175
  const assistantMessageId = `assistant_${Date.now()}`;
139
176
  setMessages((prev) => [
140
177
  ...prev,
@@ -150,41 +187,43 @@ export function useRagChat(
150
187
  const { done, value } = await reader.read();
151
188
  if (done) break;
152
189
 
153
- const chunk = decoder.decode(value, { stream: true });
154
-
155
- // Handle protocol tokens
156
- if (chunk.includes('__METADATA__')) {
157
- const [text, metadataStr] = chunk.split('__METADATA__');
158
- if (text) assistantContent += text;
159
- try {
160
- const meta = JSON.parse(metadataStr);
161
- sources = meta.sources || [];
162
- } catch {
163
- console.warn('[useRagChat] Failed to parse metadata');
164
- }
165
- } else if (chunk.includes('__ERROR__')) {
166
- const [text, errorStr] = chunk.split('__ERROR__');
167
- if (text) assistantContent += text;
168
- try {
169
- const err = JSON.parse(errorStr);
170
- setError(err.error || 'Stream error');
171
- } catch {
172
- setError('An error occurred during streaming');
190
+ buffer += decoder.decode(value, { stream: true });
191
+
192
+ // Only process complete frames (ending with \n\n)
193
+ const lastBoundary = buffer.lastIndexOf('\n\n');
194
+ if (lastBoundary === -1) continue; // Wait for more data
195
+
196
+ const complete = buffer.slice(0, lastBoundary + 2);
197
+ buffer = buffer.slice(lastBoundary + 2);
198
+
199
+ for (const frame of parseSseChunk(complete)) {
200
+ if (frame.type === 'text') {
201
+ assistantContent += frame.text;
202
+ } else if (frame.type === 'metadata') {
203
+ sources = frame.sources ?? [];
204
+ } else if (frame.type === 'error') {
205
+ setError(frame.error || 'Stream error');
173
206
  }
174
- } else {
175
- assistantContent += chunk;
176
207
  }
177
208
 
178
- // Update the specific message
179
- setMessages((prev) =>
180
- prev.map((msg) =>
181
- msg.id === assistantMessageId
182
- ? { ...msg, content: assistantContent, sources: sources.length > 0 ? sources : msg.sources }
209
+ // Update the assistant message with accumulated content
210
+ setMessages((prev) =>
211
+ prev.map((msg) =>
212
+ msg.id === assistantMessageId
213
+ ? { ...msg, content: assistantContent, sources: sources.length > 0 ? sources : msg.sources }
183
214
  : msg
184
215
  )
185
216
  );
186
217
  }
187
218
 
219
+ // Process any remaining buffered data
220
+ if (buffer.trim()) {
221
+ for (const frame of parseSseChunk(buffer)) {
222
+ if (frame.type === 'text') assistantContent += frame.text;
223
+ else if (frame.type === 'metadata') sources = frame.sources ?? [];
224
+ }
225
+ }
226
+
188
227
  const finalAssistantMessage: RagMessage = {
189
228
  id: assistantMessageId,
190
229
  role: 'assistant',
@@ -35,7 +35,7 @@ Text to extract from:
35
35
  const response = await this.llm.chat([
36
36
  { role: 'system', content: 'You are a precise knowledge graph extraction engine. You always output valid JSON and nothing else.' },
37
37
  { role: 'user', content: prompt }
38
- ], '', { maxTokens: 2048, temperature: 0.1 });
38
+ ], '', { maxTokens: 4096, temperature: 0.1 });
39
39
 
40
40
  try {
41
41
  // 1. Try to find the JSON block using a regex
@@ -44,20 +44,47 @@ Text to extract from:
44
44
 
45
45
  return JSON.parse(cleanJson);
46
46
  } catch {
47
+ // 2. If parsing fails, try to repair truncated JSON
48
+ try {
49
+ const repaired = this.repairTruncatedJson(response);
50
+ if (repaired) return JSON.parse(repaired);
51
+ } catch { /* ignore repair failure */ }
52
+
47
53
  console.warn(`[EntityExtractor] Failed to parse LLM response. Length: ${response.length} chars.`);
48
-
49
- // Attempt very basic "fix" if it looks like it was truncated
50
- if (response.trim().endsWith('}') === false && response.includes('"nodes"')) {
51
- try {
52
- // This is a last-resort attempt to see if we can get anything out of a truncated response
53
- const partialResponse = response.trim() + (response.includes('[') ? ']}' : '}');
54
- const jsonMatch = partialResponse.match(/\{[\s\S]*\}/);
55
- if (jsonMatch) return JSON.parse(jsonMatch[0]);
56
- } catch { /* ignore */ }
57
- }
58
-
59
- console.warn('[EntityExtractor] Full failing response:', response.substring(0, 200) + '...');
54
+ console.warn('[EntityExtractor] Snippet:', response.substring(0, 100) + '...');
60
55
  return { nodes: [], edges: [] };
61
56
  }
62
57
  }
58
+
59
+ /**
60
+ * Attempts to fix JSON that was cut off mid-generation.
61
+ * Strategy: Find the last valid element in an array and close the structure.
62
+ */
63
+ private repairTruncatedJson(json: string): string | null {
64
+ let text = json.trim();
65
+
66
+ // Find the first { and work from there
67
+ const startIdx = text.indexOf('{');
68
+ if (startIdx === -1) return null;
69
+ text = text.substring(startIdx);
70
+
71
+ // If it's truncated in an array like "nodes": [ ... , { ...
72
+ // We try to find the last complete object before the truncation
73
+ const lastCompleteObjectIdx = text.lastIndexOf('}');
74
+ if (lastCompleteObjectIdx === -1) return null;
75
+
76
+ // Truncate at the last complete object
77
+ let repaired = text.substring(0, lastCompleteObjectIdx + 1);
78
+
79
+ // Close any open structures (arrays or the main object)
80
+ const openBrackets = (repaired.match(/\{/g) || []).length;
81
+ const closedBrackets = (repaired.match(/\}/g) || []).length;
82
+ const openSquares = (repaired.match(/\[/g) || []).length;
83
+ const closedSquares = (repaired.match(/\]/g) || []).length;
84
+
85
+ for (let i = 0; i < openSquares - closedSquares; i++) repaired += ']';
86
+ for (let i = 0; i < openBrackets - closedBrackets; i++) repaired += '}';
87
+
88
+ return repaired;
89
+ }
63
90
  }
package/src/server.ts CHANGED
@@ -17,7 +17,7 @@ export type { BatchOptions, BatchResult } from './core/BatchProcessor';
17
17
  // ── Core Orchestration ─────────────────────────────────────────
18
18
  export { VectorPlugin } from './core/VectorPlugin';
19
19
  export { Pipeline } from './core/Pipeline';
20
- export { ConfigResolver } from './core/ConfigResolver';
20
+ export { ConfigResolver, resetConfigCache } from './core/ConfigResolver';
21
21
  export { ProviderRegistry } from './core/ProviderRegistry';
22
22
  export { ConfigValidator } from './core/ConfigValidator';
23
23
  export { ProviderHealthCheck } from './core/ProviderHealthCheck';
@@ -54,4 +54,14 @@ export { OllamaProvider } from './llm/providers/OllamaProvider';
54
54
  export { UniversalLLMAdapter } from './llm/providers/UniversalLLMAdapter';
55
55
 
56
56
  // ── Next.js Route Handler Factories ───────────────────────────
57
- export { createChatHandler, createIngestHandler, createHealthHandler, createUploadHandler } from './handlers';
57
+ export {
58
+ createChatHandler,
59
+ createStreamHandler,
60
+ createIngestHandler,
61
+ createHealthHandler,
62
+ createUploadHandler,
63
+ sseFrame,
64
+ sseTextFrame,
65
+ sseMetaFrame,
66
+ sseErrorFrame,
67
+ } from './handlers';
@@ -1,102 +0,0 @@
1
- /**
2
- * Generic LLM Provider interface.
3
- * Covers both chat completion and embedding generation so a single
4
- * provider can handle both responsibilities when appropriate.
5
- */
6
- interface ChatMessage {
7
- role: 'user' | 'assistant' | 'system';
8
- content: string;
9
- }
10
- interface ChatOptions {
11
- /** Override max tokens for this specific call */
12
- maxTokens?: number;
13
- /** Override temperature for this specific call */
14
- temperature?: number;
15
- /** Stop sequences */
16
- stop?: string[];
17
- }
18
- interface EmbedOptions {
19
- /** Override model for this specific embed call */
20
- model?: string;
21
- /** Specify the task type for models that require prefixes (e.g. nomic-embed-text) */
22
- taskType?: 'query' | 'document';
23
- }
24
- interface ILLMProvider {
25
- /**
26
- * Send a chat completion request.
27
- * @param messages – the full conversation history
28
- * @param context – retrieved RAG context to inject
29
- * @param options – optional per-call overrides
30
- * @returns – the assistant's reply text
31
- */
32
- chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
33
- /**
34
- * Send a streaming chat completion request.
35
- * @returns – an async iterable of text chunks
36
- */
37
- chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
38
- /**
39
- * Generate an embedding vector for the given text.
40
- * @param text – text to embed
41
- * @param options – optional overrides
42
- * @returns – float array (the embedding)
43
- */
44
- embed(text: string, options?: EmbedOptions): Promise<number[]>;
45
- /**
46
- * Generate embedding vectors for multiple texts in a single batch.
47
- * @param texts – array of texts to embed
48
- * @param options – optional overrides
49
- * @returns – array of float arrays
50
- */
51
- batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]>;
52
- /**
53
- * Check if the provider endpoint is reachable.
54
- */
55
- ping(): Promise<boolean>;
56
- }
57
-
58
- /**
59
- * DocumentChunker — splits long text into overlapping chunks
60
- * suitable for vector embedding and retrieval.
61
- *
62
- * Strategy: sentence-aware sliding window
63
- * 1. Split on sentence boundaries
64
- * 2. Accumulate sentences into chunks up to `chunkSize` characters
65
- * 3. Carry over `chunkOverlap` characters from the previous chunk
66
- */
67
- interface Chunk {
68
- id: string;
69
- content: string;
70
- metadata?: Record<string, unknown>;
71
- }
72
- interface ChunkOptions {
73
- /** Target chunk size in characters (default 1000) */
74
- chunkSize?: number;
75
- /** Overlap between consecutive chunks in characters (default 200) */
76
- chunkOverlap?: number;
77
- /** Source document identifier used as ID prefix */
78
- docId?: string | number;
79
- /** Extra metadata to attach to every chunk */
80
- metadata?: Record<string, unknown>;
81
- /** Characters used to split text, in order of priority */
82
- separators?: string[];
83
- }
84
- declare class DocumentChunker {
85
- private readonly chunkSize;
86
- private readonly chunkOverlap;
87
- private readonly separators;
88
- constructor(chunkSize?: number, chunkOverlap?: number, separators?: string[]);
89
- /**
90
- * Split a single text string into overlapping chunks using a recursive strategy.
91
- * Preserves structural boundaries (Markdown headers) where possible.
92
- */
93
- chunk(text: string, options?: ChunkOptions): Chunk[];
94
- private recursiveSplit;
95
- chunkMany(documents: Array<{
96
- content: string;
97
- docId?: string | number;
98
- metadata?: Record<string, unknown>;
99
- }>): Chunk[];
100
- }
101
-
102
- export { type ChatMessage as C, DocumentChunker as D, type EmbedOptions as E, type ILLMProvider as I, type ChatOptions as a, type Chunk as b, type ChunkOptions as c };
@@ -1,102 +0,0 @@
1
- /**
2
- * Generic LLM Provider interface.
3
- * Covers both chat completion and embedding generation so a single
4
- * provider can handle both responsibilities when appropriate.
5
- */
6
- interface ChatMessage {
7
- role: 'user' | 'assistant' | 'system';
8
- content: string;
9
- }
10
- interface ChatOptions {
11
- /** Override max tokens for this specific call */
12
- maxTokens?: number;
13
- /** Override temperature for this specific call */
14
- temperature?: number;
15
- /** Stop sequences */
16
- stop?: string[];
17
- }
18
- interface EmbedOptions {
19
- /** Override model for this specific embed call */
20
- model?: string;
21
- /** Specify the task type for models that require prefixes (e.g. nomic-embed-text) */
22
- taskType?: 'query' | 'document';
23
- }
24
- interface ILLMProvider {
25
- /**
26
- * Send a chat completion request.
27
- * @param messages – the full conversation history
28
- * @param context – retrieved RAG context to inject
29
- * @param options – optional per-call overrides
30
- * @returns – the assistant's reply text
31
- */
32
- chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
33
- /**
34
- * Send a streaming chat completion request.
35
- * @returns – an async iterable of text chunks
36
- */
37
- chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
38
- /**
39
- * Generate an embedding vector for the given text.
40
- * @param text – text to embed
41
- * @param options – optional overrides
42
- * @returns – float array (the embedding)
43
- */
44
- embed(text: string, options?: EmbedOptions): Promise<number[]>;
45
- /**
46
- * Generate embedding vectors for multiple texts in a single batch.
47
- * @param texts – array of texts to embed
48
- * @param options – optional overrides
49
- * @returns – array of float arrays
50
- */
51
- batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]>;
52
- /**
53
- * Check if the provider endpoint is reachable.
54
- */
55
- ping(): Promise<boolean>;
56
- }
57
-
58
- /**
59
- * DocumentChunker — splits long text into overlapping chunks
60
- * suitable for vector embedding and retrieval.
61
- *
62
- * Strategy: sentence-aware sliding window
63
- * 1. Split on sentence boundaries
64
- * 2. Accumulate sentences into chunks up to `chunkSize` characters
65
- * 3. Carry over `chunkOverlap` characters from the previous chunk
66
- */
67
- interface Chunk {
68
- id: string;
69
- content: string;
70
- metadata?: Record<string, unknown>;
71
- }
72
- interface ChunkOptions {
73
- /** Target chunk size in characters (default 1000) */
74
- chunkSize?: number;
75
- /** Overlap between consecutive chunks in characters (default 200) */
76
- chunkOverlap?: number;
77
- /** Source document identifier used as ID prefix */
78
- docId?: string | number;
79
- /** Extra metadata to attach to every chunk */
80
- metadata?: Record<string, unknown>;
81
- /** Characters used to split text, in order of priority */
82
- separators?: string[];
83
- }
84
- declare class DocumentChunker {
85
- private readonly chunkSize;
86
- private readonly chunkOverlap;
87
- private readonly separators;
88
- constructor(chunkSize?: number, chunkOverlap?: number, separators?: string[]);
89
- /**
90
- * Split a single text string into overlapping chunks using a recursive strategy.
91
- * Preserves structural boundaries (Markdown headers) where possible.
92
- */
93
- chunk(text: string, options?: ChunkOptions): Chunk[];
94
- private recursiveSplit;
95
- chunkMany(documents: Array<{
96
- content: string;
97
- docId?: string | number;
98
- metadata?: Record<string, unknown>;
99
- }>): Chunk[];
100
- }
101
-
102
- export { type ChatMessage as C, DocumentChunker as D, type EmbedOptions as E, type ILLMProvider as I, type ChatOptions as a, type Chunk as b, type ChunkOptions as c };
@@ -1,116 +0,0 @@
1
- import { c as RagConfig, C as ChatResponse } from './RagConfig-DRJO4hGU.js';
2
- import { NextRequest, NextResponse } from 'next/server';
3
-
4
- interface ValidationError {
5
- field: string;
6
- message: string;
7
- suggestion?: string;
8
- severity: 'error' | 'warning';
9
- }
10
- /**
11
- * ConfigValidator.ts — Comprehensive configuration validation.
12
- * Uses a pluggable architecture to delegate provider-specific checks.
13
- */
14
- declare class ConfigValidator {
15
- /**
16
- * Validates the entire RagConfig object.
17
- */
18
- static validate(config: RagConfig): Promise<ValidationError[]>;
19
- private static validateVectorDbConfig;
20
- private static validateLLMConfig;
21
- private static validateEmbeddingConfig;
22
- /**
23
- * Temporary fallbacks for providers not yet migrated to the pluggable architecture.
24
- */
25
- private static fallbackVectorValidation;
26
- private static fallbackLLMValidation;
27
- private static fallbackEmbeddingValidation;
28
- private static validateUIConfig;
29
- private static validateRAGConfig;
30
- private static isValidCSSColor;
31
- static validateAndThrow(config: RagConfig): Promise<void>;
32
- }
33
-
34
- /**
35
- * Interface for provider-specific configuration validation logic.
36
- */
37
- interface IProviderValidator {
38
- /**
39
- * Validates the configuration for a specific provider.
40
- * @param config - The configuration object to validate.
41
- * @returns An array of validation errors (empty if valid).
42
- */
43
- validate(config: Record<string, unknown>): ValidationError[];
44
- }
45
- /**
46
- * Result of a provider health check.
47
- */
48
- interface HealthCheckResult {
49
- healthy: boolean;
50
- provider: string;
51
- version?: string;
52
- capabilities?: Record<string, unknown>;
53
- error?: string;
54
- timestamp: number;
55
- }
56
- /**
57
- * Interface for provider-specific health checking logic.
58
- */
59
- interface IProviderHealthChecker {
60
- /**
61
- * Performs a health check for a specific provider.
62
- * @param config - The configuration object used to connect to the provider.
63
- * @returns A promise that resolves to the health check result.
64
- */
65
- check(config: Record<string, unknown>): Promise<HealthCheckResult>;
66
- }
67
-
68
- /**
69
- * createChatHandler — factory that returns a Next.js App Router POST handler
70
- */
71
- declare function createChatHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
72
- error: string;
73
- }> | NextResponse<ChatResponse>>;
74
- /**
75
- * createStreamHandler — factory that returns a streaming Next.js App Router POST handler
76
- */
77
- declare function createStreamHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<Response>;
78
- /**
79
- * createIngestHandler — factory for the document ingestion endpoint.
80
- */
81
- declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
82
- error: string;
83
- }> | NextResponse<{
84
- results: {
85
- docId: string | number;
86
- chunksIngested: number;
87
- }[];
88
- }>>;
89
- /**
90
- * createHealthHandler — factory for the health-check endpoint.
91
- */
92
- declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
93
- timestamp: string;
94
- vectorDb: HealthCheckResult;
95
- llm: HealthCheckResult;
96
- embedding?: HealthCheckResult;
97
- allHealthy: boolean;
98
- status: string;
99
- }> | NextResponse<{
100
- status: string;
101
- error: string;
102
- }>>;
103
- /**
104
- * createUploadHandler — factory for the file upload ingestion endpoint.
105
- */
106
- declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
107
- error: string;
108
- }> | NextResponse<{
109
- message: string;
110
- results: {
111
- docId: string | number;
112
- chunksIngested: number;
113
- }[];
114
- }>>;
115
-
116
- export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, createHealthHandler as b, createChatHandler as c, createIngestHandler as d, createUploadHandler as e, createStreamHandler as f };