diff --git a/packages/client-twitter/src/interactions.ts b/packages/client-twitter/src/interactions.ts index 3af5579f50..cda9c4d401 100644 --- a/packages/client-twitter/src/interactions.ts +++ b/packages/client-twitter/src/interactions.ts @@ -19,13 +19,11 @@ import { ClientBase } from "./base"; import { buildConversationThread, sendTweet, wait } from "./utils.ts"; export const twitterMessageHandlerTemplate = - `{{timeline}} - -# Knowledge + ` +# Areas of Expertise {{knowledge}} -# Task: Generate a post for the character {{agentName}}. -About {{agentName}} (@{{twitterUserName}}): +# About {{agentName}} (@{{twitterUserName}}): {{bio}} {{lore}} {{topics}} @@ -226,17 +224,6 @@ export class TwitterInteractionClient { }; const currentPost = formatTweet(tweet); - let homeTimeline: Tweet[] = []; - // read the file if it exists - - const cachedTimeline = await this.client.getCachedTimeline(); - if (cachedTimeline) { - homeTimeline = cachedTimeline; - } else { - homeTimeline = await this.client.fetchHomeTimeline(50); - await this.client.cacheTimeline(homeTimeline); - } - elizaLogger.debug("Thread: ", thread); const formattedConversation = thread .map( @@ -254,20 +241,11 @@ export class TwitterInteractionClient { elizaLogger.debug("formattedConversation: ", formattedConversation); - const formattedHomeTimeline = - `# ${this.runtime.character.name}'s Home Timeline\n\n` + - homeTimeline - .map((tweet) => { - return `ID: ${tweet.id}\nFrom: ${tweet.name} (@${tweet.username})${tweet.inReplyToStatusId ? ` In reply to: ${tweet.inReplyToStatusId}` : ""}\nText: ${tweet.text}\n---\n`; - }) - .join("\n"); - let state = await this.runtime.composeState(message, { twitterClient: this.client.twitterClient, twitterUserName: this.runtime.getSetting("TWITTER_USERNAME"), currentPost, formattedConversation, - timeline: formattedHomeTimeline, }); // check if the tweet exists, save if it doesn't diff --git a/packages/client-twitter/src/post.ts b/packages/client-twitter/src/post.ts index b8355610f9..b068060c48 100644 --- a/packages/client-twitter/src/post.ts +++ b/packages/client-twitter/src/post.ts @@ -11,25 +11,24 @@ import { import { elizaLogger } from "@ai16z/eliza"; import { ClientBase } from "./base.ts"; -const twitterPostTemplate = `{{timeline}} - -# Knowledge +const twitterPostTemplate = ` +# Areas of Expertise {{knowledge}} -About {{agentName}} (@{{twitterUserName}}): +# About {{agentName}} (@{{twitterUserName}}): {{bio}} {{lore}} -{{postDirections}} +{{topics}} {{providers}} -{{recentPosts}} - {{characterPostExamples}} -# Task: Generate a post in the voice and style of {{agentName}}, aka @{{twitterUserName}} -Write a single sentence post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Try to write something totally different than previous posts. Do not add commentary or acknowledge this request, just write the post. -Your response should not contain any questions. Brief, concise statements only. No emojis. Use \\n\\n (double spaces) between statements.`; +{{postDirections}} + +# Task: Generate a post in the voice and style and perspective of {{agentName}} @{{twitterUserName}}. +Write a 1-3 sentence post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post. +Your response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements.`; const MAX_TWEET_LENGTH = 280; @@ -132,28 +131,7 @@ export class TwitterPostClient { "twitter" ); - let homeTimeline: Tweet[] = []; - - const cachedTimeline = await this.client.getCachedTimeline(); - - // console.log({ cachedTimeline }); - - if (cachedTimeline) { - homeTimeline = cachedTimeline; - } else { - homeTimeline = await this.client.fetchHomeTimeline(10); - await this.client.cacheTimeline(homeTimeline); - } - const formattedHomeTimeline = - `# ${this.runtime.character.name}'s Home Timeline\n\n` + - homeTimeline - .map((tweet) => { - return `#${tweet.id}\n${tweet.name} (@${tweet.username})${tweet.inReplyToStatusId ? `\nIn reply to: ${tweet.inReplyToStatusId}` : ""}\n${new Date(tweet.timestamp).toDateString()}\n\n${tweet.text}\n---\n`; - }) - .join("\n"); - const topics = this.runtime.character.topics.join(", "); - const state = await this.runtime.composeState( { userId: this.runtime.agentId, @@ -166,7 +144,6 @@ export class TwitterPostClient { }, { twitterUserName: this.client.profile.username, - timeline: formattedHomeTimeline, } ); @@ -243,8 +220,6 @@ export class TwitterPostClient { await this.client.cacheTweet(tweet); - homeTimeline.push(tweet); - await this.client.cacheTimeline(homeTimeline); elizaLogger.log(`Tweet posted:\n ${tweet.permanentUrl}`); const roomId = stringToUuid( diff --git a/packages/core/src/providers.ts b/packages/core/src/providers.ts index e97eb331f9..d6335b97e1 100644 --- a/packages/core/src/providers.ts +++ b/packages/core/src/providers.ts @@ -12,11 +12,13 @@ export async function getProviders( message: Memory, state?: State ) { - const providerResults = await Promise.all( - runtime.providers.map(async (provider) => { - return await provider.get(runtime, message, state); - }) - ); + const providerResults = ( + await Promise.all( + runtime.providers.map(async (provider) => { + return await provider.get(runtime, message, state); + }) + ) + ).filter((result) => result != null && result !== ""); return providerResults.join("\n"); }