Skip to content

Commit 964de97

Browse files
authored
Merge pull request #857 from iceljc/features/refine-agent-filter
Features/refine agent filter
2 parents 7c53833 + 1acee2b commit 964de97

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ public async Task<bool> Execute(RoleDialogModel message)
2222
var conv = _services.GetRequiredService<IConversationService>();
2323
var agentService = _services.GetRequiredService<IAgentService>();
2424

25+
Agent? fromAgent = null;
26+
if (!string.IsNullOrEmpty(message.CurrentAgentId))
27+
{
28+
fromAgent = await agentService.LoadAgent(message.CurrentAgentId);
29+
}
30+
2531
var wholeDialogs = conv.GetDialogHistory();
2632
var dialogs = AssembleFiles(conv.ConversationId, args?.ImageUrls, wholeDialogs);
2733
var agent = new Agent
2834
{
2935
Id = BuiltInAgentId.UtilityAssistant,
3036
Name = "Utility Agent",
31-
Instruction = !string.IsNullOrWhiteSpace(args?.UserRequest) ? args.UserRequest : "Please describe the image(s).",
37+
Instruction = fromAgent?.Instruction ?? args.UserRequest ?? "Please describe the image(s).",
3238
TemplateDict = new Dictionary<string, object>()
3339
};
3440

35-
if (!string.IsNullOrEmpty(message.CurrentAgentId))
36-
{
37-
agent = await agentService.LoadAgent(message.CurrentAgentId, loadUtility: false);
38-
}
39-
4041
var response = await GetChatCompletion(agent, dialogs);
4142
message.Content = response;
4243
return true;

0 commit comments

Comments
 (0)