2023-07-19 22:30:23 +00:00
|
|
|
using BotSharp.Abstraction.Conversations.Models;
|
2023-07-21 01:55:40 +00:00
|
|
|
using BotSharp.Abstraction.MLTasks;
|
2023-07-19 22:30:23 +00:00
|
|
|
|
|
|
|
|
namespace BotSharp.Abstraction.Conversations;
|
|
|
|
|
|
2023-07-21 01:55:40 +00:00
|
|
|
public abstract class ConversationCompletionHookBase : IConversationCompletionHook
|
2023-07-19 22:30:23 +00:00
|
|
|
{
|
|
|
|
|
protected Agent _agent;
|
|
|
|
|
public Agent Agent => _agent;
|
|
|
|
|
|
|
|
|
|
protected Conversation _conversation;
|
|
|
|
|
public Conversation Conversation => _conversation;
|
|
|
|
|
|
|
|
|
|
protected List<RoleDialogModel> _dialogs;
|
|
|
|
|
public List<RoleDialogModel> Dialogs => _dialogs;
|
|
|
|
|
|
2023-07-21 01:55:40 +00:00
|
|
|
protected IChatCompletion _chatCompletion;
|
|
|
|
|
public IChatCompletion ChatCompletion => _chatCompletion;
|
|
|
|
|
|
|
|
|
|
public IConversationCompletionHook SetAgent(Agent agent)
|
2023-07-19 22:30:23 +00:00
|
|
|
{
|
|
|
|
|
_agent = agent;
|
2023-07-21 01:55:40 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConversationCompletionHook SetConversation(Conversation conversation)
|
|
|
|
|
{
|
2023-07-19 22:30:23 +00:00
|
|
|
_conversation = conversation;
|
2023-07-21 01:55:40 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConversationCompletionHook SetDialogs(List<RoleDialogModel> dialogs)
|
|
|
|
|
{
|
2023-07-19 22:30:23 +00:00
|
|
|
_dialogs = dialogs;
|
2023-07-21 01:55:40 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConversationCompletionHook SetChatCompletion(IChatCompletion chatCompletion)
|
|
|
|
|
{
|
|
|
|
|
_chatCompletion = chatCompletion;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-10 22:17:55 +00:00
|
|
|
public virtual Task OnStateLoaded(ConversationState state, Action<Agent>? onAgentSwitched = null)
|
2023-08-09 21:49:55 +00:00
|
|
|
{
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 01:55:40 +00:00
|
|
|
public virtual Task BeforeCompletion()
|
|
|
|
|
{
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 18:22:07 +00:00
|
|
|
public virtual Task OnFunctionExecuting(string name, string args)
|
2023-07-27 21:56:57 +00:00
|
|
|
{
|
2023-07-30 18:22:07 +00:00
|
|
|
return Task.CompletedTask;
|
2023-07-27 21:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 15:07:39 +00:00
|
|
|
public virtual Task AfterCompletion(RoleDialogModel message)
|
2023-07-21 01:55:40 +00:00
|
|
|
{
|
2023-07-27 15:07:39 +00:00
|
|
|
return Task.CompletedTask;
|
2023-07-19 22:30:23 +00:00
|
|
|
}
|
|
|
|
|
}
|