Skip to content

Commit 2c8fb7f

Browse files
committed
test more generateSHouldRespond
1 parent ab00b65 commit 2c8fb7f

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

packages/client-discord/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
Partials,
1616
type User,
1717
} from "discord.js";
18-
import { EventEmitter } from "events";
18+
import { EventEmitter } from "node:events";
1919
import chat_with_attachments from "./actions/chat_with_attachments.ts";
2020
import download_media from "./actions/download_media.ts";
2121
import joinvoice from "./actions/joinvoice.ts";

packages/client-discord/src/messages.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class MessageManager {
271271
if (message.author.bot) {
272272
if (this._isTeamMember(authorId) && !isDirectlyMentioned) {
273273
return;
274-
} else if (
274+
}if (
275275
this.runtime.character.clientConfig.discord
276276
.shouldIgnoreBotMessages
277277
) {
@@ -295,7 +295,7 @@ export class MessageManager {
295295
attachments.push(...processedAudioAttachments);
296296
}
297297

298-
const roomId = stringToUuid(channelId + "-" + this.runtime.agentId);
298+
const roomId = stringToUuid(`${channelId}-${this.runtime.agentId}`);
299299
const userIdUUID = stringToUuid(userId);
300300

301301
await this.runtime.ensureConnection(
@@ -307,7 +307,7 @@ export class MessageManager {
307307
);
308308

309309
const messageId = stringToUuid(
310-
message.id + "-" + this.runtime.agentId
310+
`${message.id}-${this.runtime.agentId}`
311311
);
312312

313313
let shouldIgnore = false;
@@ -320,9 +320,7 @@ export class MessageManager {
320320
url: message.url,
321321
inReplyTo: message.reference?.messageId
322322
? stringToUuid(
323-
message.reference.messageId +
324-
"-" +
325-
this.runtime.agentId
323+
`${message.reference.messageId}-${this.runtime.agentId}`
326324
)
327325
: undefined,
328326
};
@@ -335,7 +333,7 @@ export class MessageManager {
335333
};
336334

337335
const memory: Memory = {
338-
id: stringToUuid(message.id + "-" + this.runtime.agentId),
336+
id: stringToUuid(`${message.id}-${this.runtime.agentId}`),
339337
...userMessage,
340338
userId: userIdUUID,
341339
agentId: this.runtime.agentId,
@@ -728,7 +726,7 @@ export class MessageManager {
728726

729727
// Create and store memories
730728
const memories = messages.map(m => ({
731-
id: stringToUuid(m.id + "-" + this.runtime.agentId),
729+
id: stringToUuid(`${m.id}-${this.runtime.agentId}`),
732730
userId: this.runtime.agentId,
733731
agentId: this.runtime.agentId,
734732
content: {

packages/client-discord/src/providers/voiceState.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const voiceStateProvider: Provider = {
1212
);
1313
const agentName = state?.agentName || "The agent";
1414
if (!connection) {
15-
return agentName + " is not currently in a voice channel";
15+
return `${agentName} is not currently in a voice channel`;
1616
}
1717

1818
const channel = (
@@ -23,7 +23,7 @@ const voiceStateProvider: Provider = {
2323
);
2424

2525
if (!channel || channel.type !== ChannelType.GuildVoice) {
26-
return agentName + " is in an invalid voice channel";
26+
return `${agentName} is in an invalid voice channel`;
2727
}
2828

2929
return `${agentName} is currently in the voice channel: ${channel.name} (ID: ${channel.id})`;

packages/core/src/generation.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ async function generateEnum<T extends string>({
304304
modelClass,
305305
output: 'enum',
306306
enum: enumValues,
307+
mode: 'json'
307308
});
308309

309310
elizaLogger.debug("Received enum response:", result);
@@ -322,7 +323,7 @@ export async function generateShouldRespond({
322323
context: string;
323324
modelClass: ModelClass;
324325
}): Promise<"RESPOND" | "IGNORE" | "STOP" | null> {
325-
const RESPONSE_VALUES = ['RESPOND', 'IGNORE', 'STOP'];
326+
const RESPONSE_VALUES = ['RESPOND', 'IGNORE', 'STOP'] as string[];
326327

327328
const result = await generateEnum({
328329
runtime,

0 commit comments

Comments
 (0)