BotSharp/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs

56 lines
1.4 KiB
C#
Raw Normal View History

using BotSharp.Abstraction.Agents.Settings;
2023-09-27 20:49:44 +00:00
using BotSharp.Abstraction.Functions.Models;
2023-08-18 02:44:49 +00:00
namespace BotSharp.Abstraction.Agents;
2023-08-18 02:44:49 +00:00
public abstract class AgentHookBase : IAgentHook
{
2023-10-24 21:38:34 +00:00
public virtual string SelfId => throw new NotImplementedException("Please set SelfId as agent id!");
2023-08-18 02:44:49 +00:00
protected Agent _agent;
public Agent Agent => _agent;
protected readonly IServiceProvider _services;
protected readonly AgentSettings _settings;
2023-08-18 02:44:49 +00:00
public AgentHookBase(IServiceProvider services, AgentSettings settings)
2023-08-18 02:44:49 +00:00
{
_services = services;
_settings = settings;
2023-08-18 02:44:49 +00:00
}
public void SetAget(Agent agent)
{
_agent = agent;
}
public virtual bool OnAgentLoading(ref string id)
{
return true;
}
public virtual bool OnInstructionLoaded(string template, Dictionary<string, object> dict)
{
dict["current_date"] = $"{DateTime.Now:MMM dd, yyyy}";
dict["current_time"] = $"{DateTime.Now:hh:mm tt}";
dict["current_weekday"] = $"{DateTime.Now:dddd}";
return true;
2023-08-18 02:44:49 +00:00
}
public virtual bool OnFunctionsLoaded(List<FunctionDef> functions)
2023-08-18 02:44:49 +00:00
{
_agent.Functions = functions;
return true;
}
2023-10-19 17:24:00 +00:00
public virtual bool OnSamplesLoaded(List<string> samples)
2023-08-18 02:44:49 +00:00
{
_agent.Samples = samples;
return true;
}
public virtual void OnAgentLoaded(Agent agent)
{
}
}