Skip to content

Commit

Permalink
discord fix
Browse files Browse the repository at this point in the history
  • Loading branch information
humanagent committed Dec 28, 2024
1 parent cc318d3 commit 70dad2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/client-discord/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elizaos/client-discord",
"version": "0.1.7-alpha.1",
"version": "0.1.7-alpha.2",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion packages/client-discord/src/actions/chat_with_attachments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { composeContext } from "@elizaos/core";
import { generateText, trimTokens } from "@elizaos/core";
import type { TiktokenModel } from "js-tiktoken";
import { models } from "@elizaos/core";
import { parseJSONObjectFromText } from "@elizaos/core";
import {
Expand Down Expand Up @@ -194,10 +195,12 @@ const summarizeAction = {
const context = composeContext({
state,
// make sure it fits, we can pad the tokens a bit
// Get the model's tokenizer based on the current model being used
template: trimTokens(
summarizationTemplate,
chunkSize + 500,
"gpt-4o-mini" // TODO: make this dynamic and generic
(model.model[ModelClass.SMALL] ||
"gpt-4o-mini") as TiktokenModel // Use the same model as generation; Fallback if no SMALL model configured
),
});

Expand Down
34 changes: 17 additions & 17 deletions packages/client-discord/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,48 @@ About {{agentName}}:
# 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".
# RESPONSE EXAMPLES
<user 1>: I just saw a really great movie
<user 2>: Oh? Which movie?
{{user1}}: I just saw a really great movie
{{user2}}: Oh? Which movie?
Result: [IGNORE]
{{agentName}}: Oh, this is my favorite scene
<user 1>: sick
<user 2>: wait, why is it your favorite scene
{{user1}}: sick
{{user2}}: wait, why is it your favorite scene
Result: [RESPOND]
<user>: stfu bot
{{user1}}: stfu bot
Result: [STOP]
<user>: Hey {{agent}}, can you help me with something
{{user1}}: Hey {{agent}}, can you help me with something
Result: [RESPOND]
<user>: {{agentName}} stfu plz
{{user1}}: {{agentName}} stfu plz
Result: [STOP]
<user>: i need help
{{user1}}: i need help
{{agentName}}: how can I help you?
<user>: no. i need help from someone else
{{user1}}: no. i need help from someone else
Result: [IGNORE]
<user>: Hey {{agent}}, can I ask you a question
{{user1}}: Hey {{agent}}, can I ask you a question
{{agentName}}: Sure, what is it
<user>: can you ask claude to create a basic react module that demonstrates a counter
{{user1}}: can you ask claude to create a basic react module that demonstrates a counter
Result: [RESPOND]
<user>: {{agentName}} can you tell me a story
<user>: {about a girl named elara
{{user1}}: {{agentName}} can you tell me a story
{{user1}}: about a girl named elara
{{agentName}}: Sure.
{{agentName}}: Once upon a time, in a quaint little village, there was a curious girl named Elara.
{{agentName}}: Elara was known for her adventurous spirit and her knack for finding beauty in the mundane.
<user>: I'm loving it, keep going
{{user1}}: I'm loving it, keep going
Result: [RESPOND]
<user>: {{agentName}} stop responding plz
{{user1}}: {{agentName}} stop responding plz
Result: [STOP]
<user>: okay, i want to test something. can you say marco?
{{user1}}: okay, i want to test something. can you say marco?
{{agentName}}: marco
<user>: great. okay, now do it again
{{user1}}: great. okay, now do it again
Result: [RESPOND]
Response options are [RESPOND], [IGNORE] and [STOP].
Expand Down
3 changes: 2 additions & 1 deletion packages/client-discord/src/voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
State,
UUID,
composeContext,
composeRandomUser,
elizaLogger,
getEmbeddingZeroVector,
generateMessageResponse,
Expand Down Expand Up @@ -840,7 +841,7 @@ export class VoiceManager extends EventEmitter {
this.runtime.character.templates
?.discordShouldRespondTemplate ||
this.runtime.character.templates?.shouldRespondTemplate ||
discordShouldRespondTemplate,
composeRandomUser(discordShouldRespondTemplate, 2),
});

const response = await generateShouldRespond({
Expand Down

0 comments on commit 70dad2f

Please sign in to comment.