Skip to content

Commit 70dad2f

Browse files
committed
discord fix
1 parent cc318d3 commit 70dad2f

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

packages/client-discord/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elizaos/client-discord",
3-
"version": "0.1.7-alpha.1",
3+
"version": "0.1.7-alpha.2",
44
"main": "dist/index.js",
55
"type": "module",
66
"types": "dist/index.d.ts",

packages/client-discord/src/actions/chat_with_attachments.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { composeContext } from "@elizaos/core";
22
import { generateText, trimTokens } from "@elizaos/core";
3+
import type { TiktokenModel } from "js-tiktoken";
34
import { models } from "@elizaos/core";
45
import { parseJSONObjectFromText } from "@elizaos/core";
56
import {
@@ -194,10 +195,12 @@ const summarizeAction = {
194195
const context = composeContext({
195196
state,
196197
// make sure it fits, we can pad the tokens a bit
198+
// Get the model's tokenizer based on the current model being used
197199
template: trimTokens(
198200
summarizationTemplate,
199201
chunkSize + 500,
200-
"gpt-4o-mini" // TODO: make this dynamic and generic
202+
(model.model[ModelClass.SMALL] ||
203+
"gpt-4o-mini") as TiktokenModel // Use the same model as generation; Fallback if no SMALL model configured
201204
),
202205
});
203206

packages/client-discord/src/templates.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,48 @@ About {{agentName}}:
88
# INSTRUCTIONS: Determine if {{agentName}} should respond to the message and participate in the conversation. Do not comment. Just respond with "RESPOND" or "IGNORE" or "STOP".
99
1010
# RESPONSE EXAMPLES
11-
<user 1>: I just saw a really great movie
12-
<user 2>: Oh? Which movie?
11+
{{user1}}: I just saw a really great movie
12+
{{user2}}: Oh? Which movie?
1313
Result: [IGNORE]
1414
1515
{{agentName}}: Oh, this is my favorite scene
16-
<user 1>: sick
17-
<user 2>: wait, why is it your favorite scene
16+
{{user1}}: sick
17+
{{user2}}: wait, why is it your favorite scene
1818
Result: [RESPOND]
1919
20-
<user>: stfu bot
20+
{{user1}}: stfu bot
2121
Result: [STOP]
2222
23-
<user>: Hey {{agent}}, can you help me with something
23+
{{user1}}: Hey {{agent}}, can you help me with something
2424
Result: [RESPOND]
2525
26-
<user>: {{agentName}} stfu plz
26+
{{user1}}: {{agentName}} stfu plz
2727
Result: [STOP]
2828
29-
<user>: i need help
29+
{{user1}}: i need help
3030
{{agentName}}: how can I help you?
31-
<user>: no. i need help from someone else
31+
{{user1}}: no. i need help from someone else
3232
Result: [IGNORE]
3333
34-
<user>: Hey {{agent}}, can I ask you a question
34+
{{user1}}: Hey {{agent}}, can I ask you a question
3535
{{agentName}}: Sure, what is it
36-
<user>: can you ask claude to create a basic react module that demonstrates a counter
36+
{{user1}}: can you ask claude to create a basic react module that demonstrates a counter
3737
Result: [RESPOND]
3838
39-
<user>: {{agentName}} can you tell me a story
40-
<user>: {about a girl named elara
39+
{{user1}}: {{agentName}} can you tell me a story
40+
{{user1}}: about a girl named elara
4141
{{agentName}}: Sure.
4242
{{agentName}}: Once upon a time, in a quaint little village, there was a curious girl named Elara.
4343
{{agentName}}: Elara was known for her adventurous spirit and her knack for finding beauty in the mundane.
44-
<user>: I'm loving it, keep going
44+
{{user1}}: I'm loving it, keep going
4545
Result: [RESPOND]
4646
47-
<user>: {{agentName}} stop responding plz
47+
{{user1}}: {{agentName}} stop responding plz
4848
Result: [STOP]
4949
50-
<user>: okay, i want to test something. can you say marco?
50+
{{user1}}: okay, i want to test something. can you say marco?
5151
{{agentName}}: marco
52-
<user>: great. okay, now do it again
52+
{{user1}}: great. okay, now do it again
5353
Result: [RESPOND]
5454
5555
Response options are [RESPOND], [IGNORE] and [STOP].

packages/client-discord/src/voice.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
State,
99
UUID,
1010
composeContext,
11+
composeRandomUser,
1112
elizaLogger,
1213
getEmbeddingZeroVector,
1314
generateMessageResponse,
@@ -840,7 +841,7 @@ export class VoiceManager extends EventEmitter {
840841
this.runtime.character.templates
841842
?.discordShouldRespondTemplate ||
842843
this.runtime.character.templates?.shouldRespondTemplate ||
843-
discordShouldRespondTemplate,
844+
composeRandomUser(discordShouldRespondTemplate, 2),
844845
});
845846

846847
const response = await generateShouldRespond({

0 commit comments

Comments
 (0)