@retrivora-ai/rag-engine 1.4.5 → 1.4.7

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.
@@ -153,7 +153,7 @@ function getEnvConfig(env = process.env, base) {
153
153
  apiKey: (_$ = llmApiKeyByProvider[llmProvider]) != null ? _$ : "",
154
154
  baseUrl: readString(env, "LLM_BASE_URL"),
155
155
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
156
- maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
156
+ maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
157
157
  temperature: readNumber(env, "LLM_TEMPERATURE", 0.7),
158
158
  options: {
159
159
  profile: readString(env, "LLM_UNIVERSAL_PROFILE")
@@ -2257,29 +2257,22 @@ var Pipeline = class {
2257
2257
  this.reranker = new Reranker();
2258
2258
  }
2259
2259
  async initialize() {
2260
- var _a, _b;
2260
+ var _a;
2261
2261
  if (this.initialised) return;
2262
2262
  const chartInstruction = `
2263
2263
 
2264
- When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
2265
- - For tables: use standard Markdown tables.
2266
- - For charts (bar, line, pie): You MUST output a fenced code block with the language 'chart'.
2267
- - CRITICAL RULES:
2268
- 1. Use ONLY valid JSON (double quotes, no trailing commas).
2269
- 2. NO math expressions (e.g., use 100, NOT 50+50).
2270
- 3. dataKeys MUST exactly match the property names in the data objects.
2271
- 4. data objects MUST be FLAT (no nested objects or arrays).
2272
- 5. DO NOT output naked JSON or markdown tables for visualizations.
2273
- 6. ALWAYS wrap your visualization data in a \`\`\`chart ... \`\`\` code block.
2274
- \`\`\`chart
2275
- {
2276
- "type": "bar" | "line" | "pie",
2277
- "xAxisKey": "name",
2278
- "dataKeys": ["value"],
2279
- "data": [{"name": "A", "value": 10}]
2280
- }
2281
- \`\`\``;
2282
- if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes("chart"))) {
2264
+ ### VISUALIZATION PROTOCOL:
2265
+ When requested to show data visually (charts, graphs, or comparisons), you MUST use this format:
2266
+ 1. Wrap the data in a fenced code block with the language 'chart'.
2267
+ 2. Use ONLY valid JSON matching this schema:
2268
+ {
2269
+ "type": "bar" | "line" | "pie",
2270
+ "xAxisKey": "property_for_label",
2271
+ "dataKeys": ["property_for_value"],
2272
+ "data": [{ "property_for_label": "A", "property_for_value": 10 }]
2273
+ }
2274
+ 3. RULES: Data objects MUST be FLAT (no nesting). No math expressions in JSON. NEVER draw charts with text or markdown tables.`;
2275
+ if (!this.config.llm.systemPrompt || !this.config.llm.systemPrompt.includes("chart")) {
2283
2276
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
2284
2277
  }
2285
2278
  console.log(`[Pipeline] Initializing with provider: ${this.config.vectorDb.provider}...`);
@@ -2296,7 +2289,7 @@ When presenting structured data, statistics, or comparisons, decide if it is bes
2296
2289
  this.entityExtractor = new EntityExtractor(this.llmProvider);
2297
2290
  }
2298
2291
  await this.vectorDB.initialize();
2299
- if (((_b = this.config.rag) == null ? void 0 : _b.architecture) === "agentic") {
2292
+ if (((_a = this.config.rag) == null ? void 0 : _a.architecture) === "agentic") {
2300
2293
  this.agent = new LangChainAgent(this, this.config);
2301
2294
  await this.agent.initialize(this.llmProvider);
2302
2295
  }
@@ -1760,7 +1760,7 @@ function getEnvConfig(env = process.env, base) {
1760
1760
  apiKey: (_$ = llmApiKeyByProvider[llmProvider]) != null ? _$ : "",
1761
1761
  baseUrl: readString(env, "LLM_BASE_URL"),
1762
1762
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
1763
- maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
1763
+ maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
1764
1764
  temperature: readNumber(env, "LLM_TEMPERATURE", 0.7),
1765
1765
  options: {
1766
1766
  profile: readString(env, "LLM_UNIVERSAL_PROFILE")
@@ -3820,29 +3820,22 @@ var Pipeline = class {
3820
3820
  this.reranker = new Reranker();
3821
3821
  }
3822
3822
  async initialize() {
3823
- var _a, _b;
3823
+ var _a;
3824
3824
  if (this.initialised) return;
3825
3825
  const chartInstruction = `
3826
3826
 
3827
- When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3828
- - For tables: use standard Markdown tables.
3829
- - For charts (bar, line, pie): You MUST output a fenced code block with the language 'chart'.
3830
- - CRITICAL RULES:
3831
- 1. Use ONLY valid JSON (double quotes, no trailing commas).
3832
- 2. NO math expressions (e.g., use 100, NOT 50+50).
3833
- 3. dataKeys MUST exactly match the property names in the data objects.
3834
- 4. data objects MUST be FLAT (no nested objects or arrays).
3835
- 5. DO NOT output naked JSON or markdown tables for visualizations.
3836
- 6. ALWAYS wrap your visualization data in a \`\`\`chart ... \`\`\` code block.
3837
- \`\`\`chart
3838
- {
3839
- "type": "bar" | "line" | "pie",
3840
- "xAxisKey": "name",
3841
- "dataKeys": ["value"],
3842
- "data": [{"name": "A", "value": 10}]
3843
- }
3844
- \`\`\``;
3845
- if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes("chart"))) {
3827
+ ### VISUALIZATION PROTOCOL:
3828
+ When requested to show data visually (charts, graphs, or comparisons), you MUST use this format:
3829
+ 1. Wrap the data in a fenced code block with the language 'chart'.
3830
+ 2. Use ONLY valid JSON matching this schema:
3831
+ {
3832
+ "type": "bar" | "line" | "pie",
3833
+ "xAxisKey": "property_for_label",
3834
+ "dataKeys": ["property_for_value"],
3835
+ "data": [{ "property_for_label": "A", "property_for_value": 10 }]
3836
+ }
3837
+ 3. RULES: Data objects MUST be FLAT (no nesting). No math expressions in JSON. NEVER draw charts with text or markdown tables.`;
3838
+ if (!this.config.llm.systemPrompt || !this.config.llm.systemPrompt.includes("chart")) {
3846
3839
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
3847
3840
  }
3848
3841
  console.log(`[Pipeline] Initializing with provider: ${this.config.vectorDb.provider}...`);
@@ -3859,7 +3852,7 @@ When presenting structured data, statistics, or comparisons, decide if it is bes
3859
3852
  this.entityExtractor = new EntityExtractor(this.llmProvider);
3860
3853
  }
3861
3854
  await this.vectorDB.initialize();
3862
- if (((_b = this.config.rag) == null ? void 0 : _b.architecture) === "agentic") {
3855
+ if (((_a = this.config.rag) == null ? void 0 : _a.architecture) === "agentic") {
3863
3856
  this.agent = new LangChainAgent(this, this.config);
3864
3857
  await this.agent.initialize(this.llmProvider);
3865
3858
  }
@@ -9,7 +9,7 @@ import {
9
9
  sseFrame,
10
10
  sseMetaFrame,
11
11
  sseTextFrame
12
- } from "../chunk-GYT3LWD6.mjs";
12
+ } from "../chunk-YCL23GST.mjs";
13
13
  import "../chunk-YLTMFW4M.mjs";
14
14
  import "../chunk-X4TOT24V.mjs";
15
15
  export {
package/dist/server.js CHANGED
@@ -1806,7 +1806,7 @@ function getEnvConfig(env = process.env, base) {
1806
1806
  apiKey: (_$ = llmApiKeyByProvider[llmProvider]) != null ? _$ : "",
1807
1807
  baseUrl: readString(env, "LLM_BASE_URL"),
1808
1808
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
1809
- maxTokens: readNumber(env, "LLM_MAX_TOKENS", 1024),
1809
+ maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
1810
1810
  temperature: readNumber(env, "LLM_TEMPERATURE", 0.7),
1811
1811
  options: {
1812
1812
  profile: readString(env, "LLM_UNIVERSAL_PROFILE")
@@ -3911,29 +3911,22 @@ var Pipeline = class {
3911
3911
  this.reranker = new Reranker();
3912
3912
  }
3913
3913
  async initialize() {
3914
- var _a, _b;
3914
+ var _a;
3915
3915
  if (this.initialised) return;
3916
3916
  const chartInstruction = `
3917
3917
 
3918
- When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3919
- - For tables: use standard Markdown tables.
3920
- - For charts (bar, line, pie): You MUST output a fenced code block with the language 'chart'.
3921
- - CRITICAL RULES:
3922
- 1. Use ONLY valid JSON (double quotes, no trailing commas).
3923
- 2. NO math expressions (e.g., use 100, NOT 50+50).
3924
- 3. dataKeys MUST exactly match the property names in the data objects.
3925
- 4. data objects MUST be FLAT (no nested objects or arrays).
3926
- 5. DO NOT output naked JSON or markdown tables for visualizations.
3927
- 6. ALWAYS wrap your visualization data in a \`\`\`chart ... \`\`\` code block.
3928
- \`\`\`chart
3929
- {
3930
- "type": "bar" | "line" | "pie",
3931
- "xAxisKey": "name",
3932
- "dataKeys": ["value"],
3933
- "data": [{"name": "A", "value": 10}]
3934
- }
3935
- \`\`\``;
3936
- if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes("chart"))) {
3918
+ ### VISUALIZATION PROTOCOL:
3919
+ When requested to show data visually (charts, graphs, or comparisons), you MUST use this format:
3920
+ 1. Wrap the data in a fenced code block with the language 'chart'.
3921
+ 2. Use ONLY valid JSON matching this schema:
3922
+ {
3923
+ "type": "bar" | "line" | "pie",
3924
+ "xAxisKey": "property_for_label",
3925
+ "dataKeys": ["property_for_value"],
3926
+ "data": [{ "property_for_label": "A", "property_for_value": 10 }]
3927
+ }
3928
+ 3. RULES: Data objects MUST be FLAT (no nesting). No math expressions in JSON. NEVER draw charts with text or markdown tables.`;
3929
+ if (!this.config.llm.systemPrompt || !this.config.llm.systemPrompt.includes("chart")) {
3937
3930
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
3938
3931
  }
3939
3932
  console.log(`[Pipeline] Initializing with provider: ${this.config.vectorDb.provider}...`);
@@ -3950,7 +3943,7 @@ When presenting structured data, statistics, or comparisons, decide if it is bes
3950
3943
  this.entityExtractor = new EntityExtractor(this.llmProvider);
3951
3944
  }
3952
3945
  await this.vectorDB.initialize();
3953
- if (((_b = this.config.rag) == null ? void 0 : _b.architecture) === "agentic") {
3946
+ if (((_a = this.config.rag) == null ? void 0 : _a.architecture) === "agentic") {
3954
3947
  this.agent = new LangChainAgent(this, this.config);
3955
3948
  await this.agent.initialize(this.llmProvider);
3956
3949
  }
package/dist/server.mjs CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  sseFrame,
40
40
  sseMetaFrame,
41
41
  sseTextFrame
42
- } from "./chunk-GYT3LWD6.mjs";
42
+ } from "./chunk-YCL23GST.mjs";
43
43
  import "./chunk-YLTMFW4M.mjs";
44
44
  import {
45
45
  PineconeProvider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
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",
@@ -146,7 +146,7 @@ export function getEnvConfig(env: Record<string, string | undefined> = process.e
146
146
  apiKey: llmApiKeyByProvider[llmProvider] ?? '',
147
147
  baseUrl: readString(env, 'LLM_BASE_URL'),
148
148
  systemPrompt: readString(env, 'LLM_SYSTEM_PROMPT'),
149
- maxTokens: readNumber(env, 'LLM_MAX_TOKENS', 1024),
149
+ maxTokens: readNumber(env, 'LLM_MAX_TOKENS', 4096),
150
150
  temperature: readNumber(env, 'LLM_TEMPERATURE', 0.7),
151
151
  options: {
152
152
  profile: readString(env, 'LLM_UNIVERSAL_PROFILE'),
@@ -99,27 +99,21 @@ export class Pipeline {
99
99
  async initialize(): Promise<void> {
100
100
  if (this.initialised) return;
101
101
 
102
- // Augment system prompt with Chart/Table instructions if not already present
103
- const chartInstruction = `\n\nWhen presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
104
- - For tables: use standard Markdown tables.
105
- - For charts (bar, line, pie): You MUST output a fenced code block with the language 'chart'.
106
- - CRITICAL RULES:
107
- 1. Use ONLY valid JSON (double quotes, no trailing commas).
108
- 2. NO math expressions (e.g., use 100, NOT 50+50).
109
- 3. dataKeys MUST exactly match the property names in the data objects.
110
- 4. data objects MUST be FLAT (no nested objects or arrays).
111
- 5. DO NOT output naked JSON or markdown tables for visualizations.
112
- 6. ALWAYS wrap your visualization data in a \`\`\`chart ... \`\`\` code block.
113
- \`\`\`chart
114
- {
115
- "type": "bar" | "line" | "pie",
116
- "xAxisKey": "name",
117
- "dataKeys": ["value"],
118
- "data": [{"name": "A", "value": 10}]
119
- }
120
- \`\`\``;
121
-
122
- if (!this.config.llm.systemPrompt?.includes('chart')) {
102
+ // Augment system prompt with a Universal Visualization Protocol
103
+ const chartInstruction = `\n\n### VISUALIZATION PROTOCOL:
104
+ When requested to show data visually (charts, graphs, or comparisons), you MUST use this format:
105
+ 1. Wrap the data in a fenced code block with the language 'chart'.
106
+ 2. Use ONLY valid JSON matching this schema:
107
+ {
108
+ "type": "bar" | "line" | "pie",
109
+ "xAxisKey": "property_for_label",
110
+ "dataKeys": ["property_for_value"],
111
+ "data": [{ "property_for_label": "A", "property_for_value": 10 }]
112
+ }
113
+ 3. RULES: Data objects MUST be FLAT (no nesting). No math expressions in JSON. NEVER draw charts with text or markdown tables.`;
114
+
115
+ // Inject chart instructions if not already present (including when systemPrompt is undefined)
116
+ if (!this.config.llm.systemPrompt || !this.config.llm.systemPrompt.includes('chart')) {
123
117
  this.config.llm.systemPrompt = (this.config.llm.systemPrompt || '') + chartInstruction;
124
118
  }
125
119