Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DDL to Planner #619

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public async Task<bool> Execute(RoleDialogModel message)
};
var retrievalMessage = new RoleDialogModel(AgentRole.User, task.Requirements)
{
FunctionArgs = JsonSerializer.Serialize(msg),
FunctionArgs = JsonSerializer.Serialize(new ExtractedKnowledge
{
Question = task.Requirements
}),
KnowledgeConfidence = 0.1f,
Content = ""
};
Expand Down
24 changes: 23 additions & 1 deletion src/Plugins/BotSharp.Plugin.Planner/Functions/SummaryPlanFn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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;

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

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);
Expand All @@ -37,7 +58,8 @@ public async Task<bool> Execute(RoleDialogModel message)
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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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.