2
2
using BotSharp . Abstraction . Planning ;
3
3
using BotSharp . Abstraction . Routing . Enums ;
4
4
using BotSharp . Abstraction . Routing . Reasoning ;
5
- using BotSharp . Core . Routing . Reasoning ;
6
5
7
6
namespace BotSharp . Core . Routing ;
8
7
@@ -21,7 +20,7 @@ public async Task<RoleDialogModel> InstructLoop(RoleDialogModel message, List<Ro
21
20
var states = _services . GetRequiredService < IConversationStateService > ( ) ;
22
21
var executor = _services . GetRequiredService < IExecutor > ( ) ;
23
22
24
- var planner = GetReasoner ( _router ) ;
23
+ var reasoner = GetReasoner ( _router ) ;
25
24
26
25
_context . Push ( _router . Id ) ;
27
26
@@ -46,7 +45,7 @@ public async Task<RoleDialogModel> InstructLoop(RoleDialogModel message, List<Ro
46
45
47
46
// Get first instruction
48
47
_router . TemplateDict [ "conversation" ] = await GetConversationContent ( dialogs ) ;
49
- var inst = await planner . GetNextInstruction ( _router , message . MessageId , dialogs ) ;
48
+ var inst = await reasoner . GetNextInstruction ( _router , message . MessageId , dialogs ) ;
50
49
51
50
int loopCount = 1 ;
52
51
while ( true )
@@ -63,30 +62,30 @@ await hook.OnRoutingInstructionReceived(inst, message)
63
62
#else
64
63
_logger . LogInformation ( $ "*** Next Instruction *** { inst } ") ;
65
64
#endif
66
- await planner . AgentExecuting ( _router , inst , message , dialogs ) ;
65
+ await reasoner . AgentExecuting ( _router , inst , message , dialogs ) ;
67
66
68
67
// Handover to Task Agent
69
68
if ( inst . HandleDialogsByPlanner )
70
69
{
71
- var dialogWithoutContext = planner . BeforeHandleContext ( inst , message , dialogs ) ;
70
+ var dialogWithoutContext = reasoner . BeforeHandleContext ( inst , message , dialogs ) ;
72
71
response = await executor . Execute ( this , inst , message , dialogWithoutContext ) ;
73
- planner . AfterHandleContext ( dialogs , dialogWithoutContext ) ;
72
+ reasoner . AfterHandleContext ( dialogs , dialogWithoutContext ) ;
74
73
}
75
74
else
76
75
{
77
76
response = await executor . Execute ( this , inst , message , dialogs ) ;
78
77
}
79
78
80
- await planner . AgentExecuted ( _router , inst , response , dialogs ) ;
79
+ await reasoner . AgentExecuted ( _router , inst , response , dialogs ) ;
81
80
82
- if ( loopCount >= planner . MaxLoopCount || _context . IsEmpty )
81
+ if ( loopCount >= reasoner . MaxLoopCount || _context . IsEmpty )
83
82
{
84
83
break ;
85
84
}
86
85
87
86
// Get next instruction from Planner
88
87
_router . TemplateDict [ "conversation" ] = await GetConversationContent ( dialogs ) ;
89
- inst = await planner . GetNextInstruction ( _router , message . MessageId , dialogs ) ;
88
+ inst = await reasoner . GetNextInstruction ( _router , message . MessageId , dialogs ) ;
90
89
loopCount ++ ;
91
90
}
92
91
@@ -103,8 +102,7 @@ public IRoutingReasoner GetReasoner(Agent router)
103
102
return _services . GetServices < IRoutingReasoner > ( ) . First ( x => x . Name == "Naive Reasoner" ) ;
104
103
}
105
104
106
- var reasoner = _services . GetServices < IRoutingReasoner > ( ) .
107
- FirstOrDefault ( x => x . GetType ( ) . Name . EndsWith ( rule . Field ) ) ;
105
+ var reasoner = _services . GetServices < IRoutingReasoner > ( ) . FirstOrDefault ( x => x . GetType ( ) . Name . EndsWith ( rule . Field ) ) ;
108
106
109
107
if ( reasoner == null )
110
108
{
0 commit comments