@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.
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-DVovvPmd.mjs';
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-D0_2f-43.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-D0_2f-43.mjs';
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
  /**
@@ -177,17 +177,12 @@ declare class Pipeline {
177
177
  * repeated work in serverless cold starts and per-request handler calls.
178
178
  */
179
179
 
180
- /**
181
- * Reset the cached env config. Useful in tests where environment variables
182
- * change between test cases.
183
- */
184
- declare function resetConfigCache(): void;
185
180
  declare class ConfigResolver {
186
181
  /**
187
182
  * Resolves the final configuration by merging host-provided config with environment defaults.
188
183
  * @param hostConfig - Partial configuration passed from the host application.
189
184
  */
190
- static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
185
+ static resolve(hostConfig?: Partial<RagConfig>, env?: Record<string, string | undefined>): RagConfig;
191
186
  /**
192
187
  * Validates the configuration for required fields.
193
188
  */
@@ -325,7 +320,7 @@ declare class ProviderRegistry {
325
320
  * universal_rest→ VECTOR_BASE_URL, VECTOR_DB_REST_API_KEY
326
321
  */
327
322
 
328
- declare function getRagConfig(env?: Record<string, string | undefined>): RagConfig;
323
+ declare function getRagConfig(baseConfig?: Partial<RagConfig>, env?: Record<string, string | undefined>): RagConfig;
329
324
 
330
325
  /**
331
326
  * ConfigBuilder — Fluent, type-safe configuration builder for RagConfig
@@ -756,7 +751,7 @@ declare class QdrantProvider extends BaseVectorProvider {
756
751
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
757
752
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
758
753
  query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
759
- delete(id: string | number, _namespace?: string): Promise<void>;
754
+ delete(id: string | number): Promise<void>;
760
755
  deleteNamespace(_namespace: string): Promise<void>;
761
756
  ping(): Promise<boolean>;
762
757
  private normalizeId;
@@ -950,4 +945,4 @@ declare class UniversalLLMAdapter implements ILLMProvider {
950
945
  ping(): Promise<boolean>;
951
946
  }
952
947
 
953
- export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RAGConfig, RagConfig, RedisProvider, UIConfig, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch, WeaviateProvider, createFromPreset, getRagConfig, resetConfigCache };
948
+ export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RAGConfig, RagConfig, RedisProvider, UIConfig, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch, WeaviateProvider, createFromPreset, getRagConfig };
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-DVovvPmd.js';
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-CQ0zQ7Zk.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-CQ0zQ7Zk.js';
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
  /**
@@ -177,17 +177,12 @@ declare class Pipeline {
177
177
  * repeated work in serverless cold starts and per-request handler calls.
178
178
  */
179
179
 
180
- /**
181
- * Reset the cached env config. Useful in tests where environment variables
182
- * change between test cases.
183
- */
184
- declare function resetConfigCache(): void;
185
180
  declare class ConfigResolver {
186
181
  /**
187
182
  * Resolves the final configuration by merging host-provided config with environment defaults.
188
183
  * @param hostConfig - Partial configuration passed from the host application.
189
184
  */
190
- static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
185
+ static resolve(hostConfig?: Partial<RagConfig>, env?: Record<string, string | undefined>): RagConfig;
191
186
  /**
192
187
  * Validates the configuration for required fields.
193
188
  */
@@ -325,7 +320,7 @@ declare class ProviderRegistry {
325
320
  * universal_rest→ VECTOR_BASE_URL, VECTOR_DB_REST_API_KEY
326
321
  */
327
322
 
328
- declare function getRagConfig(env?: Record<string, string | undefined>): RagConfig;
323
+ declare function getRagConfig(baseConfig?: Partial<RagConfig>, env?: Record<string, string | undefined>): RagConfig;
329
324
 
330
325
  /**
331
326
  * ConfigBuilder — Fluent, type-safe configuration builder for RagConfig
@@ -756,7 +751,7 @@ declare class QdrantProvider extends BaseVectorProvider {
756
751
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
757
752
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
758
753
  query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
759
- delete(id: string | number, _namespace?: string): Promise<void>;
754
+ delete(id: string | number): Promise<void>;
760
755
  deleteNamespace(_namespace: string): Promise<void>;
761
756
  ping(): Promise<boolean>;
762
757
  private normalizeId;
@@ -950,4 +945,4 @@ declare class UniversalLLMAdapter implements ILLMProvider {
950
945
  ping(): Promise<boolean>;
951
946
  }
952
947
 
953
- export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RAGConfig, RagConfig, RedisProvider, UIConfig, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch, WeaviateProvider, createFromPreset, getRagConfig, resetConfigCache };
948
+ export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RAGConfig, RagConfig, RedisProvider, UIConfig, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch, WeaviateProvider, createFromPreset, getRagConfig };
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(([_, v]) => typeof v === "string").map(([k, v]) => ({ key: k, val: v }));
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, _namespace) {
1055
+ async delete(id) {
1056
1056
  await this.http.post(`/collections/${this.indexName}/points/delete`, {
1057
1057
  points: [this.normalizeId(id)]
1058
1058
  });
@@ -1658,7 +1658,6 @@ __export(server_exports, {
1658
1658
  createStreamHandler: () => createStreamHandler,
1659
1659
  createUploadHandler: () => createUploadHandler,
1660
1660
  getRagConfig: () => getRagConfig,
1661
- resetConfigCache: () => resetConfigCache,
1662
1661
  sseErrorFrame: () => sseErrorFrame,
1663
1662
  sseFrame: () => sseFrame,
1664
1663
  sseMetaFrame: () => sseMetaFrame,
@@ -1675,8 +1674,8 @@ var VECTOR_DB_PROVIDERS = [
1675
1674
  "pgvector",
1676
1675
  "postgresql",
1677
1676
  "mongodb",
1678
- "milvus",
1679
1677
  "qdrant",
1678
+ "milvus",
1680
1679
  "chromadb",
1681
1680
  "redis",
1682
1681
  "weaviate",
@@ -1733,44 +1732,47 @@ function readEnum(env, name, fallback, allowed) {
1733
1732
  }
1734
1733
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
1735
1734
  }
1736
- function getRagConfig(env = process.env) {
1737
- 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;
1738
- const projectId = (_b = (_a = readString(env, "RAG_PROJECT_ID")) != null ? _a : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : "__default__";
1735
+ function getRagConfig(baseConfig, env = process.env) {
1736
+ return getEnvConfig(env, baseConfig);
1737
+ }
1738
+ function getEnvConfig(env = process.env, base) {
1739
+ 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;
1740
+ 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__";
1739
1741
  const vectorProvider = readEnum(env, "VECTOR_DB_PROVIDER", "pinecone", VECTOR_DB_PROVIDERS);
1740
1742
  const llmProvider = readEnum(env, "LLM_PROVIDER", "openai", LLM_PROVIDERS);
1741
1743
  const embeddingProvider = readEnum(env, "EMBEDDING_PROVIDER", "openai", EMBEDDING_PROVIDERS);
1742
1744
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 1536);
1743
1745
  const vectorDbOptions = {};
1744
1746
  if (vectorProvider === "pinecone") {
1745
- vectorDbOptions.apiKey = (_c = readString(env, "PINECONE_API_KEY")) != null ? _c : "";
1747
+ 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 : "";
1746
1748
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
1747
- vectorDbOptions.connectionString = (_d = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _d : "";
1749
+ 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 : "";
1748
1750
  vectorDbOptions.dimensions = embeddingDimensions;
1749
1751
  } else if (vectorProvider === "mongodb") {
1750
- vectorDbOptions.uri = (_e = readString(env, "MONGODB_URI")) != null ? _e : "";
1751
- vectorDbOptions.database = (_f = readString(env, "MONGODB_DB")) != null ? _f : "";
1752
- vectorDbOptions.collection = (_g = readString(env, "MONGODB_COLLECTION")) != null ? _g : "";
1753
- vectorDbOptions.indexName = (_h = readString(env, "MONGODB_INDEX_NAME")) != null ? _h : "vector_index";
1752
+ 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 : "";
1753
+ 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 : "";
1754
+ 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 : "";
1755
+ 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";
1754
1756
  } else if (vectorProvider === "qdrant") {
1755
- vectorDbOptions.baseUrl = (_i = readString(env, "QDRANT_URL")) != null ? _i : "http://localhost:6333";
1756
- vectorDbOptions.apiKey = readString(env, "QDRANT_API_KEY");
1757
+ 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";
1758
+ 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;
1757
1759
  vectorDbOptions.dimensions = embeddingDimensions;
1758
1760
  } else if (vectorProvider === "milvus") {
1759
- vectorDbOptions.baseUrl = (_j = readString(env, "MILVUS_URL")) != null ? _j : "http://localhost:19530";
1761
+ vectorDbOptions.baseUrl = (_K = readString(env, "MILVUS_URL")) != null ? _K : "http://localhost:19530";
1760
1762
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
1761
1763
  } else if (vectorProvider === "chromadb") {
1762
- vectorDbOptions.baseUrl = (_k = readString(env, "CHROMADB_URL")) != null ? _k : "http://localhost:8000";
1764
+ vectorDbOptions.baseUrl = (_L = readString(env, "CHROMADB_URL")) != null ? _L : "http://localhost:8000";
1763
1765
  } else if (vectorProvider === "weaviate") {
1764
- vectorDbOptions.baseUrl = (_l = readString(env, "WEAVIATE_URL")) != null ? _l : "http://localhost:8080";
1766
+ vectorDbOptions.baseUrl = (_M = readString(env, "WEAVIATE_URL")) != null ? _M : "http://localhost:8080";
1765
1767
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
1766
1768
  } else if (vectorProvider === "redis") {
1767
- vectorDbOptions.baseUrl = (_m = readString(env, "REDIS_URL")) != null ? _m : "";
1769
+ vectorDbOptions.baseUrl = (_N = readString(env, "REDIS_URL")) != null ? _N : "";
1768
1770
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
1769
1771
  } else if (vectorProvider === "rest") {
1770
- vectorDbOptions.baseUrl = (_n = readString(env, "VECTOR_DB_REST_URL")) != null ? _n : "";
1772
+ vectorDbOptions.baseUrl = (_O = readString(env, "VECTOR_DB_REST_URL")) != null ? _O : "";
1771
1773
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
1772
1774
  } else if (vectorProvider === "universal_rest") {
1773
- vectorDbOptions.baseUrl = (_p = (_o = readString(env, "VECTOR_BASE_URL")) != null ? _o : readString(env, "VECTOR_DB_REST_URL")) != null ? _p : "";
1775
+ vectorDbOptions.baseUrl = (_Q = (_P = readString(env, "VECTOR_BASE_URL")) != null ? _P : readString(env, "VECTOR_DB_REST_URL")) != null ? _Q : "";
1774
1776
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
1775
1777
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
1776
1778
  }
@@ -1787,20 +1789,20 @@ function getRagConfig(env = process.env) {
1787
1789
  openai: readString(env, "OPENAI_API_KEY"),
1788
1790
  gemini: readString(env, "GEMINI_API_KEY"),
1789
1791
  ollama: void 0,
1790
- universal_rest: (_q = readString(env, "EMBEDDING_API_KEY")) != null ? _q : readString(env, "OPENAI_API_KEY"),
1791
- custom: (_r = readString(env, "EMBEDDING_API_KEY")) != null ? _r : readString(env, "OPENAI_API_KEY")
1792
+ universal_rest: (_R = readString(env, "EMBEDDING_API_KEY")) != null ? _R : readString(env, "OPENAI_API_KEY"),
1793
+ custom: (_S = readString(env, "EMBEDDING_API_KEY")) != null ? _S : readString(env, "OPENAI_API_KEY")
1792
1794
  };
1793
1795
  return {
1794
1796
  projectId,
1795
1797
  vectorDb: {
1796
1798
  provider: vectorProvider,
1797
- indexName: (_s = readString(env, "VECTOR_DB_INDEX")) != null ? _s : "rag-index",
1799
+ indexName: (_T = readString(env, "VECTOR_DB_INDEX")) != null ? _T : "rag-index",
1798
1800
  options: vectorDbOptions
1799
1801
  },
1800
1802
  llm: {
1801
1803
  provider: llmProvider,
1802
- model: (_t = readString(env, "LLM_MODEL")) != null ? _t : "gpt-4o",
1803
- apiKey: (_u = llmApiKeyByProvider[llmProvider]) != null ? _u : "",
1804
+ model: (_U = readString(env, "LLM_MODEL")) != null ? _U : "gpt-4o",
1805
+ apiKey: (_V = llmApiKeyByProvider[llmProvider]) != null ? _V : "",
1804
1806
  baseUrl: readString(env, "LLM_BASE_URL"),
1805
1807
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
1806
1808
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
@@ -1811,7 +1813,7 @@ function getRagConfig(env = process.env) {
1811
1813
  },
1812
1814
  embedding: {
1813
1815
  provider: embeddingProvider,
1814
- model: (_v = readString(env, "EMBEDDING_MODEL")) != null ? _v : "text-embedding-3-small",
1816
+ model: (_W = readString(env, "EMBEDDING_MODEL")) != null ? _W : "text-embedding-3-small",
1815
1817
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
1816
1818
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
1817
1819
  dimensions: embeddingDimensions,
@@ -1822,17 +1824,17 @@ function getRagConfig(env = process.env) {
1822
1824
  }
1823
1825
  },
1824
1826
  ui: {
1825
- title: (_x = (_w = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _w : readString(env, "UI_TITLE")) != null ? _x : "AI Assistant",
1826
- subtitle: (_z = (_y = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _y : readString(env, "UI_SUBTITLE")) != null ? _z : "Powered by RAG",
1827
- primaryColor: (_B = (_A = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _A : readString(env, "UI_PRIMARY_COLOR")) != null ? _B : "#10b981",
1828
- accentColor: (_D = (_C = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _C : readString(env, "UI_ACCENT_COLOR")) != null ? _D : "#3b82f6",
1829
- logoUrl: (_E = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _E : readString(env, "UI_LOGO_URL"),
1830
- placeholder: (_G = (_F = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _F : readString(env, "UI_PLACEHOLDER")) != null ? _G : "Ask me anything\u2026",
1831
- showSources: ((_I = (_H = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _H : readString(env, "UI_SHOW_SOURCES")) != null ? _I : "true") !== "false",
1832
- 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.",
1833
- visualStyle: (_M = (_L = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _L : readString(env, "UI_VISUAL_STYLE")) != null ? _M : "glass",
1834
- borderRadius: (_O = (_N = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _N : readString(env, "UI_BORDER_RADIUS")) != null ? _O : "xl",
1835
- allowUpload: ((_Q = (_P = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _P : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Q : "false") === "true"
1827
+ title: (_Y = (_X = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _X : readString(env, "UI_TITLE")) != null ? _Y : "AI Assistant",
1828
+ subtitle: (__ = (_Z = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _Z : readString(env, "UI_SUBTITLE")) != null ? __ : "Powered by RAG",
1829
+ primaryColor: (_aa = (_$ = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _$ : readString(env, "UI_PRIMARY_COLOR")) != null ? _aa : "#10b981",
1830
+ accentColor: (_ca = (_ba = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ba : readString(env, "UI_ACCENT_COLOR")) != null ? _ca : "#3b82f6",
1831
+ logoUrl: (_da = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _da : readString(env, "UI_LOGO_URL"),
1832
+ placeholder: (_fa = (_ea = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _ea : readString(env, "UI_PLACEHOLDER")) != null ? _fa : "Ask me anything\u2026",
1833
+ showSources: ((_ha = (_ga = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ga : readString(env, "UI_SHOW_SOURCES")) != null ? _ha : "true") !== "false",
1834
+ 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.",
1835
+ visualStyle: (_la = (_ka = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _ka : readString(env, "UI_VISUAL_STYLE")) != null ? _la : "glass",
1836
+ borderRadius: (_na = (_ma = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _ma : readString(env, "UI_BORDER_RADIUS")) != null ? _na : "xl",
1837
+ allowUpload: ((_pa = (_oa = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _oa : readString(env, "UI_ALLOW_UPLOAD")) != null ? _pa : "false") === "true"
1836
1838
  },
1837
1839
  rag: {
1838
1840
  topK: readNumber(env, "RAG_TOP_K", 5),
@@ -1844,23 +1846,13 @@ function getRagConfig(env = process.env) {
1844
1846
  }
1845
1847
 
1846
1848
  // src/core/ConfigResolver.ts
1847
- var _cachedEnvConfig = null;
1848
- function getCachedEnvConfig() {
1849
- if (!_cachedEnvConfig) {
1850
- _cachedEnvConfig = getRagConfig();
1851
- }
1852
- return _cachedEnvConfig;
1853
- }
1854
- function resetConfigCache() {
1855
- _cachedEnvConfig = null;
1856
- }
1857
1849
  var ConfigResolver = class {
1858
1850
  /**
1859
1851
  * Resolves the final configuration by merging host-provided config with environment defaults.
1860
1852
  * @param hostConfig - Partial configuration passed from the host application.
1861
1853
  */
1862
- static resolve(hostConfig) {
1863
- const envConfig = getCachedEnvConfig();
1854
+ static resolve(hostConfig, env = process.env) {
1855
+ const envConfig = getEnvConfig(env);
1864
1856
  if (!hostConfig) {
1865
1857
  return envConfig;
1866
1858
  }
@@ -2016,6 +2008,9 @@ ${context}`
2016
2008
  stop: options == null ? void 0 : options.stop,
2017
2009
  stream: true
2018
2010
  }));
2011
+ if (!stream) {
2012
+ throw new Error("[OpenAIProvider] completions.create stream is undefined");
2013
+ }
2019
2014
  try {
2020
2015
  for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2021
2016
  const chunk = temp.value;
@@ -2161,6 +2156,9 @@ ${context}`;
2161
2156
  messages: anthropicMessages,
2162
2157
  stream: true
2163
2158
  }));
2159
+ if (!stream) {
2160
+ throw new Error("[AnthropicProvider] messages.create stream is undefined");
2161
+ }
2164
2162
  try {
2165
2163
  for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2166
2164
  const chunk = temp.value;
@@ -2300,8 +2298,12 @@ var OllamaProvider = class {
2300
2298
  ]
2301
2299
  }, { responseType: "stream" }));
2302
2300
  let lineBuffer = "";
2301
+ const stream = response.data;
2302
+ if (!stream) {
2303
+ throw new Error("[OllamaProvider] response.data is undefined for stream request. Axios might not support streams in this environment.");
2304
+ }
2303
2305
  try {
2304
- for (var iter = __forAwait(response.data), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2306
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2305
2307
  const chunk = temp.value;
2306
2308
  lineBuffer += chunk.toString();
2307
2309
  const lines = lineBuffer.split("\n");
@@ -2483,7 +2485,7 @@ ${context}`;
2483
2485
  }
2484
2486
  chatStream(messages, context, options) {
2485
2487
  return __asyncGenerator(this, null, function* () {
2486
- var _a, _b, _c, _d, _e;
2488
+ var _a, _b, _c, _d, _e, _f;
2487
2489
  const systemPrompt = (_a = this.llmConfig.systemPrompt) != null ? _a : `You are a helpful assistant. Answer questions based on the provided context.
2488
2490
 
2489
2491
  Context:
@@ -2506,8 +2508,12 @@ ${context}`;
2506
2508
  stopSequences: options == null ? void 0 : options.stop
2507
2509
  }
2508
2510
  }));
2511
+ const stream = (_f = result == null ? void 0 : result.stream) != null ? _f : result;
2512
+ if (!stream) {
2513
+ throw new Error("[GeminiProvider] generateContentStream returned undefined");
2514
+ }
2509
2515
  try {
2510
- for (var iter = __forAwait(result.stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2516
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
2511
2517
  const chunk = temp.value;
2512
2518
  const text = chunk.text;
2513
2519
  if (text) yield text;
@@ -4097,8 +4103,12 @@ ${context}`;
4097
4103
  }
4098
4104
  const messages = [...history, { role: "user", content: question }];
4099
4105
  if (this.llmProvider.chatStream) {
4106
+ const stream = this.llmProvider.chatStream(messages, context);
4107
+ if (!stream) {
4108
+ throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
4109
+ }
4100
4110
  try {
4101
- for (var iter = __forAwait(this.llmProvider.chatStream(messages, context)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
4111
+ for (var iter = __forAwait(stream), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
4102
4112
  const chunk = temp.value;
4103
4113
  yield chunk;
4104
4114
  }
@@ -4973,7 +4983,6 @@ function createUploadHandler(configOrPlugin) {
4973
4983
  createStreamHandler,
4974
4984
  createUploadHandler,
4975
4985
  getRagConfig,
4976
- resetConfigCache,
4977
4986
  sseErrorFrame,
4978
4987
  sseFrame,
4979
4988
  sseMetaFrame,
package/dist/server.mjs CHANGED
@@ -35,12 +35,11 @@ import {
35
35
  createStreamHandler,
36
36
  createUploadHandler,
37
37
  getRagConfig,
38
- resetConfigCache,
39
38
  sseErrorFrame,
40
39
  sseFrame,
41
40
  sseMetaFrame,
42
41
  sseTextFrame
43
- } from "./chunk-JZ4H7EP6.mjs";
42
+ } from "./chunk-JBZEUFW3.mjs";
44
43
  import "./chunk-YLTMFW4M.mjs";
45
44
  import {
46
45
  PineconeProvider
@@ -56,7 +55,7 @@ import {
56
55
  } from "./chunk-U55XRW3U.mjs";
57
56
  import {
58
57
  QdrantProvider
59
- } from "./chunk-63HITIWC.mjs";
58
+ } from "./chunk-PSFPZXHX.mjs";
60
59
  import {
61
60
  BaseVectorProvider
62
61
  } from "./chunk-IMP6FUCY.mjs";
@@ -472,7 +471,6 @@ export {
472
471
  createStreamHandler,
473
472
  createUploadHandler,
474
473
  getRagConfig,
475
- resetConfigCache,
476
474
  sseErrorFrame,
477
475
  sseFrame,
478
476
  sseMetaFrame,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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",
@@ -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
  ];
@@ -18,7 +18,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
18
18
 
19
19
  return (
20
20
  <html lang="en" className={inter.variable} suppressHydrationWarning>
21
- <body className="bg-slate-50 dark:bg-[#080811] text-slate-900 dark:text-white antialiased transition-colors duration-300">
21
+ <body className="bg-slate-50 dark:bg-[#080811] text-slate-900 dark:text-white antialiased transition-colors duration-300" suppressHydrationWarning>
22
22
  <ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
23
23
  <ConfigProvider
24
24
  config={{
@@ -10,8 +10,8 @@ export const VECTOR_DB_PROVIDERS = [
10
10
  'pgvector',
11
11
  'postgresql',
12
12
  'mongodb',
13
- 'milvus',
14
13
  'qdrant',
14
+ 'milvus',
15
15
  'chromadb',
16
16
  'redis',
17
17
  'weaviate',
@@ -53,10 +53,15 @@ function readEnum<T extends readonly string[]>(
53
53
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(', ')}`);
54
54
  }
55
55
 
56
- export function getRagConfig(env: Record<string, string | undefined> = process.env): RagConfig {
56
+ export function getRagConfig(baseConfig?: Partial<RagConfig>, env: Record<string, string | undefined> = process.env): RagConfig {
57
+ return getEnvConfig(env, baseConfig);
58
+ }
59
+
60
+ export function getEnvConfig(env: Record<string, string | undefined> = process.env, base?: Partial<RagConfig>): RagConfig {
57
61
  const projectId =
58
62
  readString(env, 'RAG_PROJECT_ID') ??
59
63
  readString(env, 'NEXT_PUBLIC_PROJECT_ID') ??
64
+ base?.projectId ??
60
65
  '__default__';
61
66
 
62
67
  const vectorProvider = readEnum(env, 'VECTOR_DB_PROVIDER', 'pinecone', VECTOR_DB_PROVIDERS);
@@ -68,18 +73,18 @@ export function getRagConfig(env: Record<string, string | undefined> = process.e
68
73
  const vectorDbOptions: Record<string, unknown> = {};
69
74
 
70
75
  if (vectorProvider === 'pinecone') {
71
- vectorDbOptions.apiKey = readString(env, 'PINECONE_API_KEY') ?? '';
76
+ vectorDbOptions.apiKey = readString(env, 'PINECONE_API_KEY') ?? (base?.vectorDb?.options?.apiKey as string) ?? '';
72
77
  } else if (vectorProvider === 'pgvector' || vectorProvider === 'postgresql') {
73
- vectorDbOptions.connectionString = readString(env, 'PGVECTOR_CONNECTION_STRING') ?? '';
78
+ vectorDbOptions.connectionString = readString(env, 'PGVECTOR_CONNECTION_STRING') ?? (base?.vectorDb?.options?.connectionString as string) ?? '';
74
79
  vectorDbOptions.dimensions = embeddingDimensions;
75
80
  } else if (vectorProvider === 'mongodb') {
76
- vectorDbOptions.uri = readString(env, 'MONGODB_URI') ?? '';
77
- vectorDbOptions.database = readString(env, 'MONGODB_DB') ?? '';
78
- vectorDbOptions.collection = readString(env, 'MONGODB_COLLECTION') ?? '';
79
- vectorDbOptions.indexName = readString(env, 'MONGODB_INDEX_NAME') ?? 'vector_index';
81
+ vectorDbOptions.uri = readString(env, 'MONGODB_URI') ?? (base?.vectorDb?.options?.uri as string) ?? '';
82
+ vectorDbOptions.database = readString(env, 'MONGODB_DB') ?? (base?.vectorDb?.options?.database as string) ?? '';
83
+ vectorDbOptions.collection = readString(env, 'MONGODB_COLLECTION') ?? (base?.vectorDb?.options?.collection as string) ?? '';
84
+ vectorDbOptions.indexName = readString(env, 'MONGODB_INDEX_NAME') ?? (base?.vectorDb?.indexName as string) ?? (base?.vectorDb?.options?.indexName as string) ?? 'vector_index';
80
85
  } else if (vectorProvider === 'qdrant') {
81
- vectorDbOptions.baseUrl = readString(env, 'QDRANT_URL') ?? 'http://localhost:6333';
82
- vectorDbOptions.apiKey = readString(env, 'QDRANT_API_KEY');
86
+ vectorDbOptions.baseUrl = readString(env, 'QDRANT_URL') ?? (base?.vectorDb?.options?.baseUrl as string) ?? 'http://localhost:6333';
87
+ vectorDbOptions.apiKey = readString(env, 'QDRANT_API_KEY') ?? (base?.vectorDb?.options?.apiKey as string);
83
88
  vectorDbOptions.dimensions = embeddingDimensions;
84
89
  } else if (vectorProvider === 'milvus') {
85
90
  vectorDbOptions.baseUrl = readString(env, 'MILVUS_URL') ?? 'http://localhost:19530';
@@ -8,33 +8,17 @@
8
8
  */
9
9
  import { RagConfig } from '../config/RagConfig';
10
10
  import { mergeDefined } from '../utils/templateUtils';
11
- import { getRagConfig as getEnvConfig } from '../config/serverConfig';
11
+ import { getEnvConfig } from '../config/serverConfig';
12
12
 
13
- /** Module-level cache: populated on first use, shared across all VectorPlugin instances. */
14
- let _cachedEnvConfig: RagConfig | null = null;
15
13
 
16
- function getCachedEnvConfig(): RagConfig {
17
- if (!_cachedEnvConfig) {
18
- _cachedEnvConfig = getEnvConfig();
19
- }
20
- return _cachedEnvConfig;
21
- }
22
-
23
- /**
24
- * Reset the cached env config. Useful in tests where environment variables
25
- * change between test cases.
26
- */
27
- export function resetConfigCache(): void {
28
- _cachedEnvConfig = null;
29
- }
30
14
 
31
15
  export class ConfigResolver {
32
16
  /**
33
17
  * Resolves the final configuration by merging host-provided config with environment defaults.
34
18
  * @param hostConfig - Partial configuration passed from the host application.
35
19
  */
36
- static resolve(hostConfig?: Partial<RagConfig>): RagConfig {
37
- const envConfig = getCachedEnvConfig();
20
+ static resolve(hostConfig?: Partial<RagConfig>, env: Record<string, string | undefined> = process.env): RagConfig {
21
+ const envConfig = getEnvConfig(env);
38
22
 
39
23
  if (!hostConfig) {
40
24
  return envConfig;
@@ -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
- for await (const chunk of this.llmProvider.chatStream(messages, context)) {
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
- for await (const chunk of result.stream) {
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
- for await (const chunk of response.data) {
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;