@retrivora-ai/rag-engine 1.0.0 → 1.0.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.
- package/dist/{ChromaDBProvider-APQVJ5F7.mjs → ChromaDBProvider-MIDOR4FW.mjs} +2 -2
- package/dist/{MilvusProvider-35US67MS.mjs → MilvusProvider-U7SKC27V.mjs} +2 -2
- package/dist/{MongoDBProvider-COVYZDP6.mjs → MongoDBProvider-Z6ALOVDN.mjs} +2 -2
- package/dist/{PineconeProvider-AWFJQDZL.mjs → PineconeProvider-QZNRKTN2.mjs} +2 -2
- package/dist/{PostgreSQLProvider-IEYRJ7XJ.mjs → PostgreSQLProvider-BMOETDZA.mjs} +1 -1
- package/dist/{QdrantProvider-M6TQYZRO.mjs → QdrantProvider-YNUNEOZH.mjs} +2 -2
- package/dist/{RedisProvider-3G5PBLZ4.mjs → RedisProvider-SR65SCKV.mjs} +2 -2
- package/dist/{SimpleGraphProvider-UK7DJW37.mjs → SimpleGraphProvider-SLOXO4M7.mjs} +1 -1
- package/dist/{UniversalVectorProvider-FYQ3B2PW.mjs → UniversalVectorProvider-IN67OS56.mjs} +3 -3
- package/dist/{WeaviateProvider-ITHO36IL.mjs → WeaviateProvider-5FWDFITI.mjs} +2 -2
- package/dist/{chunk-4A47RCG2.mjs → chunk-3DSHW676.mjs} +1 -1
- package/dist/{chunk-P4HAQ7KB.mjs → chunk-5W2YWFT3.mjs} +75 -13
- package/dist/{chunk-NXUCKY5L.mjs → chunk-5YGUXK7Z.mjs} +1 -1
- package/dist/{chunk-7SOSCZGS.mjs → chunk-CD6TSNL4.mjs} +1 -1
- package/dist/{chunk-WGSZNY3X.mjs → chunk-CFVEZTBJ.mjs} +1 -1
- package/dist/{chunk-U6KHVZLF.mjs → chunk-LR3VMDVK.mjs} +2 -2
- package/dist/{chunk-OOQXNLXD.mjs → chunk-M6JSPGAR.mjs} +1 -1
- package/dist/{chunk-TYHTZIDP.mjs → chunk-U55XRW3U.mjs} +1 -1
- package/dist/{chunk-ZNBKHNJ4.mjs → chunk-VUQJVIJT.mjs} +1 -1
- package/dist/{chunk-QMIKLALV.mjs → chunk-X4TOT24V.mjs} +32 -0
- package/dist/{chunk-67AJ6SMD.mjs → chunk-YLTMFW4M.mjs} +1 -1
- package/dist/handlers/index.d.mts +1 -1
- package/dist/handlers/index.d.ts +1 -1
- package/dist/handlers/index.js +93 -0
- package/dist/handlers/index.mjs +5 -3
- package/dist/{index-CrGMwXfO.d.ts → index-B2mutkgp.d.ts} +5 -1
- package/dist/{index-v669iV-k.d.mts → index-Bjy0es5a.d.mts} +5 -1
- package/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +253 -363
- package/dist/index.mjs +243 -353
- package/dist/server.d.mts +6 -2
- package/dist/server.d.ts +6 -2
- package/dist/server.js +42 -0
- package/dist/server.mjs +11 -11
- package/package.json +1 -1
- package/src/core/VectorPlugin.ts +7 -0
- package/src/handlers/index.ts +45 -0
- package/src/rag/EntityExtractor.ts +3 -0
package/dist/server.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { e as VectorDBConfig, L as LLMConfig, E as EmbeddingConfig, c as RagConf
|
|
|
2
2
|
export { R as RAGConfig, U as UIConfig } from './RagConfig-DRJO4hGU.mjs';
|
|
3
3
|
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-C-sCZPhi.mjs';
|
|
4
4
|
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-C-sCZPhi.mjs';
|
|
5
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
6
|
-
export { C as ConfigValidator, V as ValidationError, c as createChatHandler, b as createHealthHandler, d as createIngestHandler, e as createUploadHandler } from './index-
|
|
5
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-Bjy0es5a.mjs';
|
|
6
|
+
export { C as ConfigValidator, V as ValidationError, c as createChatHandler, b as createHealthHandler, d as createIngestHandler, e as createUploadHandler } from './index-Bjy0es5a.mjs';
|
|
7
7
|
import 'next/server';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -152,6 +152,10 @@ declare class VectorPlugin {
|
|
|
152
152
|
* Run a chat query.
|
|
153
153
|
*/
|
|
154
154
|
chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Run a streaming chat query.
|
|
157
|
+
*/
|
|
158
|
+
chatStream(message: string, history?: ChatMessage[], namespace?: string): AsyncGenerator<string | ChatResponse, void, any>;
|
|
155
159
|
/**
|
|
156
160
|
* Ingest documents into the vector database.
|
|
157
161
|
*/
|
package/dist/server.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { e as VectorDBConfig, L as LLMConfig, E as EmbeddingConfig, c as RagConf
|
|
|
2
2
|
export { R as RAGConfig, U as UIConfig } from './RagConfig-DRJO4hGU.js';
|
|
3
3
|
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-C-sCZPhi.js';
|
|
4
4
|
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-C-sCZPhi.js';
|
|
5
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-
|
|
6
|
-
export { C as ConfigValidator, V as ValidationError, c as createChatHandler, b as createHealthHandler, d as createIngestHandler, e as createUploadHandler } from './index-
|
|
5
|
+
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-B2mutkgp.js';
|
|
6
|
+
export { C as ConfigValidator, V as ValidationError, c as createChatHandler, b as createHealthHandler, d as createIngestHandler, e as createUploadHandler } from './index-B2mutkgp.js';
|
|
7
7
|
import 'next/server';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -152,6 +152,10 @@ declare class VectorPlugin {
|
|
|
152
152
|
* Run a chat query.
|
|
153
153
|
*/
|
|
154
154
|
chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Run a streaming chat query.
|
|
157
|
+
*/
|
|
158
|
+
chatStream(message: string, history?: ChatMessage[], namespace?: string): AsyncGenerator<string | ChatResponse, void, any>;
|
|
155
159
|
/**
|
|
156
160
|
* Ingest documents into the vector database.
|
|
157
161
|
*/
|
package/dist/server.js
CHANGED
|
@@ -10,6 +10,9 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
10
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
12
|
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
13
|
+
var __typeError = (msg) => {
|
|
14
|
+
throw TypeError(msg);
|
|
15
|
+
};
|
|
13
16
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
17
|
var __spreadValues = (a, b) => {
|
|
15
18
|
for (var prop in b || (b = {}))
|
|
@@ -74,6 +77,34 @@ var __asyncGenerator = (__this, __arguments, generator) => {
|
|
|
74
77
|
}, method = (k, call, wait, clear) => it[k] = (x) => (call = new Promise((yes, no, run) => (run = () => resume(k, x, yes, no), q ? q.then(run) : run())), clear = () => q === wait && (q = 0), q = wait = call.then(clear, clear), call), q, it = {};
|
|
75
78
|
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
|
|
76
79
|
};
|
|
80
|
+
var __yieldStar = (value) => {
|
|
81
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
82
|
+
if (obj == null) {
|
|
83
|
+
obj = value[__knownSymbol("iterator")]();
|
|
84
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
85
|
+
} else {
|
|
86
|
+
obj = obj.call(value);
|
|
87
|
+
method = (k) => it[k] = (v) => {
|
|
88
|
+
if (isAwait) {
|
|
89
|
+
isAwait = false;
|
|
90
|
+
if (k === "throw") throw v;
|
|
91
|
+
return v;
|
|
92
|
+
}
|
|
93
|
+
isAwait = true;
|
|
94
|
+
return {
|
|
95
|
+
done: false,
|
|
96
|
+
value: new __await(new Promise((resolve) => {
|
|
97
|
+
var x = obj[k](v);
|
|
98
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
99
|
+
resolve(x);
|
|
100
|
+
}), 1)
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
105
|
+
throw x;
|
|
106
|
+
}, "return" in obj && method("return"), it;
|
|
107
|
+
};
|
|
77
108
|
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
|
|
78
109
|
|
|
79
110
|
// src/utils/templateUtils.ts
|
|
@@ -2908,6 +2939,9 @@ Extract entities and relationships from the following text.
|
|
|
2908
2939
|
Format the output as JSON with two keys: "nodes" (array of {id, label, properties}) and "edges" (array of {source, target, type, properties}).
|
|
2909
2940
|
Use the same ID for the same entity.
|
|
2910
2941
|
|
|
2942
|
+
IMPORTANT: Ensure all property values are valid JSON types (strings, numbers, booleans, or null).
|
|
2943
|
+
DO NOT include mathematical expressions like "4.5/5" as numbers; use strings instead.
|
|
2944
|
+
|
|
2911
2945
|
Text:
|
|
2912
2946
|
"${text}"
|
|
2913
2947
|
|
|
@@ -3922,6 +3956,14 @@ var VectorPlugin = class {
|
|
|
3922
3956
|
async chat(message, history = [], namespace) {
|
|
3923
3957
|
return this.pipeline.ask(message, history, namespace);
|
|
3924
3958
|
}
|
|
3959
|
+
/**
|
|
3960
|
+
* Run a streaming chat query.
|
|
3961
|
+
*/
|
|
3962
|
+
chatStream(_0) {
|
|
3963
|
+
return __asyncGenerator(this, arguments, function* (message, history = [], namespace) {
|
|
3964
|
+
yield* __yieldStar(this.pipeline.askStream(message, history, namespace));
|
|
3965
|
+
});
|
|
3966
|
+
}
|
|
3925
3967
|
/**
|
|
3926
3968
|
* Ingest documents into the vector database.
|
|
3927
3969
|
*/
|
package/dist/server.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChromaDBProvider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CFVEZTBJ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
RedisProvider
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5YGUXK7Z.mjs";
|
|
7
7
|
import {
|
|
8
8
|
WeaviateProvider
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-M6JSPGAR.mjs";
|
|
10
10
|
import {
|
|
11
11
|
UniversalVectorProvider
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LR3VMDVK.mjs";
|
|
13
13
|
import {
|
|
14
14
|
AnthropicProvider,
|
|
15
15
|
BatchProcessor,
|
|
@@ -34,23 +34,23 @@ import {
|
|
|
34
34
|
createIngestHandler,
|
|
35
35
|
createUploadHandler,
|
|
36
36
|
getRagConfig
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
37
|
+
} from "./chunk-5W2YWFT3.mjs";
|
|
38
|
+
import "./chunk-YLTMFW4M.mjs";
|
|
39
39
|
import {
|
|
40
40
|
PineconeProvider
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-VUQJVIJT.mjs";
|
|
42
42
|
import {
|
|
43
43
|
PostgreSQLProvider
|
|
44
44
|
} from "./chunk-FLOSGE6A.mjs";
|
|
45
45
|
import {
|
|
46
46
|
MongoDBProvider
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-CD6TSNL4.mjs";
|
|
48
48
|
import {
|
|
49
49
|
MilvusProvider
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-U55XRW3U.mjs";
|
|
51
51
|
import {
|
|
52
52
|
QdrantProvider
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-3DSHW676.mjs";
|
|
54
54
|
import {
|
|
55
55
|
BaseVectorProvider
|
|
56
56
|
} from "./chunk-IMP6FUCY.mjs";
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
__objRest,
|
|
59
59
|
__spreadProps,
|
|
60
60
|
__spreadValues
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-X4TOT24V.mjs";
|
|
62
62
|
|
|
63
63
|
// src/config/ConfigBuilder.ts
|
|
64
64
|
var ConfigBuilder = class {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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/core/VectorPlugin.ts
CHANGED
|
@@ -83,6 +83,13 @@ export class VectorPlugin {
|
|
|
83
83
|
return this.pipeline.ask(message, history, namespace);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Run a streaming chat query.
|
|
88
|
+
*/
|
|
89
|
+
async *chatStream(message: string, history: ChatMessage[] = [], namespace?: string) {
|
|
90
|
+
yield* this.pipeline.askStream(message, history, namespace);
|
|
91
|
+
}
|
|
92
|
+
|
|
86
93
|
/**
|
|
87
94
|
* Ingest documents into the vector database.
|
|
88
95
|
*/
|
package/src/handlers/index.ts
CHANGED
|
@@ -32,6 +32,51 @@ export function createChatHandler(config?: Partial<RagConfig>) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* createStreamHandler — factory that returns a streaming Next.js App Router POST handler
|
|
37
|
+
*/
|
|
38
|
+
export function createStreamHandler(config?: Partial<RagConfig>) {
|
|
39
|
+
const plugin = new VectorPlugin(config);
|
|
40
|
+
|
|
41
|
+
return async function POST(req: NextRequest) {
|
|
42
|
+
try {
|
|
43
|
+
const { message, history = [], namespace } = await req.json();
|
|
44
|
+
|
|
45
|
+
const encoder = new TextEncoder();
|
|
46
|
+
const stream = new ReadableStream({
|
|
47
|
+
async start(controller) {
|
|
48
|
+
const pipelineStream = plugin.chatStream(message, history, namespace);
|
|
49
|
+
|
|
50
|
+
for await (const chunk of pipelineStream) {
|
|
51
|
+
if (typeof chunk === 'string') {
|
|
52
|
+
controller.enqueue(encoder.encode(chunk));
|
|
53
|
+
} else {
|
|
54
|
+
// Yield metadata/sources at the end
|
|
55
|
+
controller.enqueue(encoder.encode(`\n\n__METADATA__${JSON.stringify(chunk)}`));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
controller.close();
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return new Response(stream, {
|
|
63
|
+
headers: {
|
|
64
|
+
'Content-Type': 'text/event-stream',
|
|
65
|
+
'Cache-Control': 'no-cache',
|
|
66
|
+
'Connection': 'keep-alive',
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
const message = err instanceof Error ? err.message : 'Internal server error';
|
|
71
|
+
return new Response(JSON.stringify({ error: message }), {
|
|
72
|
+
status: 500,
|
|
73
|
+
headers: { 'Content-Type': 'application/json' },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
35
80
|
/**
|
|
36
81
|
* createIngestHandler — factory for the document ingestion endpoint.
|
|
37
82
|
*/
|
|
@@ -20,6 +20,9 @@ Extract entities and relationships from the following text.
|
|
|
20
20
|
Format the output as JSON with two keys: "nodes" (array of {id, label, properties}) and "edges" (array of {source, target, type, properties}).
|
|
21
21
|
Use the same ID for the same entity.
|
|
22
22
|
|
|
23
|
+
IMPORTANT: Ensure all property values are valid JSON types (strings, numbers, booleans, or null).
|
|
24
|
+
DO NOT include mathematical expressions like "4.5/5" as numbers; use strings instead.
|
|
25
|
+
|
|
23
26
|
Text:
|
|
24
27
|
"${text}"
|
|
25
28
|
|