From 59414543f622e15bdc2ca8e78ed4f4abea64d5fe Mon Sep 17 00:00:00 2001 From: Joanna Ren <101223@smsassist.com> Date: Tue, 2 Sep 2025 18:24:00 -0500 Subject: [PATCH 1/2] add business intelligence agent --- .../Functions/PlotChartFn.cs | 6 ++++- .../util-chart-plot_instruction.liquid | 23 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs b/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs index 40277297a..ae8e7fdc2 100644 --- a/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs +++ b/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs @@ -33,6 +33,10 @@ public async Task Execute(RoleDialogModel message) Id = agent.Id, Name = agent.Name, Instruction = inst, + LlmConfig = new AgentLlmConfig + { + MaxOutputTokens = 8192 + }, TemplateDict = new Dictionary { { "plotting_requirement", args?.PlottingRequirement ?? string.Empty }, @@ -48,7 +52,7 @@ public async Task Execute(RoleDialogModel message) } ]); - var obj = response.JsonContent(); + var obj = response.JsonContent(); message.Content = obj?.GreetingMessage ?? "Here is the chart you ask for:"; message.RichContent = new RichContent { diff --git a/src/Plugins/BotSharp.Plugin.ChartHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-chart-plot_instruction.liquid b/src/Plugins/BotSharp.Plugin.ChartHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-chart-plot_instruction.liquid index 9bffa73f0..0d631b51d 100644 --- a/src/Plugins/BotSharp.Plugin.ChartHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-chart-plot_instruction.liquid +++ b/src/Plugins/BotSharp.Plugin.ChartHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-chart-plot_instruction.liquid @@ -1,18 +1,27 @@ Please take a look at "Plotting Requirement" and generate a javascript code that can be used to render the charts on an html element. - === Plotting Requirement === {{ plotting_requirement }} - -***** Important ***** -** Your output must be a single block with everything needed inside. -** You need to import Plotly.js to plot the charts. The script source should be "https://cdn.plot.ly/plotly-3.0.1.min.js". +***** Hard Requirements ***** +** Your output javascript code must be wrapped in one or multiple blocks with everything needed inside. +** You need to import ECharts.js to plot the charts. The script source is "https://cdnjs.cloudflare.com/ajax/libs/echarts/6.0.0/echarts.min.js". ** You need to add the MODE bar for each chart you plot. -** You must render the charts on the div html element with id {{ chart_element_id }}. +** You must render the charts under the div html element with id {{ chart_element_id }}. +** Add a custom mode bar button named "Fullscreen" that toggles the chart container in and out of fullscreen using the Fullscreen API. Requirements for this button: + * Always call the Fullscreen API on the chart container div itself (document.getElementById("{{ chart_element_id }}")), not on the document or on Plotly’s SVG. + * Use el.requestFullscreen() with fallbacks to el.webkitRequestFullscreen || el.msRequestFullscreen. + * Exit fullscreen with document.exitFullscreen() and vendor fallbacks. + * Listen for fullscreenchange, webkitfullscreenchange, and msfullscreenchange to keep the button working across repeated clicks and ESC exits. + * Ensure the chart fully expands and scales to the entire screen when fullscreen is active. + * Provide a simple inline SVG path icon for the button (no external assets). + * Use Plotly.newPlot(container, data, layout, {displayModeBar:true, modeBarButtonsToAdd:[fullscreenBtn]}); + * fullscreenBtn must be a fully-formed object {name, title, icon, click}. ** You must not create any new html element. ** You must not apply any styles on any html element. -** You must generate as less token as possible. +** Keep code compact (few tokens), but fix all errors before returning. +** Do not generate charts with zero height and zero width. +** Please ensure the code can be executed and the charts are rendered correctly. *** Response Format *** You must output the response in the following JSON format: From 7c2ed704ab46783ccb0f37b0a1be5c528acebb3d Mon Sep 17 00:00:00 2001 From: Joanna Ren Date: Tue, 2 Sep 2025 18:27:33 -0500 Subject: [PATCH 2/2] Update PlotChartFn.cs --- .../BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs b/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs index ae8e7fdc2..8958ecca8 100644 --- a/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs +++ b/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs @@ -52,7 +52,7 @@ public async Task Execute(RoleDialogModel message) } ]); - var obj = response.JsonContent(); + var obj = response.JsonContent(); message.Content = obj?.GreetingMessage ?? "Here is the chart you ask for:"; message.RichContent = new RichContent {