-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnonsense_action_handler.ts
More file actions
34 lines (28 loc) · 1.22 KB
/
nonsense_action_handler.ts
File metadata and controls
34 lines (28 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Plugin, ActionHandlerProps, ActionResult } from '../../src/index.js';
const nonsenseActionHandler: Plugin = {
name: 'nonsense-action-handler',
actionHandlers: {
'nonsense-action': {
description:
'A demonstration action handler that echoes back the received content. Use this action when you want to test the plugin system or demonstrate its capabilities.',
handler: async (props: ActionHandlerProps): Promise<ActionResult> => {
const { putSystemMessage, askUserForInput } = await import('../../src/index.js');
putSystemMessage('Custom action handler executed', props.iterateCall.args);
// Example implementation that echoes the content back
const assistantItem = {
type: 'assistant' as const,
text: `Custom action handler received: ${props.iterateCall.args?.message}`,
};
const userItem = {
type: 'user' as const,
text: (await askUserForInput('Your answer', props.iterateCall.args?.message ?? '', props.options)).answer,
};
return {
breakLoop: false,
items: [{ assistant: assistantItem, user: userItem }],
};
},
},
},
};
export default nonsenseActionHandler;