5
5
using BotSharp . Core . Infrastructures ;
6
6
using BotSharp . Plugin . Planner . TwoStaging . Models ;
7
7
using Microsoft . Extensions . Logging ;
8
+ using BotSharp . Abstraction . Routing ;
9
+ using BotSharp . Core . Agents . Services ;
8
10
9
11
namespace BotSharp . Plugin . Planner . Functions ;
10
12
@@ -23,12 +25,31 @@ public SummaryPlanFn(IServiceProvider services, ILogger<PrimaryStagePlanFn> logg
23
25
24
26
public async Task < bool > Execute ( RoleDialogModel message )
25
27
{
28
+ var fn = _services . GetRequiredService < IRoutingService > ( ) ;
29
+ var agentService = _services . GetRequiredService < IAgentService > ( ) ;
30
+ var currentAgent = await agentService . LoadAgent ( message . CurrentAgentId ) ;
26
31
//debug
27
32
var state = _services . GetRequiredService < IConversationStateService > ( ) ;
28
33
state . SetState ( "max_tokens" , "4096" ) ;
29
34
30
35
var task = state . GetState ( "requirement_detail" ) ;
31
36
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
+
32
53
// summarize and generate query
33
54
var summaryPlanningPrompt = await GetPlanSummaryPrompt ( task , message ) ;
34
55
_logger . LogInformation ( summaryPlanningPrompt ) ;
@@ -37,7 +58,8 @@ public async Task<bool> Execute(RoleDialogModel message)
37
58
Id = BuiltInAgentId . Planner ,
38
59
Name = "planner_summary" ,
39
60
Instruction = summaryPlanningPrompt ,
40
- TemplateDict = new Dictionary < string , object > ( )
61
+ TemplateDict = new Dictionary < string , object > ( ) ,
62
+ LlmConfig = currentAgent . LlmConfig
41
63
} ;
42
64
var response_summary = await GetAIResponse ( plannerAgent ) ;
43
65
0 commit comments