-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve twitter post content quality #763
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a bit cleaner would be something like this. Maybe we can fine-tune or A/B test the prompt.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can try this out |
||
|
||
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( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrectly named "timeline" - it was really just a list of the bot's previous posts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, I’ve heard it called timeline. Profile timeline might be more apt and precise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we can revisit this in a future pr. didn't actually change the underlying function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, if we need to have a list of previous posts for some analysis, we can quickly re-introduce it. For the PR its good