@retrivora-ai/rag-engine 1.1.1 → 1.1.2
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/dist/{QdrantProvider-NMXOULCU.mjs → QdrantProvider-RLJTNGPY.mjs} +1 -1
- package/dist/{RagConfig-DVovvPmd.d.mts → RagConfig-FyMB_UG6.d.mts} +1 -1
- package/dist/{RagConfig-DVovvPmd.d.ts → RagConfig-FyMB_UG6.d.ts} +1 -1
- package/dist/{chunk-63HITIWC.mjs → chunk-PSFPZXHX.mjs} +2 -2
- package/dist/{chunk-JZ4H7EP6.mjs → chunk-XEWWAHCM.mjs} +24 -6
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +25 -7
- package/dist/handlers/index.mjs +1 -1
- package/dist/{index-CQ0zQ7Zk.d.ts → index-CYgr00ot.d.ts} +1 -1
- package/dist/{index-D0_2f-43.d.mts → index-D-lfcqlL.d.mts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +25 -7
- package/dist/server.mjs +2 -2
- package/package.json +1 -1
- package/src/app/constants.tsx +2 -2
- package/src/config/constants.ts +1 -1
- package/src/core/Pipeline.ts +5 -1
- package/src/llm/providers/AnthropicProvider.ts +4 -0
- package/src/llm/providers/GeminiProvider.ts +6 -1
- package/src/llm/providers/OllamaProvider.ts +6 -1
- package/src/llm/providers/OpenAIProvider.ts +4 -0
- package/src/providers/vectordb/QdrantProvider.ts +9 -9
|
@@ -103,7 +103,7 @@ interface RetrievalResult {
|
|
|
103
103
|
* This file serves as the single source of truth for all statically supported
|
|
104
104
|
* providers and stylistic options in the Retrivora AI RAG Engine.
|
|
105
105
|
*/
|
|
106
|
-
declare const VECTOR_DB_PROVIDERS: readonly ["pinecone", "pgvector", "postgresql", "mongodb", "
|
|
106
|
+
declare const VECTOR_DB_PROVIDERS: readonly ["pinecone", "pgvector", "postgresql", "mongodb", "qdrant", "milvus", "chromadb", "redis", "weaviate", "rest", "universal_rest", "custom"];
|
|
107
107
|
declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "ollama", "gemini", "rest", "universal_rest", "custom"];
|
|
108
108
|
declare const EMBEDDING_PROVIDERS: readonly ["openai", "ollama", "gemini", "rest", "universal_rest", "custom"];
|
|
109
109
|
declare const GRAPH_DB_PROVIDERS: readonly ["neo4j", "memgraph", "simple", "custom"];
|
|
@@ -103,7 +103,7 @@ interface RetrievalResult {
|
|
|
103
103
|
* This file serves as the single source of truth for all statically supported
|
|
104
104
|
* providers and stylistic options in the Retrivora AI RAG Engine.
|
|
105
105
|
*/
|
|
106
|
-
declare const VECTOR_DB_PROVIDERS: readonly ["pinecone", "pgvector", "postgresql", "mongodb", "
|
|
106
|
+
declare const VECTOR_DB_PROVIDERS: readonly ["pinecone", "pgvector", "postgresql", "mongodb", "qdrant", "milvus", "chromadb", "redis", "weaviate", "rest", "universal_rest", "custom"];
|
|
107
107
|
declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "ollama", "gemini", "rest", "universal_rest", "custom"];
|
|
108
108
|
declare const EMBEDDING_PROVIDERS: readonly ["openai", "ollama", "gemini", "rest", "universal_rest", "custom"];
|
|
109
109
|
declare const GRAPH_DB_PROVIDERS: readonly ["neo4j", "memgraph", "simple", "custom"];
|
|
@@ -184,7 +184,7 @@ var QdrantProvider = class extends BaseVectorProvider {
|
|
|
184
184
|
const p = res.payload || {};
|
|
185
185
|
let content = p[this.contentField] || "";
|
|
186
186
|
if (!content) {
|
|
187
|
-
const stringFields = Object.entries(p).filter(([
|
|
187
|
+
const stringFields = Object.entries(p).filter(([, v]) => typeof v === "string").map(([k, v]) => ({ key: k, val: v }));
|
|
188
188
|
if (stringFields.length > 0) {
|
|
189
189
|
const bestMatch = stringFields.sort((a, b) => b.val.length - a.val.length)[0];
|
|
190
190
|
content = bestMatch.val;
|
|
@@ -209,7 +209,7 @@ var QdrantProvider = class extends BaseVectorProvider {
|
|
|
209
209
|
});
|
|
210
210
|
return results;
|
|
211
211
|
}
|
|
212
|
-
async delete(id
|
|
212
|
+
async delete(id) {
|
|
213
213
|
await this.http.post(`/collections/${this.indexName}/points/delete`, {
|
|
214
214
|
points: [this.normalizeId(id)]
|
|
215
215
|
});
|
|
@@ -21,8 +21,8 @@ var VECTOR_DB_PROVIDERS = [
|
|
|
21
21
|
"pgvector",
|
|
22
22
|
"postgresql",
|
|
23
23
|
"mongodb",
|
|
24
|
-
"milvus",
|
|
25
24
|
"qdrant",
|
|
25
|
+
"milvus",
|
|
26
26
|
"chromadb",
|
|
27
27
|
"redis",
|
|
28
28
|
"weaviate",
|
|
@@ -362,6 +362,9 @@ ${context}`
|
|
|
362
362
|
stop: options == null ? void 0 : options.stop,
|
|
363
363
|
stream: true
|
|
364
364
|
}));
|
|
365
|
+
if (!stream) {
|
|
366
|
+
throw new Error("[OpenAIProvider] completions.create stream is undefined");
|
|
367
|
+
}
|
|
365
368
|
try {
|
|
366
369
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
367
370
|
const chunk = temp.value;
|
|
@@ -507,6 +510,9 @@ ${context}`;
|
|
|
507
510
|
messages: anthropicMessages,
|
|
508
511
|
stream: true
|
|
509
512
|
}));
|
|
513
|
+
if (!stream) {
|
|
514
|
+
throw new Error("[AnthropicProvider] messages.create stream is undefined");
|
|
515
|
+
}
|
|
510
516
|
try {
|
|
511
517
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
512
518
|
const chunk = temp.value;
|
|
@@ -646,8 +652,12 @@ var OllamaProvider = class {
|
|
|
646
652
|
]
|
|
647
653
|
}, { responseType: "stream" }));
|
|
648
654
|
let lineBuffer = "";
|
|
655
|
+
const stream = response.data;
|
|
656
|
+
if (!stream) {
|
|
657
|
+
throw new Error("[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.");
|
|
658
|
+
}
|
|
649
659
|
try {
|
|
650
|
-
for (var iter = __forAwait(
|
|
660
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
651
661
|
const chunk = temp.value;
|
|
652
662
|
lineBuffer += chunk.toString();
|
|
653
663
|
const lines = lineBuffer.split("\n");
|
|
@@ -829,7 +839,7 @@ ${context}`;
|
|
|
829
839
|
}
|
|
830
840
|
chatStream(messages, context, options) {
|
|
831
841
|
return __asyncGenerator(this, null, function* () {
|
|
832
|
-
var _a, _b, _c, _d, _e;
|
|
842
|
+
var _a, _b, _c, _d, _e, _f;
|
|
833
843
|
const systemPrompt = (_a = this.llmConfig.systemPrompt) != null ? _a : `You are a helpful assistant. Answer questions based on the provided context.
|
|
834
844
|
|
|
835
845
|
Context:
|
|
@@ -852,8 +862,12 @@ ${context}`;
|
|
|
852
862
|
stopSequences: options == null ? void 0 : options.stop
|
|
853
863
|
}
|
|
854
864
|
}));
|
|
865
|
+
const stream = (_f = result == null ? void 0 : result.stream) != null ? _f : result;
|
|
866
|
+
if (!stream) {
|
|
867
|
+
throw new Error("[GeminiProvider] generateContentStream returned undefined");
|
|
868
|
+
}
|
|
855
869
|
try {
|
|
856
|
-
for (var iter = __forAwait(
|
|
870
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
857
871
|
const chunk = temp.value;
|
|
858
872
|
const text = chunk.text;
|
|
859
873
|
if (text) yield text;
|
|
@@ -1249,7 +1263,7 @@ var ProviderRegistry = class {
|
|
|
1249
1263
|
return MilvusProvider;
|
|
1250
1264
|
}
|
|
1251
1265
|
case "qdrant": {
|
|
1252
|
-
const { QdrantProvider } = await import("./QdrantProvider-
|
|
1266
|
+
const { QdrantProvider } = await import("./QdrantProvider-RLJTNGPY.mjs");
|
|
1253
1267
|
return QdrantProvider;
|
|
1254
1268
|
}
|
|
1255
1269
|
case "chromadb": {
|
|
@@ -2442,8 +2456,12 @@ ${context}`;
|
|
|
2442
2456
|
}
|
|
2443
2457
|
const messages = [...history, { role: "user", content: question }];
|
|
2444
2458
|
if (this.llmProvider.chatStream) {
|
|
2459
|
+
const stream = this.llmProvider.chatStream(messages, context);
|
|
2460
|
+
if (!stream) {
|
|
2461
|
+
throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
|
|
2462
|
+
}
|
|
2445
2463
|
try {
|
|
2446
|
-
for (var iter = __forAwait(
|
|
2464
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2447
2465
|
const chunk = temp.value;
|
|
2448
2466
|
yield chunk;
|
|
2449
2467
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../RagConfig-
|
|
2
|
-
export { 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-
|
|
1
|
+
import '../RagConfig-FyMB_UG6.mjs';
|
|
2
|
+
export { 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-D-lfcqlL.mjs';
|
|
3
3
|
import 'next/server';
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../RagConfig-
|
|
2
|
-
export { 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-
|
|
1
|
+
import '../RagConfig-FyMB_UG6.js';
|
|
2
|
+
export { 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-CYgr00ot.js';
|
|
3
3
|
import 'next/server';
|
package/dist/handlers/index.js
CHANGED
|
@@ -1015,7 +1015,7 @@ var init_QdrantProvider = __esm({
|
|
|
1015
1015
|
const p = res.payload || {};
|
|
1016
1016
|
let content = p[this.contentField] || "";
|
|
1017
1017
|
if (!content) {
|
|
1018
|
-
const stringFields = Object.entries(p).filter(([
|
|
1018
|
+
const stringFields = Object.entries(p).filter(([, v]) => typeof v === "string").map(([k, v]) => ({ key: k, val: v }));
|
|
1019
1019
|
if (stringFields.length > 0) {
|
|
1020
1020
|
const bestMatch = stringFields.sort((a, b) => b.val.length - a.val.length)[0];
|
|
1021
1021
|
content = bestMatch.val;
|
|
@@ -1040,7 +1040,7 @@ var init_QdrantProvider = __esm({
|
|
|
1040
1040
|
});
|
|
1041
1041
|
return results;
|
|
1042
1042
|
}
|
|
1043
|
-
async delete(id
|
|
1043
|
+
async delete(id) {
|
|
1044
1044
|
await this.http.post(`/collections/${this.indexName}/points/delete`, {
|
|
1045
1045
|
points: [this.normalizeId(id)]
|
|
1046
1046
|
});
|
|
@@ -1630,8 +1630,8 @@ var VECTOR_DB_PROVIDERS = [
|
|
|
1630
1630
|
"pgvector",
|
|
1631
1631
|
"postgresql",
|
|
1632
1632
|
"mongodb",
|
|
1633
|
-
"milvus",
|
|
1634
1633
|
"qdrant",
|
|
1634
|
+
"milvus",
|
|
1635
1635
|
"chromadb",
|
|
1636
1636
|
"redis",
|
|
1637
1637
|
"weaviate",
|
|
@@ -1968,6 +1968,9 @@ ${context}`
|
|
|
1968
1968
|
stop: options == null ? void 0 : options.stop,
|
|
1969
1969
|
stream: true
|
|
1970
1970
|
}));
|
|
1971
|
+
if (!stream) {
|
|
1972
|
+
throw new Error("[OpenAIProvider] completions.create stream is undefined");
|
|
1973
|
+
}
|
|
1971
1974
|
try {
|
|
1972
1975
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
1973
1976
|
const chunk = temp.value;
|
|
@@ -2113,6 +2116,9 @@ ${context}`;
|
|
|
2113
2116
|
messages: anthropicMessages,
|
|
2114
2117
|
stream: true
|
|
2115
2118
|
}));
|
|
2119
|
+
if (!stream) {
|
|
2120
|
+
throw new Error("[AnthropicProvider] messages.create stream is undefined");
|
|
2121
|
+
}
|
|
2116
2122
|
try {
|
|
2117
2123
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2118
2124
|
const chunk = temp.value;
|
|
@@ -2252,8 +2258,12 @@ var OllamaProvider = class {
|
|
|
2252
2258
|
]
|
|
2253
2259
|
}, { responseType: "stream" }));
|
|
2254
2260
|
let lineBuffer = "";
|
|
2261
|
+
const stream = response.data;
|
|
2262
|
+
if (!stream) {
|
|
2263
|
+
throw new Error("[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.");
|
|
2264
|
+
}
|
|
2255
2265
|
try {
|
|
2256
|
-
for (var iter = __forAwait(
|
|
2266
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2257
2267
|
const chunk = temp.value;
|
|
2258
2268
|
lineBuffer += chunk.toString();
|
|
2259
2269
|
const lines = lineBuffer.split("\n");
|
|
@@ -2435,7 +2445,7 @@ ${context}`;
|
|
|
2435
2445
|
}
|
|
2436
2446
|
chatStream(messages, context, options) {
|
|
2437
2447
|
return __asyncGenerator(this, null, function* () {
|
|
2438
|
-
var _a, _b, _c, _d, _e;
|
|
2448
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2439
2449
|
const systemPrompt = (_a = this.llmConfig.systemPrompt) != null ? _a : `You are a helpful assistant. Answer questions based on the provided context.
|
|
2440
2450
|
|
|
2441
2451
|
Context:
|
|
@@ -2458,8 +2468,12 @@ ${context}`;
|
|
|
2458
2468
|
stopSequences: options == null ? void 0 : options.stop
|
|
2459
2469
|
}
|
|
2460
2470
|
}));
|
|
2471
|
+
const stream = (_f = result == null ? void 0 : result.stream) != null ? _f : result;
|
|
2472
|
+
if (!stream) {
|
|
2473
|
+
throw new Error("[GeminiProvider] generateContentStream returned undefined");
|
|
2474
|
+
}
|
|
2461
2475
|
try {
|
|
2462
|
-
for (var iter = __forAwait(
|
|
2476
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2463
2477
|
const chunk = temp.value;
|
|
2464
2478
|
const text = chunk.text;
|
|
2465
2479
|
if (text) yield text;
|
|
@@ -4004,8 +4018,12 @@ ${context}`;
|
|
|
4004
4018
|
}
|
|
4005
4019
|
const messages = [...history, { role: "user", content: question }];
|
|
4006
4020
|
if (this.llmProvider.chatStream) {
|
|
4021
|
+
const stream = this.llmProvider.chatStream(messages, context);
|
|
4022
|
+
if (!stream) {
|
|
4023
|
+
throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
|
|
4024
|
+
}
|
|
4007
4025
|
try {
|
|
4008
|
-
for (var iter = __forAwait(
|
|
4026
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
4009
4027
|
const chunk = temp.value;
|
|
4010
4028
|
yield chunk;
|
|
4011
4029
|
}
|
package/dist/handlers/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-
|
|
1
|
+
import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-FyMB_UG6.js';
|
|
2
2
|
import { NextRequest, NextResponse } from 'next/server';
|
|
3
3
|
|
|
4
4
|
interface ValidationError {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-
|
|
1
|
+
import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-FyMB_UG6.mjs';
|
|
2
2
|
import { NextRequest, NextResponse } from 'next/server';
|
|
3
3
|
|
|
4
4
|
interface ValidationError {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
|
-
import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-
|
|
3
|
-
export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, d as EmbeddingProvider, I as ILLMProvider, e as IngestDocument, L as LLMConfig, f as LLMProvider, R as RAGConfig, g as RagConfig, h as UpsertDocument, i as VectorDBConfig, j as VectorDBProvider } from './RagConfig-
|
|
2
|
+
import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-FyMB_UG6.mjs';
|
|
3
|
+
export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, d as EmbeddingProvider, I as ILLMProvider, e as IngestDocument, L as LLMConfig, f as LLMProvider, R as RAGConfig, g as RagConfig, h as UpsertDocument, i as VectorDBConfig, j as VectorDBProvider } from './RagConfig-FyMB_UG6.mjs';
|
|
4
4
|
export { C as Chunk, a as ChunkOptions } from './DocumentChunker-Dh9TvmGG.mjs';
|
|
5
5
|
|
|
6
6
|
interface ChatWidgetProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
|
-
import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-
|
|
3
|
-
export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, d as EmbeddingProvider, I as ILLMProvider, e as IngestDocument, L as LLMConfig, f as LLMProvider, R as RAGConfig, g as RagConfig, h as UpsertDocument, i as VectorDBConfig, j as VectorDBProvider } from './RagConfig-
|
|
2
|
+
import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-FyMB_UG6.js';
|
|
3
|
+
export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, d as EmbeddingProvider, I as ILLMProvider, e as IngestDocument, L as LLMConfig, f as LLMProvider, R as RAGConfig, g as RagConfig, h as UpsertDocument, i as VectorDBConfig, j as VectorDBProvider } from './RagConfig-FyMB_UG6.js';
|
|
4
4
|
export { C as Chunk, a as ChunkOptions } from './DocumentChunker-Dh9TvmGG.js';
|
|
5
5
|
|
|
6
6
|
interface ChatWidgetProps {
|
package/dist/server.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as VectorDBConfig, L as LLMConfig, c as EmbeddingConfig, g as RagConfig, e as IngestDocument, C as ChatMessage, b as ChatResponse, k as RetrievalResult, h as UpsertDocument, V as VectorMatch, G as GraphDBConfig, l as GraphNode, m as Edge, n as GraphSearchResult, I as ILLMProvider, j as VectorDBProvider, f as LLMProvider, d as EmbeddingProvider, R as RAGConfig, U as UIConfig, a as ChatOptions, E as EmbedOptions } from './RagConfig-
|
|
1
|
+
import { i as VectorDBConfig, L as LLMConfig, c as EmbeddingConfig, g as RagConfig, e as IngestDocument, C as ChatMessage, b as ChatResponse, k as RetrievalResult, h as UpsertDocument, V as VectorMatch, G as GraphDBConfig, l as GraphNode, m as Edge, n as GraphSearchResult, I as ILLMProvider, j as VectorDBProvider, f as LLMProvider, d as EmbeddingProvider, R as RAGConfig, U as UIConfig, a as ChatOptions, E as EmbedOptions } from './RagConfig-FyMB_UG6.mjs';
|
|
2
2
|
export { C as Chunk, a as ChunkOptions, D as DocumentChunker } from './DocumentChunker-Dh9TvmGG.mjs';
|
|
3
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
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-
|
|
3
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-D-lfcqlL.mjs';
|
|
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-D-lfcqlL.mjs';
|
|
5
5
|
import 'next/server';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -756,7 +756,7 @@ declare class QdrantProvider extends BaseVectorProvider {
|
|
|
756
756
|
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
757
757
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
758
758
|
query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
759
|
-
delete(id: string | number
|
|
759
|
+
delete(id: string | number): Promise<void>;
|
|
760
760
|
deleteNamespace(_namespace: string): Promise<void>;
|
|
761
761
|
ping(): Promise<boolean>;
|
|
762
762
|
private normalizeId;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as VectorDBConfig, L as LLMConfig, c as EmbeddingConfig, g as RagConfig, e as IngestDocument, C as ChatMessage, b as ChatResponse, k as RetrievalResult, h as UpsertDocument, V as VectorMatch, G as GraphDBConfig, l as GraphNode, m as Edge, n as GraphSearchResult, I as ILLMProvider, j as VectorDBProvider, f as LLMProvider, d as EmbeddingProvider, R as RAGConfig, U as UIConfig, a as ChatOptions, E as EmbedOptions } from './RagConfig-
|
|
1
|
+
import { i as VectorDBConfig, L as LLMConfig, c as EmbeddingConfig, g as RagConfig, e as IngestDocument, C as ChatMessage, b as ChatResponse, k as RetrievalResult, h as UpsertDocument, V as VectorMatch, G as GraphDBConfig, l as GraphNode, m as Edge, n as GraphSearchResult, I as ILLMProvider, j as VectorDBProvider, f as LLMProvider, d as EmbeddingProvider, R as RAGConfig, U as UIConfig, a as ChatOptions, E as EmbedOptions } from './RagConfig-FyMB_UG6.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-
|
|
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-
|
|
3
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-CYgr00ot.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-CYgr00ot.js';
|
|
5
5
|
import 'next/server';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -756,7 +756,7 @@ declare class QdrantProvider extends BaseVectorProvider {
|
|
|
756
756
|
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
757
757
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
758
758
|
query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
759
|
-
delete(id: string | number
|
|
759
|
+
delete(id: string | number): Promise<void>;
|
|
760
760
|
deleteNamespace(_namespace: string): Promise<void>;
|
|
761
761
|
ping(): Promise<boolean>;
|
|
762
762
|
private normalizeId;
|
package/dist/server.js
CHANGED
|
@@ -1027,7 +1027,7 @@ var init_QdrantProvider = __esm({
|
|
|
1027
1027
|
const p = res.payload || {};
|
|
1028
1028
|
let content = p[this.contentField] || "";
|
|
1029
1029
|
if (!content) {
|
|
1030
|
-
const stringFields = Object.entries(p).filter(([
|
|
1030
|
+
const stringFields = Object.entries(p).filter(([, v]) => typeof v === "string").map(([k, v]) => ({ key: k, val: v }));
|
|
1031
1031
|
if (stringFields.length > 0) {
|
|
1032
1032
|
const bestMatch = stringFields.sort((a, b) => b.val.length - a.val.length)[0];
|
|
1033
1033
|
content = bestMatch.val;
|
|
@@ -1052,7 +1052,7 @@ var init_QdrantProvider = __esm({
|
|
|
1052
1052
|
});
|
|
1053
1053
|
return results;
|
|
1054
1054
|
}
|
|
1055
|
-
async delete(id
|
|
1055
|
+
async delete(id) {
|
|
1056
1056
|
await this.http.post(`/collections/${this.indexName}/points/delete`, {
|
|
1057
1057
|
points: [this.normalizeId(id)]
|
|
1058
1058
|
});
|
|
@@ -1675,8 +1675,8 @@ var VECTOR_DB_PROVIDERS = [
|
|
|
1675
1675
|
"pgvector",
|
|
1676
1676
|
"postgresql",
|
|
1677
1677
|
"mongodb",
|
|
1678
|
-
"milvus",
|
|
1679
1678
|
"qdrant",
|
|
1679
|
+
"milvus",
|
|
1680
1680
|
"chromadb",
|
|
1681
1681
|
"redis",
|
|
1682
1682
|
"weaviate",
|
|
@@ -2016,6 +2016,9 @@ ${context}`
|
|
|
2016
2016
|
stop: options == null ? void 0 : options.stop,
|
|
2017
2017
|
stream: true
|
|
2018
2018
|
}));
|
|
2019
|
+
if (!stream) {
|
|
2020
|
+
throw new Error("[OpenAIProvider] completions.create stream is undefined");
|
|
2021
|
+
}
|
|
2019
2022
|
try {
|
|
2020
2023
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2021
2024
|
const chunk = temp.value;
|
|
@@ -2161,6 +2164,9 @@ ${context}`;
|
|
|
2161
2164
|
messages: anthropicMessages,
|
|
2162
2165
|
stream: true
|
|
2163
2166
|
}));
|
|
2167
|
+
if (!stream) {
|
|
2168
|
+
throw new Error("[AnthropicProvider] messages.create stream is undefined");
|
|
2169
|
+
}
|
|
2164
2170
|
try {
|
|
2165
2171
|
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2166
2172
|
const chunk = temp.value;
|
|
@@ -2300,8 +2306,12 @@ var OllamaProvider = class {
|
|
|
2300
2306
|
]
|
|
2301
2307
|
}, { responseType: "stream" }));
|
|
2302
2308
|
let lineBuffer = "";
|
|
2309
|
+
const stream = response.data;
|
|
2310
|
+
if (!stream) {
|
|
2311
|
+
throw new Error("[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.");
|
|
2312
|
+
}
|
|
2303
2313
|
try {
|
|
2304
|
-
for (var iter = __forAwait(
|
|
2314
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2305
2315
|
const chunk = temp.value;
|
|
2306
2316
|
lineBuffer += chunk.toString();
|
|
2307
2317
|
const lines = lineBuffer.split("\n");
|
|
@@ -2483,7 +2493,7 @@ ${context}`;
|
|
|
2483
2493
|
}
|
|
2484
2494
|
chatStream(messages, context, options) {
|
|
2485
2495
|
return __asyncGenerator(this, null, function* () {
|
|
2486
|
-
var _a, _b, _c, _d, _e;
|
|
2496
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2487
2497
|
const systemPrompt = (_a = this.llmConfig.systemPrompt) != null ? _a : `You are a helpful assistant. Answer questions based on the provided context.
|
|
2488
2498
|
|
|
2489
2499
|
Context:
|
|
@@ -2506,8 +2516,12 @@ ${context}`;
|
|
|
2506
2516
|
stopSequences: options == null ? void 0 : options.stop
|
|
2507
2517
|
}
|
|
2508
2518
|
}));
|
|
2519
|
+
const stream = (_f = result == null ? void 0 : result.stream) != null ? _f : result;
|
|
2520
|
+
if (!stream) {
|
|
2521
|
+
throw new Error("[GeminiProvider] generateContentStream returned undefined");
|
|
2522
|
+
}
|
|
2509
2523
|
try {
|
|
2510
|
-
for (var iter = __forAwait(
|
|
2524
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
2511
2525
|
const chunk = temp.value;
|
|
2512
2526
|
const text = chunk.text;
|
|
2513
2527
|
if (text) yield text;
|
|
@@ -4097,8 +4111,12 @@ ${context}`;
|
|
|
4097
4111
|
}
|
|
4098
4112
|
const messages = [...history, { role: "user", content: question }];
|
|
4099
4113
|
if (this.llmProvider.chatStream) {
|
|
4114
|
+
const stream = this.llmProvider.chatStream(messages, context);
|
|
4115
|
+
if (!stream) {
|
|
4116
|
+
throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
|
|
4117
|
+
}
|
|
4100
4118
|
try {
|
|
4101
|
-
for (var iter = __forAwait(
|
|
4119
|
+
for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
4102
4120
|
const chunk = temp.value;
|
|
4103
4121
|
yield chunk;
|
|
4104
4122
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
sseFrame,
|
|
41
41
|
sseMetaFrame,
|
|
42
42
|
sseTextFrame
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-XEWWAHCM.mjs";
|
|
44
44
|
import "./chunk-YLTMFW4M.mjs";
|
|
45
45
|
import {
|
|
46
46
|
PineconeProvider
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
} from "./chunk-U55XRW3U.mjs";
|
|
57
57
|
import {
|
|
58
58
|
QdrantProvider
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-PSFPZXHX.mjs";
|
|
60
60
|
import {
|
|
61
61
|
BaseVectorProvider
|
|
62
62
|
} from "./chunk-IMP6FUCY.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
|
|
5
5
|
"author": "Abhinav Alkuchi",
|
|
6
6
|
"license": "MIT",
|
package/src/app/constants.tsx
CHANGED
|
@@ -39,18 +39,18 @@ export const VECTOR_DATABASES: ProviderPill[] = [
|
|
|
39
39
|
{ Icon: Zap, label: 'Pinecone' },
|
|
40
40
|
{ Icon: Database, label: 'PostgreSQL' },
|
|
41
41
|
{ Icon: Layers, label: 'MongoDB' },
|
|
42
|
-
{ Icon: Search, label: 'Milvus' },
|
|
43
42
|
{ Icon: Box, label: 'Qdrant' },
|
|
43
|
+
{ Icon: Search, label: 'Milvus' },
|
|
44
44
|
{ Icon: Package, label: 'ChromaDB' },
|
|
45
45
|
{ Icon: Activity, label: 'Redis' },
|
|
46
46
|
{ Icon: Hexagon, label: 'Weaviate' },
|
|
47
47
|
];
|
|
48
48
|
|
|
49
49
|
export const AI_MODELS: ProviderPill[] = [
|
|
50
|
+
{ Icon: Rabbit, label: 'Ollama' },
|
|
50
51
|
{ Icon: Sparkles, label: 'OpenAI' },
|
|
51
52
|
{ Icon: Bot, label: 'Anthropic' },
|
|
52
53
|
{ Icon: Brain, label: 'Gemini' },
|
|
53
|
-
{ Icon: Rabbit, label: 'Ollama' },
|
|
54
54
|
{ Icon: Code, label: 'Copilot' },
|
|
55
55
|
{ Icon: Terminal, label: 'LiteLLM' },
|
|
56
56
|
];
|
package/src/config/constants.ts
CHANGED
package/src/core/Pipeline.ts
CHANGED
|
@@ -350,7 +350,11 @@ export class Pipeline {
|
|
|
350
350
|
const messages: ChatMessage[] = [...history, { role: 'user', content: question }];
|
|
351
351
|
|
|
352
352
|
if (this.llmProvider.chatStream) {
|
|
353
|
-
|
|
353
|
+
const stream = this.llmProvider.chatStream(messages, context);
|
|
354
|
+
if (!stream) {
|
|
355
|
+
throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
|
|
356
|
+
}
|
|
357
|
+
for await (const chunk of stream) {
|
|
354
358
|
yield chunk;
|
|
355
359
|
}
|
|
356
360
|
} else {
|
|
@@ -120,6 +120,10 @@ export class AnthropicProvider implements ILLMProvider {
|
|
|
120
120
|
stream: true,
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
+
if (!stream) {
|
|
124
|
+
throw new Error('[AnthropicProvider] messages.create stream is undefined');
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
for await (const chunk of stream) {
|
|
124
128
|
if (chunk.type === 'content_block_delta' && chunk.delta.type === 'text_delta') {
|
|
125
129
|
yield chunk.delta.text;
|
|
@@ -155,7 +155,12 @@ export class GeminiProvider implements ILLMProvider {
|
|
|
155
155
|
},
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
const stream = ((result as unknown as Record<string, unknown>)?.stream ?? result) as AsyncIterable<{ text?: string }>;
|
|
159
|
+
if (!stream) {
|
|
160
|
+
throw new Error('[GeminiProvider] generateContentStream returned undefined');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
for await (const chunk of stream) {
|
|
159
164
|
const text = chunk.text;
|
|
160
165
|
if (text) yield text;
|
|
161
166
|
}
|
|
@@ -119,7 +119,12 @@ export class OllamaProvider implements ILLMProvider {
|
|
|
119
119
|
}, { responseType: 'stream' });
|
|
120
120
|
|
|
121
121
|
let lineBuffer = '';
|
|
122
|
-
|
|
122
|
+
const stream = response.data;
|
|
123
|
+
if (!stream) {
|
|
124
|
+
throw new Error('[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
for await (const chunk of stream) {
|
|
123
128
|
lineBuffer += chunk.toString();
|
|
124
129
|
const lines = lineBuffer.split('\n');
|
|
125
130
|
|
|
@@ -138,6 +138,10 @@ export class OpenAIProvider implements ILLMProvider {
|
|
|
138
138
|
stream: true,
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
+
if (!stream) {
|
|
142
|
+
throw new Error('[OpenAIProvider] completions.create stream is undefined');
|
|
143
|
+
}
|
|
144
|
+
|
|
141
145
|
for await (const chunk of stream) {
|
|
142
146
|
const content = chunk.choices[0]?.delta?.content || '';
|
|
143
147
|
if (content) yield content;
|
|
@@ -57,7 +57,7 @@ export class QdrantProvider extends BaseVectorProvider {
|
|
|
57
57
|
await Promise.all(
|
|
58
58
|
allFields.map(async (fieldInfo) => {
|
|
59
59
|
const [fieldName, schemaType] = fieldInfo.split(':');
|
|
60
|
-
return this.ensureIndex(fieldName, (schemaType as
|
|
60
|
+
return this.ensureIndex(fieldName, (schemaType as string) || 'keyword');
|
|
61
61
|
})
|
|
62
62
|
);
|
|
63
63
|
} else {
|
|
@@ -164,7 +164,7 @@ export class QdrantProvider extends BaseVectorProvider {
|
|
|
164
164
|
async batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void> {
|
|
165
165
|
const payload = {
|
|
166
166
|
points: docs.map(doc => {
|
|
167
|
-
const pointPayload: Record<string,
|
|
167
|
+
const pointPayload: Record<string, unknown> = {
|
|
168
168
|
[this.contentField]: doc.content,
|
|
169
169
|
...(namespace ? { namespace } : {}),
|
|
170
170
|
};
|
|
@@ -186,7 +186,7 @@ export class QdrantProvider extends BaseVectorProvider {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
async query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]> {
|
|
189
|
-
const must:
|
|
189
|
+
const must: Record<string, unknown>[] = [];
|
|
190
190
|
|
|
191
191
|
if (namespace) {
|
|
192
192
|
must.push({ key: 'namespace', match: { value: namespace } });
|
|
@@ -219,13 +219,13 @@ export class QdrantProvider extends BaseVectorProvider {
|
|
|
219
219
|
|
|
220
220
|
const { data } = await this.http.post(`/collections/${this.indexName}/points/search`, payload);
|
|
221
221
|
|
|
222
|
-
const results = (data.result || []).map((res: Record<string,
|
|
223
|
-
const p = res.payload || {};
|
|
222
|
+
const results = (data.result || []).map((res: Record<string, unknown>) => {
|
|
223
|
+
const p = (res.payload as Record<string, unknown>) || {};
|
|
224
224
|
let content = p[this.contentField] || '';
|
|
225
225
|
|
|
226
226
|
if (!content) {
|
|
227
227
|
const stringFields = Object.entries(p)
|
|
228
|
-
.filter(([
|
|
228
|
+
.filter(([, v]) => typeof v === 'string')
|
|
229
229
|
.map(([k, v]) => ({ key: k, val: v as string }));
|
|
230
230
|
|
|
231
231
|
if (stringFields.length > 0) {
|
|
@@ -236,13 +236,13 @@ export class QdrantProvider extends BaseVectorProvider {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
let metadata: Record<string,
|
|
239
|
+
let metadata: Record<string, unknown> = {};
|
|
240
240
|
if (this.isFlatPayload) {
|
|
241
241
|
metadata = { ...p };
|
|
242
242
|
delete metadata[this.contentField];
|
|
243
243
|
delete metadata['namespace'];
|
|
244
244
|
} else {
|
|
245
|
-
metadata = p[this.metadataField] || p;
|
|
245
|
+
metadata = (p[this.metadataField] as Record<string, unknown>) || p;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
return {
|
|
@@ -256,7 +256,7 @@ export class QdrantProvider extends BaseVectorProvider {
|
|
|
256
256
|
return results;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
async delete(id: string | number
|
|
259
|
+
async delete(id: string | number): Promise<void> {
|
|
260
260
|
await this.http.post(`/collections/${this.indexName}/points/delete`, {
|
|
261
261
|
points: [this.normalizeId(id)],
|
|
262
262
|
});
|