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