@retrivora-ai/rag-engine 1.1.2 → 1.1.4

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,48 @@ 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, _qa, _ra, _sa, _ta, _ua, _va;
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 : "";
95
+ vectorDbOptions.indexName = (_l = (_i = readString(env, "PINECONE_INDEX")) != null ? _i : (_h = base == null ? void 0 : base.vectorDb) == null ? void 0 : _h.indexName) != null ? _l : (_k = (_j = base == null ? void 0 : base.vectorDb) == null ? void 0 : _j.options) == null ? void 0 : _k.indexName;
92
96
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
93
- vectorDbOptions.connectionString = (_d = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _d : "";
97
+ vectorDbOptions.connectionString = (_p = (_o = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _o : (_n = (_m = base == null ? void 0 : base.vectorDb) == null ? void 0 : _m.options) == null ? void 0 : _n.connectionString) != null ? _p : "";
94
98
  vectorDbOptions.dimensions = embeddingDimensions;
95
99
  } 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";
100
+ vectorDbOptions.uri = (_t = (_s = readString(env, "MONGODB_URI")) != null ? _s : (_r = (_q = base == null ? void 0 : base.vectorDb) == null ? void 0 : _q.options) == null ? void 0 : _r.uri) != null ? _t : "";
101
+ vectorDbOptions.database = (_x = (_w = readString(env, "MONGODB_DB")) != null ? _w : (_v = (_u = base == null ? void 0 : base.vectorDb) == null ? void 0 : _u.options) == null ? void 0 : _v.database) != null ? _x : "";
102
+ vectorDbOptions.collection = (_B = (_A = readString(env, "MONGODB_COLLECTION")) != null ? _A : (_z = (_y = base == null ? void 0 : base.vectorDb) == null ? void 0 : _y.options) == null ? void 0 : _z.collection) != null ? _B : "";
103
+ vectorDbOptions.indexName = (_H = (_G = (_D = readString(env, "MONGODB_INDEX_NAME")) != null ? _D : (_C = base == null ? void 0 : base.vectorDb) == null ? void 0 : _C.indexName) != null ? _G : (_F = (_E = base == null ? void 0 : base.vectorDb) == null ? void 0 : _E.options) == null ? void 0 : _F.indexName) != null ? _H : "vector_index";
100
104
  } 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");
105
+ vectorDbOptions.baseUrl = (_L = (_K = readString(env, "QDRANT_URL")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.baseUrl) != null ? _L : "http://localhost:6333";
106
+ vectorDbOptions.apiKey = (_O = readString(env, "QDRANT_API_KEY")) != null ? _O : (_N = (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.options) == null ? void 0 : _N.apiKey;
103
107
  vectorDbOptions.dimensions = embeddingDimensions;
104
108
  } else if (vectorProvider === "milvus") {
105
- vectorDbOptions.baseUrl = (_j = readString(env, "MILVUS_URL")) != null ? _j : "http://localhost:19530";
109
+ vectorDbOptions.baseUrl = (_P = readString(env, "MILVUS_URL")) != null ? _P : "http://localhost:19530";
106
110
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
107
111
  } else if (vectorProvider === "chromadb") {
108
- vectorDbOptions.baseUrl = (_k = readString(env, "CHROMADB_URL")) != null ? _k : "http://localhost:8000";
112
+ vectorDbOptions.baseUrl = (_Q = readString(env, "CHROMADB_URL")) != null ? _Q : "http://localhost:8000";
109
113
  } else if (vectorProvider === "weaviate") {
110
- vectorDbOptions.baseUrl = (_l = readString(env, "WEAVIATE_URL")) != null ? _l : "http://localhost:8080";
114
+ vectorDbOptions.baseUrl = (_R = readString(env, "WEAVIATE_URL")) != null ? _R : "http://localhost:8080";
111
115
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
112
116
  } else if (vectorProvider === "redis") {
113
- vectorDbOptions.baseUrl = (_m = readString(env, "REDIS_URL")) != null ? _m : "";
117
+ vectorDbOptions.baseUrl = (_S = readString(env, "REDIS_URL")) != null ? _S : "";
114
118
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
115
119
  } else if (vectorProvider === "rest") {
116
- vectorDbOptions.baseUrl = (_n = readString(env, "VECTOR_DB_REST_URL")) != null ? _n : "";
120
+ vectorDbOptions.baseUrl = (_T = readString(env, "VECTOR_DB_REST_URL")) != null ? _T : "";
117
121
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
118
122
  } 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 : "";
123
+ vectorDbOptions.baseUrl = (_V = (_U = readString(env, "VECTOR_BASE_URL")) != null ? _U : readString(env, "VECTOR_DB_REST_URL")) != null ? _V : "";
120
124
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
121
125
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
122
126
  }
@@ -133,20 +137,20 @@ function getRagConfig(env = process.env) {
133
137
  openai: readString(env, "OPENAI_API_KEY"),
134
138
  gemini: readString(env, "GEMINI_API_KEY"),
135
139
  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")
140
+ universal_rest: (_W = readString(env, "EMBEDDING_API_KEY")) != null ? _W : readString(env, "OPENAI_API_KEY"),
141
+ custom: (_X = readString(env, "EMBEDDING_API_KEY")) != null ? _X : readString(env, "OPENAI_API_KEY")
138
142
  };
139
143
  return {
140
144
  projectId,
141
145
  vectorDb: {
142
146
  provider: vectorProvider,
143
- indexName: (_s = readString(env, "VECTOR_DB_INDEX")) != null ? _s : "rag-index",
147
+ indexName: (_Z = (_Y = readString(env, "VECTOR_DB_INDEX")) != null ? _Y : vectorDbOptions.indexName) != null ? _Z : "rag-index",
144
148
  options: vectorDbOptions
145
149
  },
146
150
  llm: {
147
151
  provider: llmProvider,
148
- model: (_t = readString(env, "LLM_MODEL")) != null ? _t : "gpt-4o",
149
- apiKey: (_u = llmApiKeyByProvider[llmProvider]) != null ? _u : "",
152
+ model: (__ = readString(env, "LLM_MODEL")) != null ? __ : "gpt-4o",
153
+ apiKey: (_$ = llmApiKeyByProvider[llmProvider]) != null ? _$ : "",
150
154
  baseUrl: readString(env, "LLM_BASE_URL"),
151
155
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
152
156
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
@@ -157,7 +161,7 @@ function getRagConfig(env = process.env) {
157
161
  },
158
162
  embedding: {
159
163
  provider: embeddingProvider,
160
- model: (_v = readString(env, "EMBEDDING_MODEL")) != null ? _v : "text-embedding-3-small",
164
+ model: (_aa = readString(env, "EMBEDDING_MODEL")) != null ? _aa : "text-embedding-3-small",
161
165
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
162
166
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
163
167
  dimensions: embeddingDimensions,
@@ -168,17 +172,17 @@ function getRagConfig(env = process.env) {
168
172
  }
169
173
  },
170
174
  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"
175
+ title: (_ca = (_ba = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _ba : readString(env, "UI_TITLE")) != null ? _ca : "AI Assistant",
176
+ subtitle: (_ea = (_da = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _da : readString(env, "UI_SUBTITLE")) != null ? _ea : "Powered by RAG",
177
+ primaryColor: (_ga = (_fa = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _fa : readString(env, "UI_PRIMARY_COLOR")) != null ? _ga : "#10b981",
178
+ accentColor: (_ia = (_ha = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ha : readString(env, "UI_ACCENT_COLOR")) != null ? _ia : "#3b82f6",
179
+ logoUrl: (_ja = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ja : readString(env, "UI_LOGO_URL"),
180
+ placeholder: (_la = (_ka = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _ka : readString(env, "UI_PLACEHOLDER")) != null ? _la : "Ask me anything\u2026",
181
+ showSources: ((_na = (_ma = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ma : readString(env, "UI_SHOW_SOURCES")) != null ? _na : "true") !== "false",
182
+ welcomeMessage: (_pa = (_oa = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _oa : readString(env, "UI_WELCOME_MESSAGE")) != null ? _pa : "Hello! I'm your AI assistant. Ask me anything about your documents.",
183
+ visualStyle: (_ra = (_qa = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _qa : readString(env, "UI_VISUAL_STYLE")) != null ? _ra : "glass",
184
+ borderRadius: (_ta = (_sa = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _sa : readString(env, "UI_BORDER_RADIUS")) != null ? _ta : "xl",
185
+ allowUpload: ((_va = (_ua = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _ua : readString(env, "UI_ALLOW_UPLOAD")) != null ? _va : "false") === "true"
182
186
  },
183
187
  rag: {
184
188
  topK: readNumber(env, "RAG_TOP_K", 5),
@@ -190,23 +194,13 @@ function getRagConfig(env = process.env) {
190
194
  }
191
195
 
192
196
  // 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
197
  var ConfigResolver = class {
204
198
  /**
205
199
  * Resolves the final configuration by merging host-provided config with environment defaults.
206
200
  * @param hostConfig - Partial configuration passed from the host application.
207
201
  */
208
- static resolve(hostConfig) {
209
- const envConfig = getCachedEnvConfig();
202
+ static resolve(hostConfig, env = process.env) {
203
+ const envConfig = getEnvConfig(env);
210
204
  if (!hostConfig) {
211
205
  return envConfig;
212
206
  }
@@ -2915,7 +2909,6 @@ function createUploadHandler(configOrPlugin) {
2915
2909
 
2916
2910
  export {
2917
2911
  getRagConfig,
2918
- resetConfigCache,
2919
2912
  ConfigResolver,
2920
2913
  OpenAIProvider,
2921
2914
  AnthropicProvider,
@@ -1688,44 +1688,45 @@ 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, _qa, _ra, _sa, _ta, _ua, _va;
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
+ vectorDbOptions.indexName = (_l = (_i = readString(env, "PINECONE_INDEX")) != null ? _i : (_h = base == null ? void 0 : base.vectorDb) == null ? void 0 : _h.indexName) != null ? _l : (_k = (_j = base == null ? void 0 : base.vectorDb) == null ? void 0 : _j.options) == null ? void 0 : _k.indexName;
1701
1702
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
1702
- vectorDbOptions.connectionString = (_d = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _d : "";
1703
+ vectorDbOptions.connectionString = (_p = (_o = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _o : (_n = (_m = base == null ? void 0 : base.vectorDb) == null ? void 0 : _m.options) == null ? void 0 : _n.connectionString) != null ? _p : "";
1703
1704
  vectorDbOptions.dimensions = embeddingDimensions;
1704
1705
  } 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";
1706
+ vectorDbOptions.uri = (_t = (_s = readString(env, "MONGODB_URI")) != null ? _s : (_r = (_q = base == null ? void 0 : base.vectorDb) == null ? void 0 : _q.options) == null ? void 0 : _r.uri) != null ? _t : "";
1707
+ vectorDbOptions.database = (_x = (_w = readString(env, "MONGODB_DB")) != null ? _w : (_v = (_u = base == null ? void 0 : base.vectorDb) == null ? void 0 : _u.options) == null ? void 0 : _v.database) != null ? _x : "";
1708
+ vectorDbOptions.collection = (_B = (_A = readString(env, "MONGODB_COLLECTION")) != null ? _A : (_z = (_y = base == null ? void 0 : base.vectorDb) == null ? void 0 : _y.options) == null ? void 0 : _z.collection) != null ? _B : "";
1709
+ vectorDbOptions.indexName = (_H = (_G = (_D = readString(env, "MONGODB_INDEX_NAME")) != null ? _D : (_C = base == null ? void 0 : base.vectorDb) == null ? void 0 : _C.indexName) != null ? _G : (_F = (_E = base == null ? void 0 : base.vectorDb) == null ? void 0 : _E.options) == null ? void 0 : _F.indexName) != null ? _H : "vector_index";
1709
1710
  } 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");
1711
+ vectorDbOptions.baseUrl = (_L = (_K = readString(env, "QDRANT_URL")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.baseUrl) != null ? _L : "http://localhost:6333";
1712
+ vectorDbOptions.apiKey = (_O = readString(env, "QDRANT_API_KEY")) != null ? _O : (_N = (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.options) == null ? void 0 : _N.apiKey;
1712
1713
  vectorDbOptions.dimensions = embeddingDimensions;
1713
1714
  } else if (vectorProvider === "milvus") {
1714
- vectorDbOptions.baseUrl = (_j = readString(env, "MILVUS_URL")) != null ? _j : "http://localhost:19530";
1715
+ vectorDbOptions.baseUrl = (_P = readString(env, "MILVUS_URL")) != null ? _P : "http://localhost:19530";
1715
1716
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
1716
1717
  } else if (vectorProvider === "chromadb") {
1717
- vectorDbOptions.baseUrl = (_k = readString(env, "CHROMADB_URL")) != null ? _k : "http://localhost:8000";
1718
+ vectorDbOptions.baseUrl = (_Q = readString(env, "CHROMADB_URL")) != null ? _Q : "http://localhost:8000";
1718
1719
  } else if (vectorProvider === "weaviate") {
1719
- vectorDbOptions.baseUrl = (_l = readString(env, "WEAVIATE_URL")) != null ? _l : "http://localhost:8080";
1720
+ vectorDbOptions.baseUrl = (_R = readString(env, "WEAVIATE_URL")) != null ? _R : "http://localhost:8080";
1720
1721
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
1721
1722
  } else if (vectorProvider === "redis") {
1722
- vectorDbOptions.baseUrl = (_m = readString(env, "REDIS_URL")) != null ? _m : "";
1723
+ vectorDbOptions.baseUrl = (_S = readString(env, "REDIS_URL")) != null ? _S : "";
1723
1724
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
1724
1725
  } else if (vectorProvider === "rest") {
1725
- vectorDbOptions.baseUrl = (_n = readString(env, "VECTOR_DB_REST_URL")) != null ? _n : "";
1726
+ vectorDbOptions.baseUrl = (_T = readString(env, "VECTOR_DB_REST_URL")) != null ? _T : "";
1726
1727
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
1727
1728
  } 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 : "";
1729
+ vectorDbOptions.baseUrl = (_V = (_U = readString(env, "VECTOR_BASE_URL")) != null ? _U : readString(env, "VECTOR_DB_REST_URL")) != null ? _V : "";
1729
1730
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
1730
1731
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
1731
1732
  }
@@ -1742,20 +1743,20 @@ function getRagConfig(env = process.env) {
1742
1743
  openai: readString(env, "OPENAI_API_KEY"),
1743
1744
  gemini: readString(env, "GEMINI_API_KEY"),
1744
1745
  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")
1746
+ universal_rest: (_W = readString(env, "EMBEDDING_API_KEY")) != null ? _W : readString(env, "OPENAI_API_KEY"),
1747
+ custom: (_X = readString(env, "EMBEDDING_API_KEY")) != null ? _X : readString(env, "OPENAI_API_KEY")
1747
1748
  };
1748
1749
  return {
1749
1750
  projectId,
1750
1751
  vectorDb: {
1751
1752
  provider: vectorProvider,
1752
- indexName: (_s = readString(env, "VECTOR_DB_INDEX")) != null ? _s : "rag-index",
1753
+ indexName: (_Z = (_Y = readString(env, "VECTOR_DB_INDEX")) != null ? _Y : vectorDbOptions.indexName) != null ? _Z : "rag-index",
1753
1754
  options: vectorDbOptions
1754
1755
  },
1755
1756
  llm: {
1756
1757
  provider: llmProvider,
1757
- model: (_t = readString(env, "LLM_MODEL")) != null ? _t : "gpt-4o",
1758
- apiKey: (_u = llmApiKeyByProvider[llmProvider]) != null ? _u : "",
1758
+ model: (__ = readString(env, "LLM_MODEL")) != null ? __ : "gpt-4o",
1759
+ apiKey: (_$ = llmApiKeyByProvider[llmProvider]) != null ? _$ : "",
1759
1760
  baseUrl: readString(env, "LLM_BASE_URL"),
1760
1761
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
1761
1762
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
@@ -1766,7 +1767,7 @@ function getRagConfig(env = process.env) {
1766
1767
  },
1767
1768
  embedding: {
1768
1769
  provider: embeddingProvider,
1769
- model: (_v = readString(env, "EMBEDDING_MODEL")) != null ? _v : "text-embedding-3-small",
1770
+ model: (_aa = readString(env, "EMBEDDING_MODEL")) != null ? _aa : "text-embedding-3-small",
1770
1771
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
1771
1772
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
1772
1773
  dimensions: embeddingDimensions,
@@ -1777,17 +1778,17 @@ function getRagConfig(env = process.env) {
1777
1778
  }
1778
1779
  },
1779
1780
  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"
1781
+ title: (_ca = (_ba = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _ba : readString(env, "UI_TITLE")) != null ? _ca : "AI Assistant",
1782
+ subtitle: (_ea = (_da = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _da : readString(env, "UI_SUBTITLE")) != null ? _ea : "Powered by RAG",
1783
+ primaryColor: (_ga = (_fa = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _fa : readString(env, "UI_PRIMARY_COLOR")) != null ? _ga : "#10b981",
1784
+ accentColor: (_ia = (_ha = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ha : readString(env, "UI_ACCENT_COLOR")) != null ? _ia : "#3b82f6",
1785
+ logoUrl: (_ja = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ja : readString(env, "UI_LOGO_URL"),
1786
+ placeholder: (_la = (_ka = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _ka : readString(env, "UI_PLACEHOLDER")) != null ? _la : "Ask me anything\u2026",
1787
+ showSources: ((_na = (_ma = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ma : readString(env, "UI_SHOW_SOURCES")) != null ? _na : "true") !== "false",
1788
+ welcomeMessage: (_pa = (_oa = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _oa : readString(env, "UI_WELCOME_MESSAGE")) != null ? _pa : "Hello! I'm your AI assistant. Ask me anything about your documents.",
1789
+ visualStyle: (_ra = (_qa = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _qa : readString(env, "UI_VISUAL_STYLE")) != null ? _ra : "glass",
1790
+ borderRadius: (_ta = (_sa = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _sa : readString(env, "UI_BORDER_RADIUS")) != null ? _ta : "xl",
1791
+ allowUpload: ((_va = (_ua = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _ua : readString(env, "UI_ALLOW_UPLOAD")) != null ? _va : "false") === "true"
1791
1792
  },
1792
1793
  rag: {
1793
1794
  topK: readNumber(env, "RAG_TOP_K", 5),
@@ -1799,20 +1800,13 @@ function getRagConfig(env = process.env) {
1799
1800
  }
1800
1801
 
1801
1802
  // src/core/ConfigResolver.ts
1802
- var _cachedEnvConfig = null;
1803
- function getCachedEnvConfig() {
1804
- if (!_cachedEnvConfig) {
1805
- _cachedEnvConfig = getRagConfig();
1806
- }
1807
- return _cachedEnvConfig;
1808
- }
1809
1803
  var ConfigResolver = class {
1810
1804
  /**
1811
1805
  * Resolves the final configuration by merging host-provided config with environment defaults.
1812
1806
  * @param hostConfig - Partial configuration passed from the host application.
1813
1807
  */
1814
- static resolve(hostConfig) {
1815
- const envConfig = getCachedEnvConfig();
1808
+ static resolve(hostConfig, env = process.env) {
1809
+ const envConfig = getEnvConfig(env);
1816
1810
  if (!hostConfig) {
1817
1811
  return envConfig;
1818
1812
  }
@@ -8,7 +8,7 @@ import {
8
8
  sseFrame,
9
9
  sseMetaFrame,
10
10
  sseTextFrame
11
- } from "../chunk-XEWWAHCM.mjs";
11
+ } from "../chunk-OCDCJUNE.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,48 @@ 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, _qa, _ra, _sa, _ta, _ua, _va;
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 : "";
1748
+ vectorDbOptions.indexName = (_l = (_i = readString(env, "PINECONE_INDEX")) != null ? _i : (_h = base == null ? void 0 : base.vectorDb) == null ? void 0 : _h.indexName) != null ? _l : (_k = (_j = base == null ? void 0 : base.vectorDb) == null ? void 0 : _j.options) == null ? void 0 : _k.indexName;
1746
1749
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
1747
- vectorDbOptions.connectionString = (_d = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _d : "";
1750
+ vectorDbOptions.connectionString = (_p = (_o = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _o : (_n = (_m = base == null ? void 0 : base.vectorDb) == null ? void 0 : _m.options) == null ? void 0 : _n.connectionString) != null ? _p : "";
1748
1751
  vectorDbOptions.dimensions = embeddingDimensions;
1749
1752
  } 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";
1753
+ vectorDbOptions.uri = (_t = (_s = readString(env, "MONGODB_URI")) != null ? _s : (_r = (_q = base == null ? void 0 : base.vectorDb) == null ? void 0 : _q.options) == null ? void 0 : _r.uri) != null ? _t : "";
1754
+ vectorDbOptions.database = (_x = (_w = readString(env, "MONGODB_DB")) != null ? _w : (_v = (_u = base == null ? void 0 : base.vectorDb) == null ? void 0 : _u.options) == null ? void 0 : _v.database) != null ? _x : "";
1755
+ vectorDbOptions.collection = (_B = (_A = readString(env, "MONGODB_COLLECTION")) != null ? _A : (_z = (_y = base == null ? void 0 : base.vectorDb) == null ? void 0 : _y.options) == null ? void 0 : _z.collection) != null ? _B : "";
1756
+ vectorDbOptions.indexName = (_H = (_G = (_D = readString(env, "MONGODB_INDEX_NAME")) != null ? _D : (_C = base == null ? void 0 : base.vectorDb) == null ? void 0 : _C.indexName) != null ? _G : (_F = (_E = base == null ? void 0 : base.vectorDb) == null ? void 0 : _E.options) == null ? void 0 : _F.indexName) != null ? _H : "vector_index";
1754
1757
  } 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");
1758
+ vectorDbOptions.baseUrl = (_L = (_K = readString(env, "QDRANT_URL")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.baseUrl) != null ? _L : "http://localhost:6333";
1759
+ vectorDbOptions.apiKey = (_O = readString(env, "QDRANT_API_KEY")) != null ? _O : (_N = (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.options) == null ? void 0 : _N.apiKey;
1757
1760
  vectorDbOptions.dimensions = embeddingDimensions;
1758
1761
  } else if (vectorProvider === "milvus") {
1759
- vectorDbOptions.baseUrl = (_j = readString(env, "MILVUS_URL")) != null ? _j : "http://localhost:19530";
1762
+ vectorDbOptions.baseUrl = (_P = readString(env, "MILVUS_URL")) != null ? _P : "http://localhost:19530";
1760
1763
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
1761
1764
  } else if (vectorProvider === "chromadb") {
1762
- vectorDbOptions.baseUrl = (_k = readString(env, "CHROMADB_URL")) != null ? _k : "http://localhost:8000";
1765
+ vectorDbOptions.baseUrl = (_Q = readString(env, "CHROMADB_URL")) != null ? _Q : "http://localhost:8000";
1763
1766
  } else if (vectorProvider === "weaviate") {
1764
- vectorDbOptions.baseUrl = (_l = readString(env, "WEAVIATE_URL")) != null ? _l : "http://localhost:8080";
1767
+ vectorDbOptions.baseUrl = (_R = readString(env, "WEAVIATE_URL")) != null ? _R : "http://localhost:8080";
1765
1768
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
1766
1769
  } else if (vectorProvider === "redis") {
1767
- vectorDbOptions.baseUrl = (_m = readString(env, "REDIS_URL")) != null ? _m : "";
1770
+ vectorDbOptions.baseUrl = (_S = readString(env, "REDIS_URL")) != null ? _S : "";
1768
1771
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
1769
1772
  } else if (vectorProvider === "rest") {
1770
- vectorDbOptions.baseUrl = (_n = readString(env, "VECTOR_DB_REST_URL")) != null ? _n : "";
1773
+ vectorDbOptions.baseUrl = (_T = readString(env, "VECTOR_DB_REST_URL")) != null ? _T : "";
1771
1774
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
1772
1775
  } 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 : "";
1776
+ vectorDbOptions.baseUrl = (_V = (_U = readString(env, "VECTOR_BASE_URL")) != null ? _U : readString(env, "VECTOR_DB_REST_URL")) != null ? _V : "";
1774
1777
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
1775
1778
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
1776
1779
  }
@@ -1787,20 +1790,20 @@ function getRagConfig(env = process.env) {
1787
1790
  openai: readString(env, "OPENAI_API_KEY"),
1788
1791
  gemini: readString(env, "GEMINI_API_KEY"),
1789
1792
  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")
1793
+ universal_rest: (_W = readString(env, "EMBEDDING_API_KEY")) != null ? _W : readString(env, "OPENAI_API_KEY"),
1794
+ custom: (_X = readString(env, "EMBEDDING_API_KEY")) != null ? _X : readString(env, "OPENAI_API_KEY")
1792
1795
  };
1793
1796
  return {
1794
1797
  projectId,
1795
1798
  vectorDb: {
1796
1799
  provider: vectorProvider,
1797
- indexName: (_s = readString(env, "VECTOR_DB_INDEX")) != null ? _s : "rag-index",
1800
+ indexName: (_Z = (_Y = readString(env, "VECTOR_DB_INDEX")) != null ? _Y : vectorDbOptions.indexName) != null ? _Z : "rag-index",
1798
1801
  options: vectorDbOptions
1799
1802
  },
1800
1803
  llm: {
1801
1804
  provider: llmProvider,
1802
- model: (_t = readString(env, "LLM_MODEL")) != null ? _t : "gpt-4o",
1803
- apiKey: (_u = llmApiKeyByProvider[llmProvider]) != null ? _u : "",
1805
+ model: (__ = readString(env, "LLM_MODEL")) != null ? __ : "gpt-4o",
1806
+ apiKey: (_$ = llmApiKeyByProvider[llmProvider]) != null ? _$ : "",
1804
1807
  baseUrl: readString(env, "LLM_BASE_URL"),
1805
1808
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
1806
1809
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
@@ -1811,7 +1814,7 @@ function getRagConfig(env = process.env) {
1811
1814
  },
1812
1815
  embedding: {
1813
1816
  provider: embeddingProvider,
1814
- model: (_v = readString(env, "EMBEDDING_MODEL")) != null ? _v : "text-embedding-3-small",
1817
+ model: (_aa = readString(env, "EMBEDDING_MODEL")) != null ? _aa : "text-embedding-3-small",
1815
1818
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
1816
1819
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
1817
1820
  dimensions: embeddingDimensions,
@@ -1822,17 +1825,17 @@ function getRagConfig(env = process.env) {
1822
1825
  }
1823
1826
  },
1824
1827
  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"
1828
+ title: (_ca = (_ba = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _ba : readString(env, "UI_TITLE")) != null ? _ca : "AI Assistant",
1829
+ subtitle: (_ea = (_da = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _da : readString(env, "UI_SUBTITLE")) != null ? _ea : "Powered by RAG",
1830
+ primaryColor: (_ga = (_fa = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _fa : readString(env, "UI_PRIMARY_COLOR")) != null ? _ga : "#10b981",
1831
+ accentColor: (_ia = (_ha = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ha : readString(env, "UI_ACCENT_COLOR")) != null ? _ia : "#3b82f6",
1832
+ logoUrl: (_ja = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ja : readString(env, "UI_LOGO_URL"),
1833
+ placeholder: (_la = (_ka = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _ka : readString(env, "UI_PLACEHOLDER")) != null ? _la : "Ask me anything\u2026",
1834
+ showSources: ((_na = (_ma = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ma : readString(env, "UI_SHOW_SOURCES")) != null ? _na : "true") !== "false",
1835
+ welcomeMessage: (_pa = (_oa = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _oa : readString(env, "UI_WELCOME_MESSAGE")) != null ? _pa : "Hello! I'm your AI assistant. Ask me anything about your documents.",
1836
+ visualStyle: (_ra = (_qa = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _qa : readString(env, "UI_VISUAL_STYLE")) != null ? _ra : "glass",
1837
+ borderRadius: (_ta = (_sa = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _sa : readString(env, "UI_BORDER_RADIUS")) != null ? _ta : "xl",
1838
+ allowUpload: ((_va = (_ua = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _ua : readString(env, "UI_ALLOW_UPLOAD")) != null ? _va : "false") === "true"
1836
1839
  },
1837
1840
  rag: {
1838
1841
  topK: readNumber(env, "RAG_TOP_K", 5),
@@ -1844,23 +1847,13 @@ function getRagConfig(env = process.env) {
1844
1847
  }
1845
1848
 
1846
1849
  // 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
1850
  var ConfigResolver = class {
1858
1851
  /**
1859
1852
  * Resolves the final configuration by merging host-provided config with environment defaults.
1860
1853
  * @param hostConfig - Partial configuration passed from the host application.
1861
1854
  */
1862
- static resolve(hostConfig) {
1863
- const envConfig = getCachedEnvConfig();
1855
+ static resolve(hostConfig, env = process.env) {
1856
+ const envConfig = getEnvConfig(env);
1864
1857
  if (!hostConfig) {
1865
1858
  return envConfig;
1866
1859
  }
@@ -4991,7 +4984,6 @@ function createUploadHandler(configOrPlugin) {
4991
4984
  createStreamHandler,
4992
4985
  createUploadHandler,
4993
4986
  getRagConfig,
4994
- resetConfigCache,
4995
4987
  sseErrorFrame,
4996
4988
  sseFrame,
4997
4989
  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-OCDCJUNE.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.4",
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,19 @@ 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) ?? '';
77
+ vectorDbOptions.indexName = readString(env, 'PINECONE_INDEX') ?? (base?.vectorDb?.indexName as string) ?? (base?.vectorDb?.options?.indexName as string);
72
78
  } else if (vectorProvider === 'pgvector' || vectorProvider === 'postgresql') {
73
- vectorDbOptions.connectionString = readString(env, 'PGVECTOR_CONNECTION_STRING') ?? '';
79
+ vectorDbOptions.connectionString = readString(env, 'PGVECTOR_CONNECTION_STRING') ?? (base?.vectorDb?.options?.connectionString as string) ?? '';
74
80
  vectorDbOptions.dimensions = embeddingDimensions;
75
81
  } 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';
82
+ vectorDbOptions.uri = readString(env, 'MONGODB_URI') ?? (base?.vectorDb?.options?.uri as string) ?? '';
83
+ vectorDbOptions.database = readString(env, 'MONGODB_DB') ?? (base?.vectorDb?.options?.database as string) ?? '';
84
+ vectorDbOptions.collection = readString(env, 'MONGODB_COLLECTION') ?? (base?.vectorDb?.options?.collection as string) ?? '';
85
+ vectorDbOptions.indexName = readString(env, 'MONGODB_INDEX_NAME') ?? (base?.vectorDb?.indexName as string) ?? (base?.vectorDb?.options?.indexName as string) ?? 'vector_index';
80
86
  } else if (vectorProvider === 'qdrant') {
81
- vectorDbOptions.baseUrl = readString(env, 'QDRANT_URL') ?? 'http://localhost:6333';
82
- vectorDbOptions.apiKey = readString(env, 'QDRANT_API_KEY');
87
+ vectorDbOptions.baseUrl = readString(env, 'QDRANT_URL') ?? (base?.vectorDb?.options?.baseUrl as string) ?? 'http://localhost:6333';
88
+ vectorDbOptions.apiKey = readString(env, 'QDRANT_API_KEY') ?? (base?.vectorDb?.options?.apiKey as string);
83
89
  vectorDbOptions.dimensions = embeddingDimensions;
84
90
  } else if (vectorProvider === 'milvus') {
85
91
  vectorDbOptions.baseUrl = readString(env, 'MILVUS_URL') ?? 'http://localhost:19530';
@@ -128,7 +134,10 @@ export function getRagConfig(env: Record<string, string | undefined> = process.e
128
134
  projectId,
129
135
  vectorDb: {
130
136
  provider: vectorProvider,
131
- indexName: readString(env, 'VECTOR_DB_INDEX') ?? 'rag-index',
137
+ indexName:
138
+ readString(env, 'VECTOR_DB_INDEX') ??
139
+ (vectorDbOptions.indexName as string) ??
140
+ 'rag-index',
132
141
  options: vectorDbOptions,
133
142
  },
134
143
  llm: {
@@ -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';