You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/website/docs/guide/13-ai-powered-commands/01-introduction.mdx
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,14 @@ configureAI({
54
54
// commandkit will call this function
55
55
// to determine which AI model to use
56
56
selectAiModel: async () => {
57
-
return { model };
57
+
return {
58
+
model,
59
+
// OPTIONAL: provider specific options
60
+
options,
61
+
// OPTIONAL: whether to use the object mode. Default is false.
62
+
// If set to true, the AI will be able to generate object responses, such as creating polls or sending embeds.
63
+
objectMode: false,
64
+
};
58
65
},
59
66
messageFilter: async (message) => {
60
67
// only respond to messages in guilds that mention the bot
@@ -156,3 +163,17 @@ AI can also call multiple commands in a single message. Eg:
156
163
```
157
164
158
165
The above prompt will call the built-in `getUserInfo` tool and the `balance` command.
166
+
167
+
## Object Mode Example
168
+
169
+
Simply set the `objectMode` to `true` in the `configureAI` function to enable object mode. This allows the AI to generate object responses, such as creating polls or sending embeds.
170
+
171
+
```text
172
+
@bot create a poll titled "What's your favorite game?" and answers should be
@@ -201,7 +202,10 @@ export class AiPlugin extends RuntimePlugin<AiPluginOptions> {
201
202
Tools are basically like commands that you can execute to perform specific actions based on user input.
202
203
Keep the response short and concise, and only use tools when necessary. Keep the response length under 2000 characters.
203
204
Do not include your own text in the response unless necessary. For text formatting, you can use discord's markdown syntax.
204
-
${message.inGuild() ? `\nYou are currently in a guild named ${message.guild.name} whose id is ${message.guildId}. While in guild, you can fetch member information if needed.` : '\nYou are currently in a direct message with the user.'}`;
205
+
${message.inGuild() ? `\nYou are currently in a guild named ${message.guild.name} whose id is ${message.guildId}. While in guild, you can fetch member information if needed.` : '\nYou are currently in a direct message with the user.'}
206
+
If the user asks you to create a poll or embeds, create a text containing the poll or embed information. If structured response is possible, use the structured response format.
207
+
If the user asks you to perform a task that requires a tool, use the tool to perform the task and return the result.
208
+
`;
205
209
206
210
constuserInfo=`<user>
207
211
<id>${message.author.id}</id>
@@ -215,22 +219,116 @@ export class AiPlugin extends RuntimePlugin<AiPluginOptions> {
0 commit comments