Merge pull request #775 from hchen2020/master

Fix duplicate function loaded OnAgentUtilityLoaded
This commit is contained in:
Haiping 2024-12-03 19:58:53 +00:00 committed by GitHub
commit b23cd20b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,7 +71,14 @@ public abstract class AgentHookBase : IAgentHook
var (functions, templates) = GetUtilityContent(agent);
agent.Functions.AddRange(functions);
foreach (var fn in functions)
{
if (!agent.Functions.Any(x => x.Name.Equals(fn.Name, StringComparison.OrdinalIgnoreCase)))
{
agent.Functions.Add(fn);
}
}
foreach (var prompt in templates)
{
agent.Instruction += $"\r\n\r\n{prompt}\r\n\r\n";