From abfc7a8b0fd8ee85cf284f45a2010aefc24d622f Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Thu, 28 Aug 2025 17:16:16 -0500 Subject: [PATCH 1/5] refine chart plot instruction --- .../templates/util-chart-plot_instruction.liquid | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 9bffa73f..dc4523f8 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,26 @@ 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 ***** +***** Hard Requirements ***** ** 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". ** 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 }}. +** 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. +** Please fix any code errors before returning the final response. *** Response Format *** You must output the response in the following JSON format: From 3d07fa54f41b11ccebb7b80e3b477f77b9ca0a22 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Sun, 31 Aug 2025 20:43:45 -0500 Subject: [PATCH 2/5] fix potential null reference --- src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs index cd14e375..736ed29f 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs +++ b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs @@ -230,8 +230,13 @@ public class QdrantDb : IVectorDb { foreach (var item in payload) { + if (item.Value == null) + { + continue; + } + var value = item.Value.DataValue?.ConvertToString(); - if (value == null || item.Key.IsEqualTo(KnowledgePayloadName.Text)) + if (string.IsNullOrEmpty(value) || item.Key.IsEqualTo(KnowledgePayloadName.Text)) { continue; } From 690590f60e45794f6e10b53001baf898dd39e0af Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Sun, 31 Aug 2025 20:44:40 -0500 Subject: [PATCH 3/5] minor change --- src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs index 736ed29f..2ffbdb53 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs +++ b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs @@ -230,13 +230,13 @@ public class QdrantDb : IVectorDb { foreach (var item in payload) { - if (item.Value == null) + if (item.Value == null || item.Key.IsEqualTo(KnowledgePayloadName.Text)) { continue; } var value = item.Value.DataValue?.ConvertToString(); - if (string.IsNullOrEmpty(value) || item.Key.IsEqualTo(KnowledgePayloadName.Text)) + if (string.IsNullOrEmpty(value)) { continue; } From a03bb4b00b37d973b4a5b85c73815ab0f687d12b Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Tue, 2 Sep 2025 11:52:20 -0500 Subject: [PATCH 4/5] refine chart plot template --- .../Functions/PlotChartFn.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs b/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs index 40277297..20047b76 100644 --- a/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs +++ b/src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs @@ -21,13 +21,13 @@ public class PlotChartFn : IFunctionCallback public async Task Execute(RoleDialogModel message) { - var db = _services.GetRequiredService(); var agentService = _services.GetRequiredService(); var convService = _services.GetRequiredService(); var args = JsonSerializer.Deserialize(message.FunctionArgs); + var agent = await agentService.GetAgent(message.CurrentAgentId); - var inst = db.GetAgentTemplate(BuiltInAgentId.UtilityAssistant, "util-chart-plot_instruction"); + var inst = GetChartPlotInstruction(message.CurrentAgentId); var innerAgent = new Agent { Id = agent.Id, @@ -80,6 +80,27 @@ public class PlotChartFn : IFunctionCallback } } + private string GetChartPlotInstruction(string agentId) + { + var db = _services.GetRequiredService(); + var state = _services.GetRequiredService(); + + var templateContent = string.Empty; + var templateName = state.GetState("chart_plot_template"); + + if (!string.IsNullOrEmpty(templateName)) + { + templateContent = db.GetAgentTemplate(agentId, templateName); + } + else + { + templateName = "util-chart-plot_instruction"; + templateContent = db.GetAgentTemplate(BuiltInAgentId.UtilityAssistant, templateName); + } + + return templateContent; + } + private (string, string) GetLlmProviderModel() { var provider = "openai"; From 877fc3ece644ea9efd7004ef28cea838d979b4f0 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Tue, 2 Sep 2025 16:59:49 -0500 Subject: [PATCH 5/5] temp model for image reading --- .../BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs | 7 +++---- .../BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs index f8a0f593..2e30929e 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs @@ -98,10 +98,9 @@ public class ReadImageFn : IFunctionCallback { try { - var llmProviderService = _services.GetRequiredService(); - var provider = llmProviderService.GetProviders().FirstOrDefault(x => x == "openai"); - var model = llmProviderService.GetProviderModel(provider: provider, id: "gpt-4o", multiModal: true); - var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model.Name); + var provider = "openai"; + var model = "gpt-5-mini"; + var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model); var response = await completion.GetChatCompletions(agent, dialogs); return response.Content; } diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs index ab8ab8a9..7436fce5 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs @@ -89,10 +89,9 @@ public class ReadPdfFn : IFunctionCallback { try { - var llmProviderService = _services.GetRequiredService(); - var provider = llmProviderService.GetProviders().FirstOrDefault(x => x == "openai"); - var model = llmProviderService.GetProviderModel(provider: provider, id: "gpt-4o", multiModal: true); - var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model.Name); + var provider = "openai"; + var model = "gpt-5-mini"; + var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model); var response = await completion.GetChatCompletions(agent, dialogs); return response.Content; }