Skip to content

Commit 0e156c3

Browse files
authored
Merge pull request #619 from Joannall/master
add DDL to Planner
2 parents 1926914 + 9e2d280 commit 0e156c3

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/Plugins/BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public async Task<bool> Execute(RoleDialogModel message)
3939
};
4040
var retrievalMessage = new RoleDialogModel(AgentRole.User, task.Requirements)
4141
{
42-
FunctionArgs = JsonSerializer.Serialize(msg),
42+
FunctionArgs = JsonSerializer.Serialize(new ExtractedKnowledge
43+
{
44+
Question = task.Requirements
45+
}),
4346
KnowledgeConfidence = 0.1f,
4447
Content = ""
4548
};

src/Plugins/BotSharp.Plugin.Planner/Functions/SummaryPlanFn.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using BotSharp.Core.Infrastructures;
66
using BotSharp.Plugin.Planner.TwoStaging.Models;
77
using Microsoft.Extensions.Logging;
8+
using BotSharp.Abstraction.Routing;
9+
using BotSharp.Core.Agents.Services;
810

911
namespace BotSharp.Plugin.Planner.Functions;
1012

@@ -23,12 +25,31 @@ public SummaryPlanFn(IServiceProvider services, ILogger<PrimaryStagePlanFn> logg
2325

2426
public async Task<bool> Execute(RoleDialogModel message)
2527
{
28+
var fn = _services.GetRequiredService<IRoutingService>();
29+
var agentService = _services.GetRequiredService<IAgentService>();
30+
var currentAgent = await agentService.LoadAgent(message.CurrentAgentId);
2631
//debug
2732
var state = _services.GetRequiredService<IConversationStateService>();
2833
state.SetState("max_tokens", "4096");
2934

3035
var task = state.GetState("requirement_detail");
3136

37+
//get DDL
38+
var steps = message.Content.JsonArrayContent<SecondStagePlan>();
39+
40+
//get all the related tables
41+
List<string> allTables = new List<string>();
42+
foreach (var step in steps)
43+
{
44+
allTables.AddRange(step.Tables);
45+
}
46+
message.Data = allTables.Distinct().ToList();
47+
48+
//get table DDL and stores in content
49+
var msg2 = RoleDialogModel.From(message);
50+
await fn.InvokeFunction("get_table_definition", msg2);
51+
message.SecondaryContent = msg2.Content;
52+
3253
// summarize and generate query
3354
var summaryPlanningPrompt = await GetPlanSummaryPrompt(task, message);
3455
_logger.LogInformation(summaryPlanningPrompt);
@@ -37,7 +58,8 @@ public async Task<bool> Execute(RoleDialogModel message)
3758
Id = BuiltInAgentId.Planner,
3859
Name = "planner_summary",
3960
Instruction = summaryPlanningPrompt,
40-
TemplateDict = new Dictionary<string, object>()
61+
TemplateDict = new Dictionary<string, object>(),
62+
LlmConfig = currentAgent.LlmConfig
4163
};
4264
var response_summary = await GetAIResponse(plannerAgent);
4365

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Use the TwoStagePlanner approach to plan the overall implementation steps, call plan_primary_stage.
22
If need_additional_information is true, call plan_secondary_stage for the specific primary stage.
3-
Call plan_summary to summarize the final planning steps.
3+
You must Call plan_summary as the last step to summarize the final planning steps.

0 commit comments

Comments
 (0)