BotSharp/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationHook.cs

70 lines
2.2 KiB
C#
Raw Normal View History

2023-08-14 17:00:01 +00:00
namespace BotSharp.Abstraction.Conversations;
public interface IConversationHook
{
2023-08-31 11:40:51 +00:00
int Priority { get; }
2023-08-14 17:00:01 +00:00
Agent Agent { get; }
2023-10-16 20:07:07 +00:00
List<RoleDialogModel> Dialogs { get; }
2023-08-14 17:00:01 +00:00
IConversationHook SetAgent(Agent agent);
Conversation Conversation { get; }
IConversationHook SetConversation(Conversation conversation);
/// <summary>
2023-10-16 20:07:07 +00:00
/// Triggered once for every new conversation.
/// </summary>
/// <param name="conversation"></param>
/// <returns></returns>
Task OnConversationInitialized(Conversation conversation);
/// <summary>
/// Triggered when dialog history is loaded.
2023-08-14 17:00:01 +00:00
/// </summary>
/// <param name="dialogs"></param>
/// <returns></returns>
Task OnDialogsLoaded(List<RoleDialogModel> dialogs);
Task OnStateLoaded(ConversationState state);
Task OnStateChanged(string name, string preValue, string currentValue);
2023-10-16 20:07:07 +00:00
Task OnMessageReceived(RoleDialogModel message);
/// <summary>
/// Triggered before LLM calls function.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
2023-08-14 17:00:01 +00:00
Task OnFunctionExecuting(RoleDialogModel message);
2023-10-16 20:07:07 +00:00
/// <summary>
/// Triggered when the function calling completed.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
2023-08-14 17:00:01 +00:00
Task OnFunctionExecuted(RoleDialogModel message);
2023-10-16 20:07:07 +00:00
Task OnResponseGenerated(RoleDialogModel message);
/// <summary>
/// LLM detected the current task is completed.
/// It's useful for the situation of multiple tasks in the same conversation.
/// </summary>
/// <param name="conversation"></param>
/// <returns></returns>
2023-10-23 00:31:49 +00:00
Task OnCurrentTaskEnding(RoleDialogModel message);
2023-10-16 20:07:07 +00:00
/// <summary>
/// LLM detected the whole conversation is going to be end.
/// </summary>
/// <param name="conversation"></param>
/// <returns></returns>
2023-10-23 00:31:49 +00:00
Task OnConversationEnding(RoleDialogModel message);
2023-10-16 20:07:07 +00:00
/// <summary>
/// LLM can't handle user's request or user requests human being to involve.
/// </summary>
/// <param name="conversation"></param>
/// <returns></returns>
2023-10-23 00:31:49 +00:00
Task OnHumanInterventionNeeded(RoleDialogModel message);
2023-08-14 17:00:01 +00:00
}