This commit is contained in:
songguo.zeng 2024-12-12 18:02:00 +08:00
parent 7f6845b268
commit 8d8fd758d9
3 changed files with 1 additions and 27 deletions

View file

@ -56,9 +56,4 @@ public abstract class AgentHookBase : IAgentHook
public virtual void OnAgentUtilityLoaded(Agent agent)
{
}
public virtual void OnAgentLoadFilter(Agent agent)
{
}
}

View file

@ -33,6 +33,4 @@ public interface IAgentHook
/// <param name="agent"></param>
/// <returns></returns>
void OnAgentLoaded(Agent agent);
void OnAgentLoadFilter(Agent agent);
}

View file

@ -7,6 +7,7 @@ public partial class AgentService
{
public static ConcurrentDictionary<string, Dictionary<string, string>> AgentParameterTypes = new();
[MemoryCache(10 * 60, perInstanceCache: true)]
public async Task<Agent> LoadAgent(string id)
{
if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString())
@ -14,26 +15,6 @@ public partial class AgentService
return null;
}
Agent agent = await GetLoadAgent(id);
OnAgentLoadFilter(agent);
return agent;
}
private void OnAgentLoadFilter(Agent? agent)
{
if (agent != null && agent.Type == AgentType.Routing)
{
var hooks = _services.GetServices<IAgentHook>();
foreach (var hook in hooks)
{
hook.OnAgentLoadFilter(agent);
}
}
}
[MemoryCache(10 * 60, perInstanceCache: true)]
private async Task<Agent> GetLoadAgent(string id)
{
var hooks = _services.GetServices<IAgentHook>();
// Before agent is loaded.