@retrivora-ai/rag-engine 1.2.2 → 1.2.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.
@@ -1692,11 +1692,30 @@ Sources Used: ${JSON.stringify(
1692
1692
  )}`;
1693
1693
  }
1694
1694
  });
1695
+ const defaultAgentPrompt = "You are a helpful AI assistant with access to a document search tool.";
1696
+ let finalSystemPrompt = this.config.llm.systemPrompt || defaultAgentPrompt;
1697
+ const chartInstruction = `
1698
+
1699
+ When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
1700
+ - For tables: use standard Markdown tables.
1701
+ - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
1702
+ - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
1703
+ \`\`\`chart
1704
+ {
1705
+ "type": "bar" | "line" | "pie",
1706
+ "xAxisKey": "name",
1707
+ "dataKeys": ["value"],
1708
+ "data": [{"name": "A", "value": 10}]
1709
+ }
1710
+ \`\`\``;
1711
+ if (!finalSystemPrompt.includes("chart")) {
1712
+ finalSystemPrompt += chartInstruction;
1713
+ }
1695
1714
  this.agent = createAgent({
1696
1715
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1697
1716
  model: chatModel,
1698
1717
  tools: [searchTool],
1699
- systemPrompt: this.config.llm.systemPrompt || "You are a helpful AI assistant with access to a document search tool."
1718
+ systemPrompt: finalSystemPrompt
1700
1719
  });
1701
1720
  void HumanMessage;
1702
1721
  } catch (error) {
@@ -2231,8 +2250,25 @@ var Pipeline = class {
2231
2250
  this.reranker = new Reranker();
2232
2251
  }
2233
2252
  async initialize() {
2234
- var _a;
2253
+ var _a, _b;
2235
2254
  if (this.initialised) return;
2255
+ const chartInstruction = `
2256
+
2257
+ When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
2258
+ - For tables: use standard Markdown tables.
2259
+ - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
2260
+ - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
2261
+ \`\`\`chart
2262
+ {
2263
+ "type": "bar" | "line" | "pie",
2264
+ "xAxisKey": "name",
2265
+ "dataKeys": ["value"],
2266
+ "data": [{"name": "A", "value": 10}]
2267
+ }
2268
+ \`\`\``;
2269
+ if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes("chart"))) {
2270
+ this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
2271
+ }
2236
2272
  console.log(`[Pipeline] Initializing with provider: ${this.config.vectorDb.provider}...`);
2237
2273
  this.vectorDB = await ProviderRegistry.createVectorProvider(this.config.vectorDb);
2238
2274
  const { llmProvider, embeddingProvider } = await EmbeddingStrategyResolver.resolve(
@@ -2247,7 +2283,7 @@ var Pipeline = class {
2247
2283
  this.entityExtractor = new EntityExtractor(this.llmProvider);
2248
2284
  }
2249
2285
  await this.vectorDB.initialize();
2250
- if (((_a = this.config.rag) == null ? void 0 : _a.architecture) === "agentic") {
2286
+ if (((_b = this.config.rag) == null ? void 0 : _b.architecture) === "agentic") {
2251
2287
  this.agent = new LangChainAgent(this, this.config);
2252
2288
  await this.agent.initialize(this.llmProvider);
2253
2289
  }
@@ -3261,11 +3261,30 @@ Sources Used: ${JSON.stringify(
3261
3261
  )}`;
3262
3262
  }
3263
3263
  });
3264
+ const defaultAgentPrompt = "You are a helpful AI assistant with access to a document search tool.";
3265
+ let finalSystemPrompt = this.config.llm.systemPrompt || defaultAgentPrompt;
3266
+ const chartInstruction = `
3267
+
3268
+ When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3269
+ - For tables: use standard Markdown tables.
3270
+ - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
3271
+ - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
3272
+ \`\`\`chart
3273
+ {
3274
+ "type": "bar" | "line" | "pie",
3275
+ "xAxisKey": "name",
3276
+ "dataKeys": ["value"],
3277
+ "data": [{"name": "A", "value": 10}]
3278
+ }
3279
+ \`\`\``;
3280
+ if (!finalSystemPrompt.includes("chart")) {
3281
+ finalSystemPrompt += chartInstruction;
3282
+ }
3264
3283
  this.agent = createAgent({
3265
3284
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3266
3285
  model: chatModel,
3267
3286
  tools: [searchTool],
3268
- systemPrompt: this.config.llm.systemPrompt || "You are a helpful AI assistant with access to a document search tool."
3287
+ systemPrompt: finalSystemPrompt
3269
3288
  });
3270
3289
  void HumanMessage;
3271
3290
  } catch (error) {
@@ -3794,8 +3813,25 @@ var Pipeline = class {
3794
3813
  this.reranker = new Reranker();
3795
3814
  }
3796
3815
  async initialize() {
3797
- var _a;
3816
+ var _a, _b;
3798
3817
  if (this.initialised) return;
3818
+ const chartInstruction = `
3819
+
3820
+ When presenting structured data, statistics, or comparisons, decide if it is best presented as a table or a chart.
3821
+ - For tables: use standard Markdown tables.
3822
+ - For charts (bar, line, pie): Output a JSON code block with language 'chart'.
3823
+ - CRITICAL: Use ONLY valid JSON (double quotes, no trailing commas).
3824
+ \`\`\`chart
3825
+ {
3826
+ "type": "bar" | "line" | "pie",
3827
+ "xAxisKey": "name",
3828
+ "dataKeys": ["value"],
3829
+ "data": [{"name": "A", "value": 10}]
3830
+ }
3831
+ \`\`\``;
3832
+ if (!((_a = this.config.llm.systemPrompt) == null ? void 0 : _a.includes("chart"))) {
3833
+ this.config.llm.systemPrompt = (this.config.llm.systemPrompt || "") + chartInstruction;
3834
+ }
3799
3835
  console.log(`[Pipeline] Initializing with provider: ${this.config.vectorDb.provider}...`);
3800
3836
  this.vectorDB = await ProviderRegistry.createVectorProvider(this.config.vectorDb);
3801
3837
  const { llmProvider, embeddingProvider } = await EmbeddingStrategyResolver.resolve(
@@ -3810,7 +3846,7 @@ var Pipeline = class {
3810
3846
  this.entityExtractor = new EntityExtractor(this.llmProvider);
3811
3847
  }
3812
3848
  await this.vectorDB.initialize();
3813
- if (((_a = this.config.rag) == null ? void 0 : _a.architecture) === "agentic") {
3849
+ if (((_b = this.config.rag) == null ? void 0 : _b.architecture) === "agentic") {
3814
3850
  this.agent = new LangChainAgent(this, this.config);
3815
3851
  await this.agent.initialize(this.llmProvider);
3816
3852
  }
@@ -9,7 +9,7 @@ import {
9
9
  sseFrame,
10
10
  sseMetaFrame,
11
11
  sseTextFrame
12
- } from "../chunk-GCPPRD2G.mjs";
12
+ } from "../chunk-X4TMJV23.mjs";
13
13
  import "../chunk-YLTMFW4M.mjs";
14
14
  import "../chunk-X4TOT24V.mjs";
15
15
  export {