Skip to content

Commit 1c41de5

Browse files
authored
Merge branch 'develop' into feature/plugin-hyperliquid
2 parents b04604a + cb51da5 commit 1c41de5

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

packages/client-twitter/src/interactions.ts

+30-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
stringToUuid,
1515
elizaLogger,
1616
getEmbeddingZeroVector,
17+
IImageDescriptionService,
18+
ServiceType
1719
} from "@elizaos/core";
1820
import { ClientBase } from "./base";
1921
import { buildConversationThread, sendTweet, wait } from "./utils.ts";
@@ -43,6 +45,8 @@ Recent interactions between {{agentName}} and other users:
4345
4446
Current Post:
4547
{{currentPost}}
48+
Here is the descriptions of images in the Current post.
49+
{{imageDescriptions}}
4650
4751
Thread of Tweets You Are Replying To:
4852
{{formattedConversation}}
@@ -53,6 +57,8 @@ Thread of Tweets You Are Replying To:
5357
5458
Here is the current post text again. Remember to include an action if the current post text includes a prompt that asks for one of the available actions mentioned above (does not need to be exact)
5559
{{currentPost}}
60+
Here is the descriptions of images in the Current post.
61+
{{imageDescriptions}}
5662
` + messageCompletionFooter;
5763

5864
export const twitterShouldRespondTemplate = (targetUsersStr: string) =>
@@ -342,11 +348,34 @@ export class TwitterInteractionClient {
342348

343349
elizaLogger.debug("formattedConversation: ", formattedConversation);
344350

351+
let imageDescriptionsArray = [];
352+
try{
353+
elizaLogger.debug('Getting images');
354+
for (const photo of tweet.photos) {
355+
elizaLogger.debug(photo.url);
356+
const description = await this.runtime
357+
.getService<IImageDescriptionService>(
358+
ServiceType.IMAGE_DESCRIPTION
359+
)
360+
.describeImage(photo.url);
361+
imageDescriptionsArray.push(description);
362+
}
363+
} catch (error) {
364+
// Handle the error
365+
elizaLogger.error("Error Occured during describing image: ", error);
366+
}
367+
368+
369+
370+
345371
let state = await this.runtime.composeState(message, {
346372
twitterClient: this.client.twitterClient,
347373
twitterUserName: this.client.twitterConfig.TWITTER_USERNAME,
348374
currentPost,
349375
formattedConversation,
376+
imageDescriptions: imageDescriptionsArray.length > 0
377+
? `\nImages in Tweet:\n${imageDescriptionsArray.map((desc, i) =>
378+
`Image ${i + 1}: Title: ${desc.title}\nDescription: ${desc.description}`).join("\n\n")}`:""
350379
});
351380

352381
// check if the tweet exists, save if it doesn't
@@ -413,7 +442,6 @@ export class TwitterInteractionClient {
413442
this.runtime.character?.templates?.messageHandlerTemplate ||
414443
twitterMessageHandlerTemplate,
415444
});
416-
417445
elizaLogger.debug("Interactions prompt:\n" + context);
418446

419447
const response = await generateMessageResponse({
@@ -624,4 +652,4 @@ export class TwitterInteractionClient {
624652

625653
return thread;
626654
}
627-
}
655+
}

0 commit comments

Comments
 (0)