Merge pull request #1142 from iceljc/master

refine chart plot template
This commit is contained in:
iceljc 2025-09-02 11:53:46 -05:00 committed by GitHub
commit f661a39dd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,13 +21,13 @@ public class PlotChartFn : IFunctionCallback
public async Task<bool> Execute(RoleDialogModel message) public async Task<bool> Execute(RoleDialogModel message)
{ {
var db = _services.GetRequiredService<IBotSharpRepository>();
var agentService = _services.GetRequiredService<IAgentService>(); var agentService = _services.GetRequiredService<IAgentService>();
var convService = _services.GetRequiredService<IConversationService>(); var convService = _services.GetRequiredService<IConversationService>();
var args = JsonSerializer.Deserialize<LlmContextIn>(message.FunctionArgs); var args = JsonSerializer.Deserialize<LlmContextIn>(message.FunctionArgs);
var agent = await agentService.GetAgent(message.CurrentAgentId); 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 var innerAgent = new Agent
{ {
Id = agent.Id, Id = agent.Id,
@ -80,6 +80,27 @@ public class PlotChartFn : IFunctionCallback
} }
} }
private string GetChartPlotInstruction(string agentId)
{
var db = _services.GetRequiredService<IBotSharpRepository>();
var state = _services.GetRequiredService<IConversationStateService>();
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() private (string, string) GetLlmProviderModel()
{ {
var provider = "openai"; var provider = "openai";