@retrivora-ai/rag-engine 1.1.1 → 1.1.3

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  QdrantProvider
3
- } from "./chunk-63HITIWC.mjs";
3
+ } from "./chunk-PSFPZXHX.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
5
  import "./chunk-X4TOT24V.mjs";
6
6
  export {
@@ -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", "milvus", "qdrant", "chromadb", "redis", "weaviate", "rest", "universal_rest", "custom"];
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", "milvus", "qdrant", "chromadb", "redis", "weaviate", "rest", "universal_rest", "custom"];
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"];
@@ -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",
@@ -79,44 +79,47 @@ function readEnum(env, name, fallback, allowed) {
79
79
  }
80
80
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
81
81
  }
82
- function getRagConfig(env = process.env) {
83
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q;
84
- const projectId = (_b = (_a = readString(env, "RAG_PROJECT_ID")) != null ? _a : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : "__default__";
82
+ function getRagConfig(baseConfig, env = process.env) {
83
+ return getEnvConfig(env, baseConfig);
84
+ }
85
+ function getEnvConfig(env = process.env, base) {
86
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa;
87
+ const projectId = (_c = (_b = (_a = readString(env, "RAG_PROJECT_ID")) != null ? _a : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : base == null ? void 0 : base.projectId) != null ? _c : "__default__";
85
88
  const vectorProvider = readEnum(env, "VECTOR_DB_PROVIDER", "pinecone", VECTOR_DB_PROVIDERS);
86
89
  const llmProvider = readEnum(env, "LLM_PROVIDER", "openai", LLM_PROVIDERS);
87
90
  const embeddingProvider = readEnum(env, "EMBEDDING_PROVIDER", "openai", EMBEDDING_PROVIDERS);
88
91
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 1536);
89
92
  const vectorDbOptions = {};
90
93
  if (vectorProvider === "pinecone") {
91
- vectorDbOptions.apiKey = (_c = readString(env, "PINECONE_API_KEY")) != null ? _c : "";
94
+ vectorDbOptions.apiKey = (_g = (_f = readString(env, "PINECONE_API_KEY")) != null ? _f : (_e = (_d = base == null ? void 0 : base.vectorDb) == null ? void 0 : _d.options) == null ? void 0 : _e.apiKey) != null ? _g : "";
92
95
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
93
- vectorDbOptions.connectionString = (_d = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _d : "";
96
+ vectorDbOptions.connectionString = (_k = (_j = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _j : (_i = (_h = base == null ? void 0 : base.vectorDb) == null ? void 0 : _h.options) == null ? void 0 : _i.connectionString) != null ? _k : "";
94
97
  vectorDbOptions.dimensions = embeddingDimensions;
95
98
  } else if (vectorProvider === "mongodb") {
96
- vectorDbOptions.uri = (_e = readString(env, "MONGODB_URI")) != null ? _e : "";
97
- vectorDbOptions.database = (_f = readString(env, "MONGODB_DB")) != null ? _f : "";
98
- vectorDbOptions.collection = (_g = readString(env, "MONGODB_COLLECTION")) != null ? _g : "";
99
- vectorDbOptions.indexName = (_h = readString(env, "MONGODB_INDEX_NAME")) != null ? _h : "vector_index";
99
+ vectorDbOptions.uri = (_o = (_n = readString(env, "MONGODB_URI")) != null ? _n : (_m = (_l = base == null ? void 0 : base.vectorDb) == null ? void 0 : _l.options) == null ? void 0 : _m.uri) != null ? _o : "";
100
+ vectorDbOptions.database = (_s = (_r = readString(env, "MONGODB_DB")) != null ? _r : (_q = (_p = base == null ? void 0 : base.vectorDb) == null ? void 0 : _p.options) == null ? void 0 : _q.database) != null ? _s : "";
101
+ vectorDbOptions.collection = (_w = (_v = readString(env, "MONGODB_COLLECTION")) != null ? _v : (_u = (_t = base == null ? void 0 : base.vectorDb) == null ? void 0 : _t.options) == null ? void 0 : _u.collection) != null ? _w : "";
102
+ vectorDbOptions.indexName = (_C = (_B = (_y = readString(env, "MONGODB_INDEX_NAME")) != null ? _y : (_x = base == null ? void 0 : base.vectorDb) == null ? void 0 : _x.indexName) != null ? _B : (_A = (_z = base == null ? void 0 : base.vectorDb) == null ? void 0 : _z.options) == null ? void 0 : _A.indexName) != null ? _C : "vector_index";
100
103
  } else if (vectorProvider === "qdrant") {
101
- vectorDbOptions.baseUrl = (_i = readString(env, "QDRANT_URL")) != null ? _i : "http://localhost:6333";
102
- vectorDbOptions.apiKey = readString(env, "QDRANT_API_KEY");
104
+ vectorDbOptions.baseUrl = (_G = (_F = readString(env, "QDRANT_URL")) != null ? _F : (_E = (_D = base == null ? void 0 : base.vectorDb) == null ? void 0 : _D.options) == null ? void 0 : _E.baseUrl) != null ? _G : "http://localhost:6333";
105
+ vectorDbOptions.apiKey = (_J = readString(env, "QDRANT_API_KEY")) != null ? _J : (_I = (_H = base == null ? void 0 : base.vectorDb) == null ? void 0 : _H.options) == null ? void 0 : _I.apiKey;
103
106
  vectorDbOptions.dimensions = embeddingDimensions;
104
107
  } else if (vectorProvider === "milvus") {
105
- vectorDbOptions.baseUrl = (_j = readString(env, "MILVUS_URL")) != null ? _j : "http://localhost:19530";
108
+ vectorDbOptions.baseUrl = (_K = readString(env, "MILVUS_URL")) != null ? _K : "http://localhost:19530";
106
109
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
107
110
  } else if (vectorProvider === "chromadb") {
108
- vectorDbOptions.baseUrl = (_k = readString(env, "CHROMADB_URL")) != null ? _k : "http://localhost:8000";
111
+ vectorDbOptions.baseUrl = (_L = readString(env, "CHROMADB_URL")) != null ? _L : "http://localhost:8000";
109
112
  } else if (vectorProvider === "weaviate") {
110
- vectorDbOptions.baseUrl = (_l = readString(env, "WEAVIATE_URL")) != null ? _l : "http://localhost:8080";
113
+ vectorDbOptions.baseUrl = (_M = readString(env, "WEAVIATE_URL")) != null ? _M : "http://localhost:8080";
111
114
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
112
115
  } else if (vectorProvider === "redis") {
113
- vectorDbOptions.baseUrl = (_m = readString(env, "REDIS_URL")) != null ? _m : "";
116
+ vectorDbOptions.baseUrl = (_N = readString(env, "REDIS_URL")) != null ? _N : "";
114
117
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
115
118
  } else if (vectorProvider === "rest") {
116
- vectorDbOptions.baseUrl = (_n = readString(env, "VECTOR_DB_REST_URL")) != null ? _n : "";
119
+ vectorDbOptions.baseUrl = (_O = readString(env, "VECTOR_DB_REST_URL")) != null ? _O : "";
117
120
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
118
121
  } else if (vectorProvider === "universal_rest") {
119
- vectorDbOptions.baseUrl = (_p = (_o = readString(env, "VECTOR_BASE_URL")) != null ? _o : readString(env, "VECTOR_DB_REST_URL")) != null ? _p : "";
122
+ vectorDbOptions.baseUrl = (_Q = (_P = readString(env, "VECTOR_BASE_URL")) != null ? _P : readString(env, "VECTOR_DB_REST_URL")) != null ? _Q : "";
120
123
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
121
124
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
122
125
  }
@@ -133,20 +136,20 @@ function getRagConfig(env = process.env) {
133
136
  openai: readString(env, "OPENAI_API_KEY"),
134
137
  gemini: readString(env, "GEMINI_API_KEY"),
135
138
  ollama: void 0,
136
- universal_rest: (_q = readString(env, "EMBEDDING_API_KEY")) != null ? _q : readString(env, "OPENAI_API_KEY"),
137
- custom: (_r = readString(env, "EMBEDDING_API_KEY")) != null ? _r : readString(env, "OPENAI_API_KEY")
139
+ universal_rest: (_R = readString(env, "EMBEDDING_API_KEY")) != null ? _R : readString(env, "OPENAI_API_KEY"),
140
+ custom: (_S = readString(env, "EMBEDDING_API_KEY")) != null ? _S : readString(env, "OPENAI_API_KEY")
138
141
  };
139
142
  return {
140
143
  projectId,
141
144
  vectorDb: {
142
145
  provider: vectorProvider,
143
- indexName: (_s = readString(env, "VECTOR_DB_INDEX")) != null ? _s : "rag-index",
146
+ indexName: (_T = readString(env, "VECTOR_DB_INDEX")) != null ? _T : "rag-index",
144
147
  options: vectorDbOptions
145
148
  },
146
149
  llm: {
147
150
  provider: llmProvider,
148
- model: (_t = readString(env, "LLM_MODEL")) != null ? _t : "gpt-4o",
149
- apiKey: (_u = llmApiKeyByProvider[llmProvider]) != null ? _u : "",
151
+ model: (_U = readString(env, "LLM_MODEL")) != null ? _U : "gpt-4o",
152
+ apiKey: (_V = llmApiKeyByProvider[llmProvider]) != null ? _V : "",
150
153
  baseUrl: readString(env, "LLM_BASE_URL"),
151
154
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
152
155
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
@@ -157,7 +160,7 @@ function getRagConfig(env = process.env) {
157
160
  },
158
161
  embedding: {
159
162
  provider: embeddingProvider,
160
- model: (_v = readString(env, "EMBEDDING_MODEL")) != null ? _v : "text-embedding-3-small",
163
+ model: (_W = readString(env, "EMBEDDING_MODEL")) != null ? _W : "text-embedding-3-small",
161
164
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
162
165
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
163
166
  dimensions: embeddingDimensions,
@@ -168,17 +171,17 @@ function getRagConfig(env = process.env) {
168
171
  }
169
172
  },
170
173
  ui: {
171
- title: (_x = (_w = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _w : readString(env, "UI_TITLE")) != null ? _x : "AI Assistant",
172
- subtitle: (_z = (_y = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _y : readString(env, "UI_SUBTITLE")) != null ? _z : "Powered by RAG",
173
- primaryColor: (_B = (_A = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _A : readString(env, "UI_PRIMARY_COLOR")) != null ? _B : "#10b981",
174
- accentColor: (_D = (_C = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _C : readString(env, "UI_ACCENT_COLOR")) != null ? _D : "#3b82f6",
175
- logoUrl: (_E = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _E : readString(env, "UI_LOGO_URL"),
176
- placeholder: (_G = (_F = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _F : readString(env, "UI_PLACEHOLDER")) != null ? _G : "Ask me anything\u2026",
177
- showSources: ((_I = (_H = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _H : readString(env, "UI_SHOW_SOURCES")) != null ? _I : "true") !== "false",
178
- welcomeMessage: (_K = (_J = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _J : readString(env, "UI_WELCOME_MESSAGE")) != null ? _K : "Hello! I'm your AI assistant. Ask me anything about your documents.",
179
- visualStyle: (_M = (_L = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _L : readString(env, "UI_VISUAL_STYLE")) != null ? _M : "glass",
180
- borderRadius: (_O = (_N = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _N : readString(env, "UI_BORDER_RADIUS")) != null ? _O : "xl",
181
- allowUpload: ((_Q = (_P = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _P : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Q : "false") === "true"
174
+ title: (_Y = (_X = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _X : readString(env, "UI_TITLE")) != null ? _Y : "AI Assistant",
175
+ subtitle: (__ = (_Z = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _Z : readString(env, "UI_SUBTITLE")) != null ? __ : "Powered by RAG",
176
+ primaryColor: (_aa = (_$ = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _$ : readString(env, "UI_PRIMARY_COLOR")) != null ? _aa : "#10b981",
177
+ accentColor: (_ca = (_ba = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ba : readString(env, "UI_ACCENT_COLOR")) != null ? _ca : "#3b82f6",
178
+ logoUrl: (_da = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _da : readString(env, "UI_LOGO_URL"),
179
+ placeholder: (_fa = (_ea = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _ea : readString(env, "UI_PLACEHOLDER")) != null ? _fa : "Ask me anything\u2026",
180
+ showSources: ((_ha = (_ga = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ga : readString(env, "UI_SHOW_SOURCES")) != null ? _ha : "true") !== "false",
181
+ welcomeMessage: (_ja = (_ia = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _ia : readString(env, "UI_WELCOME_MESSAGE")) != null ? _ja : "Hello! I'm your AI assistant. Ask me anything about your documents.",
182
+ visualStyle: (_la = (_ka = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _ka : readString(env, "UI_VISUAL_STYLE")) != null ? _la : "glass",
183
+ borderRadius: (_na = (_ma = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _ma : readString(env, "UI_BORDER_RADIUS")) != null ? _na : "xl",
184
+ allowUpload: ((_pa = (_oa = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _oa : readString(env, "UI_ALLOW_UPLOAD")) != null ? _pa : "false") === "true"
182
185
  },
183
186
  rag: {
184
187
  topK: readNumber(env, "RAG_TOP_K", 5),
@@ -190,23 +193,13 @@ function getRagConfig(env = process.env) {
190
193
  }
191
194
 
192
195
  // src/core/ConfigResolver.ts
193
- var _cachedEnvConfig = null;
194
- function getCachedEnvConfig() {
195
- if (!_cachedEnvConfig) {
196
- _cachedEnvConfig = getRagConfig();
197
- }
198
- return _cachedEnvConfig;
199
- }
200
- function resetConfigCache() {
201
- _cachedEnvConfig = null;
202
- }
203
196
  var ConfigResolver = class {
204
197
  /**
205
198
  * Resolves the final configuration by merging host-provided config with environment defaults.
206
199
  * @param hostConfig - Partial configuration passed from the host application.
207
200
  */
208
- static resolve(hostConfig) {
209
- const envConfig = getCachedEnvConfig();
201
+ static resolve(hostConfig, env = process.env) {
202
+ const envConfig = getEnvConfig(env);
210
203
  if (!hostConfig) {
211
204
  return envConfig;
212
205
  }
@@ -362,6 +355,9 @@ ${context}`
362
355
  stop: options == null ? void 0 : options.stop,
363
356
  stream: true
364
357
  }));
358
+ if (!stream) {
359
+ throw new Error("[OpenAIProvider] completions.create stream is undefined");
360
+ }
365
361
  try {
366
362
  for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
367
363
  const chunk = temp.value;
@@ -507,6 +503,9 @@ ${context}`;
507
503
  messages: anthropicMessages,
508
504
  stream: true
509
505
  }));
506
+ if (!stream) {
507
+ throw new Error("[AnthropicProvider] messages.create stream is undefined");
508
+ }
510
509
  try {
511
510
  for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
512
511
  const chunk = temp.value;
@@ -646,8 +645,12 @@ var OllamaProvider = class {
646
645
  ]
647
646
  }, { responseType: "stream" }));
648
647
  let lineBuffer = "";
648
+ const stream = response.data;
649
+ if (!stream) {
650
+ throw new Error("[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.");
651
+ }
649
652
  try {
650
- for (var iter = __forAwait(response.data), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
653
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
651
654
  const chunk = temp.value;
652
655
  lineBuffer += chunk.toString();
653
656
  const lines = lineBuffer.split("\n");
@@ -829,7 +832,7 @@ ${context}`;
829
832
  }
830
833
  chatStream(messages, context, options) {
831
834
  return __asyncGenerator(this, null, function* () {
832
- var _a, _b, _c, _d, _e;
835
+ var _a, _b, _c, _d, _e, _f;
833
836
  const systemPrompt = (_a = this.llmConfig.systemPrompt) != null ? _a : `You are a helpful assistant. Answer questions based on the provided context.
834
837
 
835
838
  Context:
@@ -852,8 +855,12 @@ ${context}`;
852
855
  stopSequences: options == null ? void 0 : options.stop
853
856
  }
854
857
  }));
858
+ const stream = (_f = result == null ? void 0 : result.stream) != null ? _f : result;
859
+ if (!stream) {
860
+ throw new Error("[GeminiProvider] generateContentStream returned undefined");
861
+ }
855
862
  try {
856
- for (var iter = __forAwait(result.stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
863
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
857
864
  const chunk = temp.value;
858
865
  const text = chunk.text;
859
866
  if (text) yield text;
@@ -1249,7 +1256,7 @@ var ProviderRegistry = class {
1249
1256
  return MilvusProvider;
1250
1257
  }
1251
1258
  case "qdrant": {
1252
- const { QdrantProvider } = await import("./QdrantProvider-NMXOULCU.mjs");
1259
+ const { QdrantProvider } = await import("./QdrantProvider-RLJTNGPY.mjs");
1253
1260
  return QdrantProvider;
1254
1261
  }
1255
1262
  case "chromadb": {
@@ -2442,8 +2449,12 @@ ${context}`;
2442
2449
  }
2443
2450
  const messages = [...history, { role: "user", content: question }];
2444
2451
  if (this.llmProvider.chatStream) {
2452
+ const stream = this.llmProvider.chatStream(messages, context);
2453
+ if (!stream) {
2454
+ throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
2455
+ }
2445
2456
  try {
2446
- for (var iter = __forAwait(this.llmProvider.chatStream(messages, context)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2457
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2447
2458
  const chunk = temp.value;
2448
2459
  yield chunk;
2449
2460
  }
@@ -2897,7 +2908,6 @@ function createUploadHandler(configOrPlugin) {
2897
2908
 
2898
2909
  export {
2899
2910
  getRagConfig,
2900
- resetConfigCache,
2901
2911
  ConfigResolver,
2902
2912
  OpenAIProvider,
2903
2913
  AnthropicProvider,
@@ -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(([_, v]) => typeof v === "string").map(([k, v]) => ({ key: k, val: v }));
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, _namespace) {
212
+ async delete(id) {
213
213
  await this.http.post(`/collections/${this.indexName}/points/delete`, {
214
214
  points: [this.normalizeId(id)]
215
215
  });
@@ -1,3 +1,3 @@
1
- import '../RagConfig-DVovvPmd.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-D0_2f-43.mjs';
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';
@@ -1,3 +1,3 @@
1
- import '../RagConfig-DVovvPmd.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-CQ0zQ7Zk.js';
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';
@@ -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(([_, v]) => typeof v === "string").map(([k, v]) => ({ key: k, val: v }));
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, _namespace) {
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",
@@ -1688,44 +1688,44 @@ function readEnum(env, name, fallback, allowed) {
1688
1688
  }
1689
1689
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
1690
1690
  }
1691
- function getRagConfig(env = process.env) {
1692
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q;
1693
- const projectId = (_b = (_a = readString(env, "RAG_PROJECT_ID")) != null ? _a : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : "__default__";
1691
+ function getEnvConfig(env = process.env, base) {
1692
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa;
1693
+ const projectId = (_c = (_b = (_a = readString(env, "RAG_PROJECT_ID")) != null ? _a : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : base == null ? void 0 : base.projectId) != null ? _c : "__default__";
1694
1694
  const vectorProvider = readEnum(env, "VECTOR_DB_PROVIDER", "pinecone", VECTOR_DB_PROVIDERS);
1695
1695
  const llmProvider = readEnum(env, "LLM_PROVIDER", "openai", LLM_PROVIDERS);
1696
1696
  const embeddingProvider = readEnum(env, "EMBEDDING_PROVIDER", "openai", EMBEDDING_PROVIDERS);
1697
1697
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 1536);
1698
1698
  const vectorDbOptions = {};
1699
1699
  if (vectorProvider === "pinecone") {
1700
- vectorDbOptions.apiKey = (_c = readString(env, "PINECONE_API_KEY")) != null ? _c : "";
1700
+ vectorDbOptions.apiKey = (_g = (_f = readString(env, "PINECONE_API_KEY")) != null ? _f : (_e = (_d = base == null ? void 0 : base.vectorDb) == null ? void 0 : _d.options) == null ? void 0 : _e.apiKey) != null ? _g : "";
1701
1701
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
1702
- vectorDbOptions.connectionString = (_d = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _d : "";
1702
+ vectorDbOptions.connectionString = (_k = (_j = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _j : (_i = (_h = base == null ? void 0 : base.vectorDb) == null ? void 0 : _h.options) == null ? void 0 : _i.connectionString) != null ? _k : "";
1703
1703
  vectorDbOptions.dimensions = embeddingDimensions;
1704
1704
  } else if (vectorProvider === "mongodb") {
1705
- vectorDbOptions.uri = (_e = readString(env, "MONGODB_URI")) != null ? _e : "";
1706
- vectorDbOptions.database = (_f = readString(env, "MONGODB_DB")) != null ? _f : "";
1707
- vectorDbOptions.collection = (_g = readString(env, "MONGODB_COLLECTION")) != null ? _g : "";
1708
- vectorDbOptions.indexName = (_h = readString(env, "MONGODB_INDEX_NAME")) != null ? _h : "vector_index";
1705
+ vectorDbOptions.uri = (_o = (_n = readString(env, "MONGODB_URI")) != null ? _n : (_m = (_l = base == null ? void 0 : base.vectorDb) == null ? void 0 : _l.options) == null ? void 0 : _m.uri) != null ? _o : "";
1706
+ vectorDbOptions.database = (_s = (_r = readString(env, "MONGODB_DB")) != null ? _r : (_q = (_p = base == null ? void 0 : base.vectorDb) == null ? void 0 : _p.options) == null ? void 0 : _q.database) != null ? _s : "";
1707
+ vectorDbOptions.collection = (_w = (_v = readString(env, "MONGODB_COLLECTION")) != null ? _v : (_u = (_t = base == null ? void 0 : base.vectorDb) == null ? void 0 : _t.options) == null ? void 0 : _u.collection) != null ? _w : "";
1708
+ vectorDbOptions.indexName = (_C = (_B = (_y = readString(env, "MONGODB_INDEX_NAME")) != null ? _y : (_x = base == null ? void 0 : base.vectorDb) == null ? void 0 : _x.indexName) != null ? _B : (_A = (_z = base == null ? void 0 : base.vectorDb) == null ? void 0 : _z.options) == null ? void 0 : _A.indexName) != null ? _C : "vector_index";
1709
1709
  } else if (vectorProvider === "qdrant") {
1710
- vectorDbOptions.baseUrl = (_i = readString(env, "QDRANT_URL")) != null ? _i : "http://localhost:6333";
1711
- vectorDbOptions.apiKey = readString(env, "QDRANT_API_KEY");
1710
+ vectorDbOptions.baseUrl = (_G = (_F = readString(env, "QDRANT_URL")) != null ? _F : (_E = (_D = base == null ? void 0 : base.vectorDb) == null ? void 0 : _D.options) == null ? void 0 : _E.baseUrl) != null ? _G : "http://localhost:6333";
1711
+ vectorDbOptions.apiKey = (_J = readString(env, "QDRANT_API_KEY")) != null ? _J : (_I = (_H = base == null ? void 0 : base.vectorDb) == null ? void 0 : _H.options) == null ? void 0 : _I.apiKey;
1712
1712
  vectorDbOptions.dimensions = embeddingDimensions;
1713
1713
  } else if (vectorProvider === "milvus") {
1714
- vectorDbOptions.baseUrl = (_j = readString(env, "MILVUS_URL")) != null ? _j : "http://localhost:19530";
1714
+ vectorDbOptions.baseUrl = (_K = readString(env, "MILVUS_URL")) != null ? _K : "http://localhost:19530";
1715
1715
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
1716
1716
  } else if (vectorProvider === "chromadb") {
1717
- vectorDbOptions.baseUrl = (_k = readString(env, "CHROMADB_URL")) != null ? _k : "http://localhost:8000";
1717
+ vectorDbOptions.baseUrl = (_L = readString(env, "CHROMADB_URL")) != null ? _L : "http://localhost:8000";
1718
1718
  } else if (vectorProvider === "weaviate") {
1719
- vectorDbOptions.baseUrl = (_l = readString(env, "WEAVIATE_URL")) != null ? _l : "http://localhost:8080";
1719
+ vectorDbOptions.baseUrl = (_M = readString(env, "WEAVIATE_URL")) != null ? _M : "http://localhost:8080";
1720
1720
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
1721
1721
  } else if (vectorProvider === "redis") {
1722
- vectorDbOptions.baseUrl = (_m = readString(env, "REDIS_URL")) != null ? _m : "";
1722
+ vectorDbOptions.baseUrl = (_N = readString(env, "REDIS_URL")) != null ? _N : "";
1723
1723
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
1724
1724
  } else if (vectorProvider === "rest") {
1725
- vectorDbOptions.baseUrl = (_n = readString(env, "VECTOR_DB_REST_URL")) != null ? _n : "";
1725
+ vectorDbOptions.baseUrl = (_O = readString(env, "VECTOR_DB_REST_URL")) != null ? _O : "";
1726
1726
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
1727
1727
  } else if (vectorProvider === "universal_rest") {
1728
- vectorDbOptions.baseUrl = (_p = (_o = readString(env, "VECTOR_BASE_URL")) != null ? _o : readString(env, "VECTOR_DB_REST_URL")) != null ? _p : "";
1728
+ vectorDbOptions.baseUrl = (_Q = (_P = readString(env, "VECTOR_BASE_URL")) != null ? _P : readString(env, "VECTOR_DB_REST_URL")) != null ? _Q : "";
1729
1729
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
1730
1730
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
1731
1731
  }
@@ -1742,20 +1742,20 @@ function getRagConfig(env = process.env) {
1742
1742
  openai: readString(env, "OPENAI_API_KEY"),
1743
1743
  gemini: readString(env, "GEMINI_API_KEY"),
1744
1744
  ollama: void 0,
1745
- universal_rest: (_q = readString(env, "EMBEDDING_API_KEY")) != null ? _q : readString(env, "OPENAI_API_KEY"),
1746
- custom: (_r = readString(env, "EMBEDDING_API_KEY")) != null ? _r : readString(env, "OPENAI_API_KEY")
1745
+ universal_rest: (_R = readString(env, "EMBEDDING_API_KEY")) != null ? _R : readString(env, "OPENAI_API_KEY"),
1746
+ custom: (_S = readString(env, "EMBEDDING_API_KEY")) != null ? _S : readString(env, "OPENAI_API_KEY")
1747
1747
  };
1748
1748
  return {
1749
1749
  projectId,
1750
1750
  vectorDb: {
1751
1751
  provider: vectorProvider,
1752
- indexName: (_s = readString(env, "VECTOR_DB_INDEX")) != null ? _s : "rag-index",
1752
+ indexName: (_T = readString(env, "VECTOR_DB_INDEX")) != null ? _T : "rag-index",
1753
1753
  options: vectorDbOptions
1754
1754
  },
1755
1755
  llm: {
1756
1756
  provider: llmProvider,
1757
- model: (_t = readString(env, "LLM_MODEL")) != null ? _t : "gpt-4o",
1758
- apiKey: (_u = llmApiKeyByProvider[llmProvider]) != null ? _u : "",
1757
+ model: (_U = readString(env, "LLM_MODEL")) != null ? _U : "gpt-4o",
1758
+ apiKey: (_V = llmApiKeyByProvider[llmProvider]) != null ? _V : "",
1759
1759
  baseUrl: readString(env, "LLM_BASE_URL"),
1760
1760
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
1761
1761
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
@@ -1766,7 +1766,7 @@ function getRagConfig(env = process.env) {
1766
1766
  },
1767
1767
  embedding: {
1768
1768
  provider: embeddingProvider,
1769
- model: (_v = readString(env, "EMBEDDING_MODEL")) != null ? _v : "text-embedding-3-small",
1769
+ model: (_W = readString(env, "EMBEDDING_MODEL")) != null ? _W : "text-embedding-3-small",
1770
1770
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
1771
1771
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
1772
1772
  dimensions: embeddingDimensions,
@@ -1777,17 +1777,17 @@ function getRagConfig(env = process.env) {
1777
1777
  }
1778
1778
  },
1779
1779
  ui: {
1780
- title: (_x = (_w = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _w : readString(env, "UI_TITLE")) != null ? _x : "AI Assistant",
1781
- subtitle: (_z = (_y = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _y : readString(env, "UI_SUBTITLE")) != null ? _z : "Powered by RAG",
1782
- primaryColor: (_B = (_A = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _A : readString(env, "UI_PRIMARY_COLOR")) != null ? _B : "#10b981",
1783
- accentColor: (_D = (_C = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _C : readString(env, "UI_ACCENT_COLOR")) != null ? _D : "#3b82f6",
1784
- logoUrl: (_E = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _E : readString(env, "UI_LOGO_URL"),
1785
- placeholder: (_G = (_F = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _F : readString(env, "UI_PLACEHOLDER")) != null ? _G : "Ask me anything\u2026",
1786
- showSources: ((_I = (_H = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _H : readString(env, "UI_SHOW_SOURCES")) != null ? _I : "true") !== "false",
1787
- welcomeMessage: (_K = (_J = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _J : readString(env, "UI_WELCOME_MESSAGE")) != null ? _K : "Hello! I'm your AI assistant. Ask me anything about your documents.",
1788
- visualStyle: (_M = (_L = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _L : readString(env, "UI_VISUAL_STYLE")) != null ? _M : "glass",
1789
- borderRadius: (_O = (_N = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _N : readString(env, "UI_BORDER_RADIUS")) != null ? _O : "xl",
1790
- allowUpload: ((_Q = (_P = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _P : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Q : "false") === "true"
1780
+ title: (_Y = (_X = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _X : readString(env, "UI_TITLE")) != null ? _Y : "AI Assistant",
1781
+ subtitle: (__ = (_Z = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _Z : readString(env, "UI_SUBTITLE")) != null ? __ : "Powered by RAG",
1782
+ primaryColor: (_aa = (_$ = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _$ : readString(env, "UI_PRIMARY_COLOR")) != null ? _aa : "#10b981",
1783
+ accentColor: (_ca = (_ba = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ba : readString(env, "UI_ACCENT_COLOR")) != null ? _ca : "#3b82f6",
1784
+ logoUrl: (_da = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _da : readString(env, "UI_LOGO_URL"),
1785
+ placeholder: (_fa = (_ea = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _ea : readString(env, "UI_PLACEHOLDER")) != null ? _fa : "Ask me anything\u2026",
1786
+ showSources: ((_ha = (_ga = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ga : readString(env, "UI_SHOW_SOURCES")) != null ? _ha : "true") !== "false",
1787
+ welcomeMessage: (_ja = (_ia = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _ia : readString(env, "UI_WELCOME_MESSAGE")) != null ? _ja : "Hello! I'm your AI assistant. Ask me anything about your documents.",
1788
+ visualStyle: (_la = (_ka = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _ka : readString(env, "UI_VISUAL_STYLE")) != null ? _la : "glass",
1789
+ borderRadius: (_na = (_ma = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _ma : readString(env, "UI_BORDER_RADIUS")) != null ? _na : "xl",
1790
+ allowUpload: ((_pa = (_oa = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _oa : readString(env, "UI_ALLOW_UPLOAD")) != null ? _pa : "false") === "true"
1791
1791
  },
1792
1792
  rag: {
1793
1793
  topK: readNumber(env, "RAG_TOP_K", 5),
@@ -1799,20 +1799,13 @@ function getRagConfig(env = process.env) {
1799
1799
  }
1800
1800
 
1801
1801
  // src/core/ConfigResolver.ts
1802
- var _cachedEnvConfig = null;
1803
- function getCachedEnvConfig() {
1804
- if (!_cachedEnvConfig) {
1805
- _cachedEnvConfig = getRagConfig();
1806
- }
1807
- return _cachedEnvConfig;
1808
- }
1809
1802
  var ConfigResolver = class {
1810
1803
  /**
1811
1804
  * Resolves the final configuration by merging host-provided config with environment defaults.
1812
1805
  * @param hostConfig - Partial configuration passed from the host application.
1813
1806
  */
1814
- static resolve(hostConfig) {
1815
- const envConfig = getCachedEnvConfig();
1807
+ static resolve(hostConfig, env = process.env) {
1808
+ const envConfig = getEnvConfig(env);
1816
1809
  if (!hostConfig) {
1817
1810
  return envConfig;
1818
1811
  }
@@ -1968,6 +1961,9 @@ ${context}`
1968
1961
  stop: options == null ? void 0 : options.stop,
1969
1962
  stream: true
1970
1963
  }));
1964
+ if (!stream) {
1965
+ throw new Error("[OpenAIProvider] completions.create stream is undefined");
1966
+ }
1971
1967
  try {
1972
1968
  for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
1973
1969
  const chunk = temp.value;
@@ -2113,6 +2109,9 @@ ${context}`;
2113
2109
  messages: anthropicMessages,
2114
2110
  stream: true
2115
2111
  }));
2112
+ if (!stream) {
2113
+ throw new Error("[AnthropicProvider] messages.create stream is undefined");
2114
+ }
2116
2115
  try {
2117
2116
  for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2118
2117
  const chunk = temp.value;
@@ -2252,8 +2251,12 @@ var OllamaProvider = class {
2252
2251
  ]
2253
2252
  }, { responseType: "stream" }));
2254
2253
  let lineBuffer = "";
2254
+ const stream = response.data;
2255
+ if (!stream) {
2256
+ throw new Error("[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.");
2257
+ }
2255
2258
  try {
2256
- for (var iter = __forAwait(response.data), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2259
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2257
2260
  const chunk = temp.value;
2258
2261
  lineBuffer += chunk.toString();
2259
2262
  const lines = lineBuffer.split("\n");
@@ -2435,7 +2438,7 @@ ${context}`;
2435
2438
  }
2436
2439
  chatStream(messages, context, options) {
2437
2440
  return __asyncGenerator(this, null, function* () {
2438
- var _a, _b, _c, _d, _e;
2441
+ var _a, _b, _c, _d, _e, _f;
2439
2442
  const systemPrompt = (_a = this.llmConfig.systemPrompt) != null ? _a : `You are a helpful assistant. Answer questions based on the provided context.
2440
2443
 
2441
2444
  Context:
@@ -2458,8 +2461,12 @@ ${context}`;
2458
2461
  stopSequences: options == null ? void 0 : options.stop
2459
2462
  }
2460
2463
  }));
2464
+ const stream = (_f = result == null ? void 0 : result.stream) != null ? _f : result;
2465
+ if (!stream) {
2466
+ throw new Error("[GeminiProvider] generateContentStream returned undefined");
2467
+ }
2461
2468
  try {
2462
- for (var iter = __forAwait(result.stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2469
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2463
2470
  const chunk = temp.value;
2464
2471
  const text = chunk.text;
2465
2472
  if (text) yield text;
@@ -4004,8 +4011,12 @@ ${context}`;
4004
4011
  }
4005
4012
  const messages = [...history, { role: "user", content: question }];
4006
4013
  if (this.llmProvider.chatStream) {
4014
+ const stream = this.llmProvider.chatStream(messages, context);
4015
+ if (!stream) {
4016
+ throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
4017
+ }
4007
4018
  try {
4008
- for (var iter = __forAwait(this.llmProvider.chatStream(messages, context)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
4019
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
4009
4020
  const chunk = temp.value;
4010
4021
  yield chunk;
4011
4022
  }
@@ -8,7 +8,7 @@ import {
8
8
  sseFrame,
9
9
  sseMetaFrame,
10
10
  sseTextFrame
11
- } from "../chunk-JZ4H7EP6.mjs";
11
+ } from "../chunk-JBZEUFW3.mjs";
12
12
  import "../chunk-YLTMFW4M.mjs";
13
13
  import "../chunk-X4TOT24V.mjs";
14
14
  export {
@@ -1,4 +1,4 @@
1
- import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-DVovvPmd.js';
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-DVovvPmd.mjs';
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-DVovvPmd.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-DVovvPmd.mjs';
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-DVovvPmd.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-DVovvPmd.js';
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 {