Merge pull request #857 from iceljc/features/refine-agent-filter

Features/refine agent filter
This commit is contained in:
iceljc 2025-01-30 16:46:54 -06:00 committed by GitHub
commit 964de973fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,21 +22,22 @@ public class ReadImageFn : IFunctionCallback
var conv = _services.GetRequiredService<IConversationService>();
var agentService = _services.GetRequiredService<IAgentService>();
Agent? fromAgent = null;
if (!string.IsNullOrEmpty(message.CurrentAgentId))
{
fromAgent = await agentService.LoadAgent(message.CurrentAgentId);
}
var wholeDialogs = conv.GetDialogHistory();
var dialogs = AssembleFiles(conv.ConversationId, args?.ImageUrls, wholeDialogs);
var agent = new Agent
{
Id = BuiltInAgentId.UtilityAssistant,
Name = "Utility Agent",
Instruction = !string.IsNullOrWhiteSpace(args?.UserRequest) ? args.UserRequest : "Please describe the image(s).",
Instruction = fromAgent?.Instruction ?? args.UserRequest ?? "Please describe the image(s).",
TemplateDict = new Dictionary<string, object>()
};
if (!string.IsNullOrEmpty(message.CurrentAgentId))
{
agent = await agentService.LoadAgent(message.CurrentAgentId, loadUtility: false);
}
var response = await GetChatCompletion(agent, dialogs);
message.Content = response;
return true;