commit
0e156c319a
|
|
@ -39,7 +39,10 @@ public class PrimaryStagePlanFn : IFunctionCallback
|
|||
};
|
||||
var retrievalMessage = new RoleDialogModel(AgentRole.User, task.Requirements)
|
||||
{
|
||||
FunctionArgs = JsonSerializer.Serialize(msg),
|
||||
FunctionArgs = JsonSerializer.Serialize(new ExtractedKnowledge
|
||||
{
|
||||
Question = task.Requirements
|
||||
}),
|
||||
KnowledgeConfidence = 0.1f,
|
||||
Content = ""
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using System.Threading.Tasks;
|
|||
using BotSharp.Core.Infrastructures;
|
||||
using BotSharp.Plugin.Planner.TwoStaging.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using BotSharp.Abstraction.Routing;
|
||||
using BotSharp.Core.Agents.Services;
|
||||
|
||||
namespace BotSharp.Plugin.Planner.Functions;
|
||||
|
||||
|
|
@ -23,12 +25,31 @@ public class SummaryPlanFn : IFunctionCallback
|
|||
|
||||
public async Task<bool> Execute(RoleDialogModel message)
|
||||
{
|
||||
var fn = _services.GetRequiredService<IRoutingService>();
|
||||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
var currentAgent = await agentService.LoadAgent(message.CurrentAgentId);
|
||||
//debug
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
state.SetState("max_tokens", "4096");
|
||||
|
||||
var task = state.GetState("requirement_detail");
|
||||
|
||||
//get DDL
|
||||
var steps = message.Content.JsonArrayContent<SecondStagePlan>();
|
||||
|
||||
//get all the related tables
|
||||
List<string> allTables = new List<string>();
|
||||
foreach (var step in steps)
|
||||
{
|
||||
allTables.AddRange(step.Tables);
|
||||
}
|
||||
message.Data = allTables.Distinct().ToList();
|
||||
|
||||
//get table DDL and stores in content
|
||||
var msg2 = RoleDialogModel.From(message);
|
||||
await fn.InvokeFunction("get_table_definition", msg2);
|
||||
message.SecondaryContent = msg2.Content;
|
||||
|
||||
// summarize and generate query
|
||||
var summaryPlanningPrompt = await GetPlanSummaryPrompt(task, message);
|
||||
_logger.LogInformation(summaryPlanningPrompt);
|
||||
|
|
@ -37,7 +58,8 @@ public class SummaryPlanFn : IFunctionCallback
|
|||
Id = BuiltInAgentId.Planner,
|
||||
Name = "planner_summary",
|
||||
Instruction = summaryPlanningPrompt,
|
||||
TemplateDict = new Dictionary<string, object>()
|
||||
TemplateDict = new Dictionary<string, object>(),
|
||||
LlmConfig = currentAgent.LlmConfig
|
||||
};
|
||||
var response_summary = await GetAIResponse(plannerAgent);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
Use the TwoStagePlanner approach to plan the overall implementation steps, call plan_primary_stage.
|
||||
If need_additional_information is true, call plan_secondary_stage for the specific primary stage.
|
||||
Call plan_summary to summarize the final planning steps.
|
||||
You must Call plan_summary as the last step to summarize the final planning steps.
|
||||
Loading…
Reference in a new issue