@retrivora-ai/rag-engine 0.4.5 → 1.0.0
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.
- package/README.md +32 -57
- package/dist/{ChromaDBProvider-GI7TB7GJ.mjs → ChromaDBProvider-APQVJ5F7.mjs} +2 -2
- package/dist/{DocumentChunker-3yElxTO3.d.mts → DocumentChunker-C-sCZPhi.d.mts} +6 -6
- package/dist/{DocumentChunker-3yElxTO3.d.ts → DocumentChunker-C-sCZPhi.d.ts} +6 -6
- package/dist/{MilvusProvider-WDVTFB7D.mjs → MilvusProvider-35US67MS.mjs} +2 -2
- package/dist/{MongoDBProvider-RE3Q5S5B.mjs → MongoDBProvider-COVYZDP6.mjs} +2 -2
- package/dist/{PineconeProvider-BE2JWSPD.mjs → PineconeProvider-AWFJQDZL.mjs} +2 -2
- package/dist/{PostgreSQLProvider-5HHTK4SU.mjs → PostgreSQLProvider-IEYRJ7XJ.mjs} +2 -2
- package/dist/{QdrantProvider-XVDVBNIG.mjs → QdrantProvider-M6TQYZRO.mjs} +2 -2
- package/dist/{RagConfig-BgRDL9Vy.d.mts → RagConfig-DRJO4hGU.d.mts} +12 -1
- package/dist/{RagConfig-BgRDL9Vy.d.ts → RagConfig-DRJO4hGU.d.ts} +12 -1
- package/dist/{RedisProvider-EK2R2PQH.mjs → RedisProvider-3G5PBLZ4.mjs} +2 -2
- package/dist/{SimpleGraphProvider-M6T7SE7D.mjs → SimpleGraphProvider-UK7DJW37.mjs} +1 -1
- package/dist/{UniversalVectorProvider-YIDRX6VT.mjs → UniversalVectorProvider-FYQ3B2PW.mjs} +3 -3
- package/dist/{WeaviateProvider-4CAPQ7UY.mjs → WeaviateProvider-ITHO36IL.mjs} +2 -2
- package/dist/{chunk-5KNBWQM6.mjs → chunk-4A47RCG2.mjs} +5 -1
- package/dist/{chunk-EDLTMSNY.mjs → chunk-67AJ6SMD.mjs} +1 -1
- package/dist/{chunk-PQKTC73Y.mjs → chunk-7SOSCZGS.mjs} +67 -6
- package/dist/{chunk-LJWWPTWE.mjs → chunk-FLOSGE6A.mjs} +76 -14
- package/dist/{chunk-H6RKMU7W.mjs → chunk-NXUCKY5L.mjs} +1 -1
- package/dist/{chunk-KTS3LLHY.mjs → chunk-OOQXNLXD.mjs} +5 -5
- package/dist/{chunk-PRC5CZIZ.mjs → chunk-P4HAQ7KB.mjs} +1184 -1359
- package/dist/chunk-QMIKLALV.mjs +57 -0
- package/dist/{chunk-3QWAK3RZ.mjs → chunk-TYHTZIDP.mjs} +6 -2
- package/dist/{chunk-GQT5LF4G.mjs → chunk-U6KHVZLF.mjs} +2 -2
- package/dist/{chunk-RK2UDJA2.mjs → chunk-WGSZNY3X.mjs} +1 -1
- package/dist/{chunk-XCNXPECE.mjs → chunk-ZNBKHNJ4.mjs} +55 -1
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +1415 -1391
- package/dist/handlers/index.mjs +3 -3
- package/dist/index-CrGMwXfO.d.ts +112 -0
- package/dist/index-v669iV-k.d.mts +112 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/server.d.mts +104 -158
- package/dist/server.d.ts +104 -158
- package/dist/server.js +1414 -1390
- package/dist/server.mjs +12 -12
- package/package.json +5 -1
- package/src/config/RagConfig.ts +7 -0
- package/src/core/ConfigValidator.ts +66 -492
- package/src/core/LangChainAgent.ts +78 -0
- package/src/core/Pipeline.ts +210 -240
- package/src/core/ProviderHealthCheck.ts +35 -406
- package/src/core/ProviderInterfaces.ts +37 -0
- package/src/core/ProviderRegistry.ts +70 -55
- package/src/core/QueryProcessor.ts +173 -0
- package/src/llm/ILLMProvider.ts +10 -0
- package/src/llm/LLMFactory.ts +33 -13
- package/src/llm/providers/AnthropicProvider.ts +55 -15
- package/src/llm/providers/GeminiProvider.ts +51 -0
- package/src/llm/providers/OllamaProvider.ts +100 -15
- package/src/llm/providers/OpenAIProvider.ts +60 -11
- package/src/providers/vectordb/BaseVectorProvider.ts +11 -0
- package/src/providers/vectordb/MilvusProvider.ts +4 -0
- package/src/providers/vectordb/MongoDBProvider.ts +72 -8
- package/src/providers/vectordb/PineconeProvider.ts +60 -5
- package/src/providers/vectordb/PostgreSQLProvider.ts +84 -14
- package/src/providers/vectordb/QdrantProvider.ts +4 -0
- package/src/providers/vectordb/WeaviateProvider.ts +8 -4
- package/src/rag/DocumentChunker.ts +15 -19
- package/src/rag/LlamaIndexIngestor.ts +61 -0
- package/src/rag/Reranker.ts +20 -0
- package/src/server.ts +1 -1
- package/src/types/index.ts +9 -0
- package/dist/chunk-FWCSY2DS.mjs +0 -37
- package/dist/index-7qeLTPBL.d.mts +0 -114
- package/dist/index-DowY4_K0.d.ts +0 -114
package/dist/handlers/index.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
createHealthHandler,
|
|
4
4
|
createIngestHandler,
|
|
5
5
|
createUploadHandler
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-P4HAQ7KB.mjs";
|
|
7
|
+
import "../chunk-67AJ6SMD.mjs";
|
|
8
|
+
import "../chunk-QMIKLALV.mjs";
|
|
9
9
|
export {
|
|
10
10
|
createChatHandler,
|
|
11
11
|
createHealthHandler,
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
* createIngestHandler — factory for the document ingestion endpoint.
|
|
76
|
+
*/
|
|
77
|
+
declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
78
|
+
error: string;
|
|
79
|
+
}> | NextResponse<{
|
|
80
|
+
results: {
|
|
81
|
+
docId: string | number;
|
|
82
|
+
chunksIngested: number;
|
|
83
|
+
}[];
|
|
84
|
+
}>>;
|
|
85
|
+
/**
|
|
86
|
+
* createHealthHandler — factory for the health-check endpoint.
|
|
87
|
+
*/
|
|
88
|
+
declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
|
|
89
|
+
timestamp: string;
|
|
90
|
+
vectorDb: HealthCheckResult;
|
|
91
|
+
llm: HealthCheckResult;
|
|
92
|
+
embedding?: HealthCheckResult;
|
|
93
|
+
allHealthy: boolean;
|
|
94
|
+
status: string;
|
|
95
|
+
}> | NextResponse<{
|
|
96
|
+
status: string;
|
|
97
|
+
error: string;
|
|
98
|
+
}>>;
|
|
99
|
+
/**
|
|
100
|
+
* createUploadHandler — factory for the file upload ingestion endpoint.
|
|
101
|
+
*/
|
|
102
|
+
declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
103
|
+
error: string;
|
|
104
|
+
}> | NextResponse<{
|
|
105
|
+
message: string;
|
|
106
|
+
results: {
|
|
107
|
+
docId: string | number;
|
|
108
|
+
chunksIngested: number;
|
|
109
|
+
}[];
|
|
110
|
+
}>>;
|
|
111
|
+
|
|
112
|
+
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 };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { c as RagConfig, C as ChatResponse } from './RagConfig-DRJO4hGU.mjs';
|
|
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
|
+
* createIngestHandler — factory for the document ingestion endpoint.
|
|
76
|
+
*/
|
|
77
|
+
declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
78
|
+
error: string;
|
|
79
|
+
}> | NextResponse<{
|
|
80
|
+
results: {
|
|
81
|
+
docId: string | number;
|
|
82
|
+
chunksIngested: number;
|
|
83
|
+
}[];
|
|
84
|
+
}>>;
|
|
85
|
+
/**
|
|
86
|
+
* createHealthHandler — factory for the health-check endpoint.
|
|
87
|
+
*/
|
|
88
|
+
declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
|
|
89
|
+
timestamp: string;
|
|
90
|
+
vectorDb: HealthCheckResult;
|
|
91
|
+
llm: HealthCheckResult;
|
|
92
|
+
embedding?: HealthCheckResult;
|
|
93
|
+
allHealthy: boolean;
|
|
94
|
+
status: string;
|
|
95
|
+
}> | NextResponse<{
|
|
96
|
+
status: string;
|
|
97
|
+
error: string;
|
|
98
|
+
}>>;
|
|
99
|
+
/**
|
|
100
|
+
* createUploadHandler — factory for the file upload ingestion endpoint.
|
|
101
|
+
*/
|
|
102
|
+
declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
103
|
+
error: string;
|
|
104
|
+
}> | NextResponse<{
|
|
105
|
+
message: string;
|
|
106
|
+
results: {
|
|
107
|
+
docId: string | number;
|
|
108
|
+
chunksIngested: number;
|
|
109
|
+
}[];
|
|
110
|
+
}>>;
|
|
111
|
+
|
|
112
|
+
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { ReactNode } from 'react';
|
|
3
|
-
import { C as ChatMessage } from './DocumentChunker-
|
|
4
|
-
export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-
|
|
5
|
-
import { V as VectorMatch, U as UIConfig } from './RagConfig-
|
|
6
|
-
export { C as ChatResponse, E as EmbeddingConfig, a as EmbeddingProvider, I as IngestDocument, L as LLMConfig, b as LLMProvider, R as RAGConfig, c as RagConfig, d as UpsertDocument, e as VectorDBConfig, f as VectorDBProvider } from './RagConfig-
|
|
3
|
+
import { C as ChatMessage } from './DocumentChunker-C-sCZPhi.mjs';
|
|
4
|
+
export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-C-sCZPhi.mjs';
|
|
5
|
+
import { V as VectorMatch, U as UIConfig } from './RagConfig-DRJO4hGU.mjs';
|
|
6
|
+
export { C as ChatResponse, E as EmbeddingConfig, a as EmbeddingProvider, I as IngestDocument, L as LLMConfig, b as LLMProvider, R as RAGConfig, c as RagConfig, d as UpsertDocument, e as VectorDBConfig, f as VectorDBProvider } from './RagConfig-DRJO4hGU.mjs';
|
|
7
7
|
|
|
8
8
|
interface ChatWidgetProps {
|
|
9
9
|
/** Position of the floating button. Defaults to bottom-right. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { ReactNode } from 'react';
|
|
3
|
-
import { C as ChatMessage } from './DocumentChunker-
|
|
4
|
-
export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-
|
|
5
|
-
import { V as VectorMatch, U as UIConfig } from './RagConfig-
|
|
6
|
-
export { C as ChatResponse, E as EmbeddingConfig, a as EmbeddingProvider, I as IngestDocument, L as LLMConfig, b as LLMProvider, R as RAGConfig, c as RagConfig, d as UpsertDocument, e as VectorDBConfig, f as VectorDBProvider } from './RagConfig-
|
|
3
|
+
import { C as ChatMessage } from './DocumentChunker-C-sCZPhi.js';
|
|
4
|
+
export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-C-sCZPhi.js';
|
|
5
|
+
import { V as VectorMatch, U as UIConfig } from './RagConfig-DRJO4hGU.js';
|
|
6
|
+
export { C as ChatResponse, E as EmbeddingConfig, a as EmbeddingProvider, I as IngestDocument, L as LLMConfig, b as LLMProvider, R as RAGConfig, c as RagConfig, d as UpsertDocument, e as VectorDBConfig, f as VectorDBProvider } from './RagConfig-DRJO4hGU.js';
|
|
7
7
|
|
|
8
8
|
interface ChatWidgetProps {
|
|
9
9
|
/** Position of the floating button. Defaults to bottom-right. */
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mergeDefined
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-67AJ6SMD.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QMIKLALV.mjs";
|
|
8
8
|
|
|
9
9
|
// src/components/ChatWidget.tsx
|
|
10
10
|
import { useState as useState4 } from "react";
|