BotSharp/docs/architecture/hooks.md

35 lines
1.1 KiB
Markdown
Raw Normal View History

2023-08-19 13:25:47 +00:00
# Hooks
`Hook` is a place in `BotSharp` that allows you to tap in to a module to either provide different behavior or to react.
## Agent Hook
`IAgentHook`
```csharp
bool OnAgentLoading(ref string id);
bool OnInstructionLoaded(string template, Dictionary<string, object> dict);
bool OnFunctionsLoaded(List<FunctionDef> functions);
2023-08-19 13:25:47 +00:00
bool OnSamplesLoaded(ref string samples);
Agent OnAgentLoaded();
```
More information about agent hook please go to [Agent Hook](../agent/hook.md).
2023-08-19 13:25:47 +00:00
## Conversation Hook
`IConversationHook`
```csharp
Task OnDialogsLoaded(List<RoleDialogModel> dialogs);
Task BeforeCompletion();
Task OnFunctionExecuting(RoleDialogModel message);
Task OnFunctionExecuted(RoleDialogModel message);
Task AfterCompletion(RoleDialogModel message);
// LLM detected the user's intention to end the conversation
Task ConversationEnding(RoleDialogModel conversation);
2023-08-19 13:25:47 +00:00
```
More information about conversation hook please go to [Conversation Hook](../conversation/hook.md).
2023-08-19 13:25:47 +00:00
### Conversation State Hook
`IConversationHook`
```csharp
Task OnStateLoaded(ConversationState state);
Task OnStateChanged(string name, string preValue, string currentValue);
```