Skip to content

Commit d7ef99d

Browse files
committed
Render assistant role as specific agent name.
1 parent 9356cb6 commit d7ef99d

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetNextInstruction.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,24 @@ public async Task<FunctionCallFromLlm> GetNextInstruction()
5656
model: _settings.Model);
5757

5858
int retryCount = 0;
59+
var agentService = _services.GetRequiredService<IAgentService>();
5960

6061
while (retryCount < 3)
6162
{
6263
try
6364
{
6465
var conversation = "";
66+
6567
foreach (var dialog in _dialogs.TakeLast(20))
6668
{
67-
conversation += $"{dialog.Role}: {dialog.Content}\r\n";
69+
var role = dialog.Role;
70+
if (role != AgentRole.User)
71+
{
72+
var agent = await agentService.GetAgent(dialog.CurrentAgentId);
73+
role = agent.Name;
74+
}
75+
76+
conversation += $"{role}: {dialog.Content}\r\n";
6877
}
6978
content = $"{conversation}\r\n###\r\n{content}";
7079

src/WebStarter/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instruction.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ You're {{router.name}} ({{router.description}}). Follow these steps to handle us
33
2. Select a appropriate function from [FUNCTIONS].
44
3. Determine which agent is suitable to handle this conversation.
55
4. Re-think about the selected function or agent is the best choice.
6-
5. For agent required arguments, leave it blank if user doesn't provide it.
6+
5. For agent required arguments, leave it as blank object if user doesn't provide it.
77

88
[FUNCTIONS]
99
{% for handler in routing_handlers %}

0 commit comments

Comments
 (0)