Skip to content

Commit 11e5465

Browse files
merge
2 parents 80af67a + 0b3438b commit 11e5465

16 files changed

+279
-135
lines changed

core/.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
DISCORD_APPLICATION_ID=
33
DISCORD_API_TOKEN= # Bot token
44
OPENAI_API_KEY=sk-* # OpenAI API key, starting with sk-
5+
GROQ_API_KEY=gsk_*
6+
57
ELEVENLABS_XI_API_KEY= # API key from elevenlabs
68

79
# ELEVENLABS SETTINGS

core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"start:degen": "node --loader ts-node/esm src/index.ts --characters=\"../characters/degenspartan.json\"",
2121
"start:service:all": "pm2 start pnpm --name=\"all\" --restart-delay=3000 --max-restarts=10 -- run start:all",
2222
"stop:service:all": "pm2 stop all",
23-
"start:all": "node --loader ts-node/esm src/index.ts --characters=\"../characters/degenspartan.json\",\"../characters/ruby.character.json\",\"../characters/pmairca.character.json\"",
23+
"start:all": "node --loader ts-node/esm src/index.ts --characters=\"../characters/degenspartan.json\",\"../characters/ruby.character.json\",\"../characters/pmairca.json\"",
2424
"start:trump": "node --loader ts-node/esm src/index.ts --characters=\"../characters/trump.character.json\"",
2525
"start:service:tate": "pm2 start pnpm --name=\"tate\" --restart-delay=3000 --max-restarts=10 -- run start:tate",
2626
"stop:service:tate": "pm2 stop tate",

core/src/actions/imageGeneration.ts

+45-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import { prettyConsole } from "../index.ts";
99
import { generateCaption, generateImage } from "./imageGenerationUtils.ts";
1010

1111
export const imageGeneration: Action = {
12-
name: "IMAGE_GEN",
13-
similes: ["GENERATE_IMAGE", "CREATE_IMAGE", "MAKE_PICTURE"],
14-
description: "Generate an image based on a prompt",
12+
name: "GENERATE_IMAGE",
13+
similes: ["IMAGE_GENERATION", "IMAGE_GEN", "CREATE_IMAGE", "MAKE_PICTURE"],
14+
description: "Generate an image to go along with the message.",
1515
validate: async (runtime: IAgentRuntime, message: Memory) => {
1616
const anthropicApiKeyOk = !!runtime.getSetting("ANTHROPIC_API_KEY");
1717
const togetherApiKeyOk = !!runtime.getSetting("TOGETHER_API_KEY");
1818

19-
prettyConsole.log("Validating image generation settings...");
19+
// TODO: Add openai DALL-E generation as well
20+
2021
return anthropicApiKeyOk && togetherApiKeyOk;
2122
},
2223
handler: async (
@@ -33,6 +34,9 @@ export const imageGeneration: Action = {
3334

3435
const imagePrompt = message.content.text;
3536
prettyConsole.log("Image prompt received:", imagePrompt);
37+
38+
// TODO: Generate a prompt for the image
39+
3640
const res: { image: string; caption: string }[] = [];
3741

3842
prettyConsole.log("Generating image with prompt:", imagePrompt);
@@ -90,35 +94,72 @@ export const imageGeneration: Action = {
9094
}
9195
},
9296
examples: [
97+
// TODO: We want to generate images in more abstract ways, not just when asked to generate an image
98+
9399
[
94100
{
95101
user: "{{user1}}",
96102
content: { text: "Generate an image of a cat" },
97103
},
104+
{
105+
user: "{{agentName}}",
106+
content: {
107+
text: "Here's an image of a cat",
108+
action: "GENERATE_IMAGE",
109+
},
110+
},
98111
],
99112
[
100113
{
101114
user: "{{user1}}",
102115
content: { text: "Generate an image of a dog" },
103116
},
117+
{
118+
user: "{{agentName}}",
119+
content: {
120+
text: "Here's an image of a dog",
121+
action: "GENERATE_IMAGE",
122+
},
123+
},
104124
],
105125
[
106126
{
107127
user: "{{user1}}",
108128
content: { text: "Create an image of a cat with a hat" },
109129
},
130+
{
131+
user: "{{agentName}}",
132+
content: {
133+
text: "Here's an image of a cat with a hat",
134+
action: "GENERATE_IMAGE",
135+
},
136+
},
110137
],
111138
[
112139
{
113140
user: "{{user1}}",
114141
content: { text: "Make an image of a dog with a hat" },
115142
},
143+
{
144+
user: "{{agentName}}",
145+
content: {
146+
text: "Here's an image of a dog with a hat",
147+
action: "GENERATE_IMAGE",
148+
},
149+
},
116150
],
117151
[
118152
{
119153
user: "{{user1}}",
120154
content: { text: "Paint an image of a cat with a hat" },
121155
},
156+
{
157+
user: "{{agentName}}",
158+
content: {
159+
text: "Here's an image of a cat with a hat",
160+
action: "GENERATE_IMAGE",
161+
},
162+
},
122163
],
123164
],
124165
} as Action;

core/src/clients/discord/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ export class DiscordClient extends EventEmitter {
168168

169169
const reactionMessage = `*<${emoji}>: "${truncatedContent}"*`;
170170

171-
const roomId = stringToUuid(reaction.message.channel.id);
172-
const userIdUUID = stringToUuid(user.id);
171+
const roomId = stringToUuid(reaction.message.channel.id + "-" + this.runtime.agentId);
172+
const userIdUUID = stringToUuid(user.id + "-" + this.runtime.agentId);
173173

174174
// Generate a unique UUID for the reaction
175175
const reactionUUID = stringToUuid(
176-
`${reaction.message.id}-${user.id}-${emoji}`
176+
`${reaction.message.id}-${user.id}-${emoji}-${this.runtime.agentId}`
177177
);
178178

179179
// ensure the user id and room id are valid
@@ -200,7 +200,7 @@ export class DiscordClient extends EventEmitter {
200200
content: {
201201
text: reactionMessage,
202202
source: "discord",
203-
inReplyTo: stringToUuid(reaction.message.id), // This is the ID of the original message
203+
inReplyTo: stringToUuid(reaction.message.id + "-" + this.runtime.agentId), // This is the ID of the original message
204204
},
205205
roomId,
206206
createdAt: Date.now(),
@@ -238,12 +238,12 @@ export class DiscordClient extends EventEmitter {
238238

239239
const reactionMessage = `*Removed <${emoji} emoji> from: "${truncatedContent}"*`;
240240

241-
const roomId = stringToUuid(reaction.message.channel.id);
241+
const roomId = stringToUuid(reaction.message.channel.id + "-" + this.runtime.agentId);
242242
const userIdUUID = stringToUuid(user.id);
243243

244244
// Generate a unique UUID for the reaction removal
245245
const reactionUUID = stringToUuid(
246-
`${reaction.message.id}-${user.id}-${emoji}-removed`
246+
`${reaction.message.id}-${user.id}-${emoji}-removed-${this.runtime.agentId}`
247247
);
248248

249249
const userName = reaction.message.author.username;
@@ -266,7 +266,7 @@ export class DiscordClient extends EventEmitter {
266266
content: {
267267
text: reactionMessage,
268268
source: "discord",
269-
inReplyTo: stringToUuid(reaction.message.id), // This is the ID of the original message
269+
inReplyTo: stringToUuid(reaction.message.id + "-" + this.runtime.agentId), // This is the ID of the original message
270270
},
271271
roomId,
272272
createdAt: Date.now(),

0 commit comments

Comments
 (0)