@retrivora-ai/rag-engine 0.4.4 → 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.
Files changed (73) hide show
  1. package/README.md +32 -57
  2. package/dist/{ChromaDBProvider-GI7TB7GJ.mjs → ChromaDBProvider-APQVJ5F7.mjs} +2 -2
  3. package/dist/{DocumentChunker-3yElxTO3.d.mts → DocumentChunker-C-sCZPhi.d.mts} +6 -6
  4. package/dist/{DocumentChunker-3yElxTO3.d.ts → DocumentChunker-C-sCZPhi.d.ts} +6 -6
  5. package/dist/{MilvusProvider-WDVTFB7D.mjs → MilvusProvider-35US67MS.mjs} +2 -2
  6. package/dist/{MongoDBProvider-ZKW34AEL.mjs → MongoDBProvider-COVYZDP6.mjs} +2 -2
  7. package/dist/{PineconeProvider-BE2JWSPD.mjs → PineconeProvider-AWFJQDZL.mjs} +2 -2
  8. package/dist/{PostgreSQLProvider-5HHTK4SU.mjs → PostgreSQLProvider-IEYRJ7XJ.mjs} +2 -2
  9. package/dist/{QdrantProvider-XVDVBNIG.mjs → QdrantProvider-M6TQYZRO.mjs} +2 -2
  10. package/dist/{RagConfig-BgRDL9Vy.d.mts → RagConfig-DRJO4hGU.d.mts} +12 -1
  11. package/dist/{RagConfig-BgRDL9Vy.d.ts → RagConfig-DRJO4hGU.d.ts} +12 -1
  12. package/dist/{RedisProvider-EK2R2PQH.mjs → RedisProvider-3G5PBLZ4.mjs} +2 -2
  13. package/dist/{SimpleGraphProvider-M6T7SE7D.mjs → SimpleGraphProvider-UK7DJW37.mjs} +1 -1
  14. package/dist/{UniversalVectorProvider-YIDRX6VT.mjs → UniversalVectorProvider-FYQ3B2PW.mjs} +3 -3
  15. package/dist/{WeaviateProvider-4CAPQ7UY.mjs → WeaviateProvider-ITHO36IL.mjs} +2 -2
  16. package/dist/{chunk-5KNBWQM6.mjs → chunk-4A47RCG2.mjs} +5 -1
  17. package/dist/{chunk-EDLTMSNY.mjs → chunk-67AJ6SMD.mjs} +1 -1
  18. package/dist/{chunk-IWHCAQEA.mjs → chunk-7SOSCZGS.mjs} +68 -7
  19. package/dist/{chunk-LJWWPTWE.mjs → chunk-FLOSGE6A.mjs} +76 -14
  20. package/dist/{chunk-H6RKMU7W.mjs → chunk-NXUCKY5L.mjs} +1 -1
  21. package/dist/{chunk-KTS3LLHY.mjs → chunk-OOQXNLXD.mjs} +5 -5
  22. package/dist/{chunk-OKY5P6RA.mjs → chunk-P4HAQ7KB.mjs} +1186 -1345
  23. package/dist/chunk-QMIKLALV.mjs +57 -0
  24. package/dist/{chunk-3QWAK3RZ.mjs → chunk-TYHTZIDP.mjs} +6 -2
  25. package/dist/{chunk-GQT5LF4G.mjs → chunk-U6KHVZLF.mjs} +2 -2
  26. package/dist/{chunk-RK2UDJA2.mjs → chunk-WGSZNY3X.mjs} +1 -1
  27. package/dist/{chunk-XCNXPECE.mjs → chunk-ZNBKHNJ4.mjs} +55 -1
  28. package/dist/handlers/index.d.mts +2 -2
  29. package/dist/handlers/index.d.ts +2 -2
  30. package/dist/handlers/index.js +1417 -1377
  31. package/dist/handlers/index.mjs +3 -3
  32. package/dist/index-CrGMwXfO.d.ts +112 -0
  33. package/dist/index-v669iV-k.d.mts +112 -0
  34. package/dist/index.d.mts +5 -5
  35. package/dist/index.d.ts +5 -5
  36. package/dist/index.mjs +2 -2
  37. package/dist/server.d.mts +104 -158
  38. package/dist/server.d.ts +104 -158
  39. package/dist/server.js +1419 -1379
  40. package/dist/server.mjs +12 -12
  41. package/package.json +5 -1
  42. package/src/components/DocumentUpload.tsx +1 -1
  43. package/src/config/RagConfig.ts +7 -0
  44. package/src/core/ConfigValidator.ts +66 -492
  45. package/src/core/LangChainAgent.ts +78 -0
  46. package/src/core/Pipeline.ts +210 -222
  47. package/src/core/ProviderHealthCheck.ts +35 -406
  48. package/src/core/ProviderInterfaces.ts +37 -0
  49. package/src/core/ProviderRegistry.ts +70 -55
  50. package/src/core/QueryProcessor.ts +173 -0
  51. package/src/llm/ILLMProvider.ts +10 -0
  52. package/src/llm/LLMFactory.ts +33 -13
  53. package/src/llm/providers/AnthropicProvider.ts +55 -15
  54. package/src/llm/providers/GeminiProvider.ts +51 -0
  55. package/src/llm/providers/OllamaProvider.ts +100 -15
  56. package/src/llm/providers/OpenAIProvider.ts +60 -11
  57. package/src/providers/vectordb/BaseVectorProvider.ts +11 -0
  58. package/src/providers/vectordb/MilvusProvider.ts +4 -0
  59. package/src/providers/vectordb/MongoDBProvider.ts +75 -11
  60. package/src/providers/vectordb/PineconeProvider.ts +60 -5
  61. package/src/providers/vectordb/PostgreSQLProvider.ts +84 -14
  62. package/src/providers/vectordb/QdrantProvider.ts +4 -0
  63. package/src/providers/vectordb/WeaviateProvider.ts +8 -4
  64. package/src/rag/DocumentChunker.ts +15 -19
  65. package/src/rag/EntityExtractor.ts +1 -1
  66. package/src/rag/LlamaIndexIngestor.ts +61 -0
  67. package/src/rag/Reranker.ts +20 -0
  68. package/src/server.ts +1 -1
  69. package/src/types/index.ts +9 -0
  70. package/src/utils/DocumentParser.ts +1 -1
  71. package/dist/chunk-FWCSY2DS.mjs +0 -37
  72. package/dist/index-7qeLTPBL.d.mts +0 -114
  73. package/dist/index-DowY4_K0.d.ts +0 -114
@@ -3,9 +3,9 @@ import {
3
3
  createHealthHandler,
4
4
  createIngestHandler,
5
5
  createUploadHandler
6
- } from "../chunk-OKY5P6RA.mjs";
7
- import "../chunk-EDLTMSNY.mjs";
8
- import "../chunk-FWCSY2DS.mjs";
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-3yElxTO3.mjs';
4
- export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-3yElxTO3.mjs';
5
- import { V as VectorMatch, U as UIConfig } from './RagConfig-BgRDL9Vy.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-BgRDL9Vy.mjs';
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. */
@@ -27,7 +27,7 @@ interface DocumentUploadProps {
27
27
  /** Optional namespace for the upload */
28
28
  namespace?: string;
29
29
  /** Callback when upload completes */
30
- onUploadComplete?: (results: any) => void;
30
+ onUploadComplete?: (results: unknown) => void;
31
31
  /** Additional className */
32
32
  className?: string;
33
33
  }
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-3yElxTO3.js';
4
- export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-3yElxTO3.js';
5
- import { V as VectorMatch, U as UIConfig } from './RagConfig-BgRDL9Vy.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-BgRDL9Vy.js';
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. */
@@ -27,7 +27,7 @@ interface DocumentUploadProps {
27
27
  /** Optional namespace for the upload */
28
28
  namespace?: string;
29
29
  /** Callback when upload completes */
30
- onUploadComplete?: (results: any) => void;
30
+ onUploadComplete?: (results: unknown) => void;
31
31
  /** Additional className */
32
32
  className?: string;
33
33
  }
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  mergeDefined
3
- } from "./chunk-EDLTMSNY.mjs";
3
+ } from "./chunk-67AJ6SMD.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
7
- } from "./chunk-FWCSY2DS.mjs";
7
+ } from "./chunk-QMIKLALV.mjs";
8
8
 
9
9
  // src/components/ChatWidget.tsx
10
10
  import { useState as useState4 } from "react";