@retrivora-ai/rag-engine 1.1.2 → 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.
@@ -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
  }
@@ -2915,7 +2908,6 @@ function createUploadHandler(configOrPlugin) {
2915
2908
 
2916
2909
  export {
2917
2910
  getRagConfig,
2918
- resetConfigCache,
2919
2911
  ConfigResolver,
2920
2912
  OpenAIProvider,
2921
2913
  AnthropicProvider,
@@ -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
  }
@@ -8,7 +8,7 @@ import {
8
8
  sseFrame,
9
9
  sseMetaFrame,
10
10
  sseTextFrame
11
- } from "../chunk-XEWWAHCM.mjs";
11
+ } from "../chunk-JBZEUFW3.mjs";
12
12
  import "../chunk-YLTMFW4M.mjs";
13
13
  import "../chunk-X4TOT24V.mjs";
14
14
  export {
package/dist/server.d.mts CHANGED
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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,
@@ -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
  }
@@ -4991,7 +4983,6 @@ function createUploadHandler(configOrPlugin) {
4991
4983
  createStreamHandler,
4992
4984
  createUploadHandler,
4993
4985
  getRagConfig,
4994
- resetConfigCache,
4995
4986
  sseErrorFrame,
4996
4987
  sseFrame,
4997
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-XEWWAHCM.mjs";
42
+ } from "./chunk-JBZEUFW3.mjs";
44
43
  import "./chunk-YLTMFW4M.mjs";
45
44
  import {
46
45
  PineconeProvider
@@ -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.2",
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",
@@ -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={{
@@ -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;
package/src/server.ts CHANGED
@@ -17,7 +17,7 @@ export type { BatchOptions, BatchResult } from './core/BatchProcessor';
17
17
  // ── Core Orchestration ─────────────────────────────────────────
18
18
  export { VectorPlugin } from './core/VectorPlugin';
19
19
  export { Pipeline } from './core/Pipeline';
20
- export { ConfigResolver, resetConfigCache } from './core/ConfigResolver';
20
+ export { ConfigResolver } from './core/ConfigResolver';
21
21
  export { ProviderRegistry } from './core/ProviderRegistry';
22
22
  export { ConfigValidator } from './core/ConfigValidator';
23
23
  export { ProviderHealthCheck } from './core/ProviderHealthCheck';