@retrivora-ai/rag-engine 1.8.9 → 1.9.1

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 (44) hide show
  1. package/dist/{ILLMProvider-CbUtvWAW.d.mts → ILLMProvider-BQyKZLnd.d.mts} +10 -2
  2. package/dist/{ILLMProvider-CbUtvWAW.d.ts → ILLMProvider-BQyKZLnd.d.ts} +10 -2
  3. package/dist/handlers/index.d.mts +2 -2
  4. package/dist/handlers/index.d.ts +2 -2
  5. package/dist/handlers/index.js +1726 -522
  6. package/dist/handlers/index.mjs +1725 -521
  7. package/dist/{index-DgzcnqZs.d.ts → index-A0GqPsaG.d.ts} +1 -1
  8. package/dist/{index-c_y_5qdw.d.mts → index-CDftK3qs.d.mts} +1 -1
  9. package/dist/index.css +26 -0
  10. package/dist/index.d.mts +2 -2
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +246 -76
  13. package/dist/index.mjs +248 -76
  14. package/dist/server.d.mts +32 -5
  15. package/dist/server.d.ts +32 -5
  16. package/dist/server.js +1735 -733
  17. package/dist/server.mjs +1733 -731
  18. package/package.json +1 -1
  19. package/src/components/MarkdownComponents.tsx +3 -3
  20. package/src/components/MessageBubble.tsx +49 -2
  21. package/src/components/ProductCard.tsx +33 -6
  22. package/src/components/UIDispatcher.tsx +1 -0
  23. package/src/components/VisualizationRenderer.tsx +143 -11
  24. package/src/config/EmbeddingStrategy.ts +5 -4
  25. package/src/config/RagConfig.ts +10 -2
  26. package/src/config/serverConfig.ts +16 -1
  27. package/src/core/LLMRouter.ts +79 -0
  28. package/src/core/Pipeline.ts +262 -45
  29. package/src/core/ProviderRegistry.ts +6 -0
  30. package/src/core/QueryProcessor.ts +98 -0
  31. package/src/handlers/index.ts +8 -5
  32. package/src/hooks/useRagChat.ts +53 -17
  33. package/src/llm/providers/UniversalLLMAdapter.ts +110 -13
  34. package/src/providers/vectordb/ChromaDBProvider.ts +13 -6
  35. package/src/providers/vectordb/MilvusProvider.ts +18 -2
  36. package/src/providers/vectordb/MultiTablePostgresProvider.ts +16 -29
  37. package/src/providers/vectordb/PostgreSQLProvider.ts +4 -15
  38. package/src/providers/vectordb/QdrantProvider.ts +2 -5
  39. package/src/providers/vectordb/RedisProvider.ts +3 -4
  40. package/src/providers/vectordb/WeaviateProvider.ts +41 -3
  41. package/src/types/index.ts +26 -0
  42. package/src/utils/ProductExtractor.ts +5 -3
  43. package/src/utils/UITransformer.ts +1345 -534
  44. package/src/utils/synonyms.ts +2 -0
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { n as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, p as RetrievalResult, m as UpsertDocument, V as VectorMatch, G as GraphDBConfig, q as GraphNode, r as Edge, s as GraphSearchResult, o as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-CbUtvWAW.js';
1
+ import { n as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, p as RetrievalResult, m as UpsertDocument, V as VectorMatch, G as GraphDBConfig, q as GraphNode, r as Edge, s as GraphSearchResult, o as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-BQyKZLnd.js';
2
2
  export { C as Chunk, a as ChunkOptions, D as DocumentChunker } from './DocumentChunker-Dh9TvmGG.js';
3
- import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-DgzcnqZs.js';
4
- export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from './index-DgzcnqZs.js';
3
+ import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-A0GqPsaG.js';
4
+ export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from './index-A0GqPsaG.js';
5
5
  import 'next/server';
6
6
 
7
7
  /**
@@ -113,6 +113,7 @@ declare class Pipeline {
113
113
  private graphDB?;
114
114
  private llmProvider;
115
115
  private embeddingProvider;
116
+ private llmRouter;
116
117
  private chunker;
117
118
  private llamaIngestor?;
118
119
  private entityExtractor?;
@@ -150,6 +151,12 @@ declare class Pipeline {
150
151
  /**
151
152
  * High-performance streaming RAG flow.
152
153
  * Yields text chunks first, then the retrieval metadata + observability trace at the end.
154
+ *
155
+ * Latency optimizations:
156
+ * - Strategy classification runs in parallel with query embedding (saves ~400ms)
157
+ * - Hallucination scoring is fire-and-forget (doesn't block metadata yield)
158
+ * - UITransformation is computed after text streaming and emitted with metadata
159
+ * - SchemaMapper.train runs while answer generation streams
153
160
  */
154
161
  askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
155
162
  /**
@@ -157,6 +164,14 @@ declare class Pipeline {
157
164
  * Uses an LRU-bounded embedding cache to avoid re-embedding the same query.
158
165
  */
159
166
  private generateUiTransformation;
167
+ private applyStructuredFilters;
168
+ private resolveNumericPredicateValue;
169
+ private extractNumericValueFromContent;
170
+ private matchesNumericPredicate;
171
+ private normalizeComparableField;
172
+ private fieldSimilarityScore;
173
+ private fieldTokens;
174
+ private toFiniteNumber;
160
175
  retrieve(query: string, options: {
161
176
  namespace?: string;
162
177
  topK?: number;
@@ -811,8 +826,8 @@ declare class RedisProvider extends BaseVectorProvider {
811
826
  delete(id: string, namespace?: string): Promise<void>;
812
827
  deleteNamespace(namespace: string): Promise<void>;
813
828
  /**
814
- * Redis is TCP-based and has no HTTP health endpoint.
815
- * Returns true; actual connectivity is validated on the first operation.
829
+ * Check reachability via a PING command.
830
+ * Returns false on connection failure so health checks surface real problems.
816
831
  */
817
832
  ping(): Promise<boolean>;
818
833
  disconnect(): Promise<void>;
@@ -838,6 +853,9 @@ declare class WeaviateProvider extends BaseVectorProvider {
838
853
  deleteNamespace(namespace: string): Promise<void>;
839
854
  ping(): Promise<boolean>;
840
855
  disconnect(): Promise<void>;
856
+ private extractPrimitiveMetadata;
857
+ private buildWhereFilter;
858
+ private weaviateOperand;
841
859
  }
842
860
 
843
861
  /**
@@ -969,8 +987,17 @@ declare class UniversalLLMAdapter implements ILLMProvider {
969
987
  private readonly systemPrompt;
970
988
  private readonly maxTokens;
971
989
  private readonly temperature;
990
+ private readonly baseUrl;
991
+ private readonly apiKey?;
992
+ private readonly resolvedHeaders;
972
993
  constructor(config: LLMConfig | EmbeddingConfig);
973
994
  chat(messages: ChatMessage[], context?: string): Promise<string>;
995
+ /**
996
+ * Streaming chat using native fetch + ReadableStream.
997
+ * Parses OpenAI-compatible SSE frames: `data: {...}\n\n`
998
+ * Works with vLLM, LMStudio, Together AI, Fireworks, and any OpenAI-compatible API.
999
+ */
1000
+ chatStream(messages: ChatMessage[], context?: string): AsyncIterable<string>;
974
1001
  embed(text: string): Promise<number[]>;
975
1002
  batchEmbed(texts: string[]): Promise<number[][]>;
976
1003
  ping(): Promise<boolean>;