Skip to content
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 double spaced tweets in Post.ts #1626

Merged

Conversation

suicidalgoofy
Copy link
Contributor

Relates to:

N/A

Risks

Low risk, simply ensures tweets generated follow the prompt guidelines of double spaces (\n\n) for new statements instead of a single space to improve tweet readability.

Background

What does this PR do?

Updates the line break handling in the tweet formatting logic to follow the prompt stating to use double spaces between statements. Currently statements only use a single line break (\n). This enforces the double line breaks for better readability in tweets.

What kind of change is this?

Improvements (misc. changes to existing features)

Why are we doing this? Any context or related work?

This allows agents to tweet better-structured posts that are optimally formatted for readability. Also ensures posting follows the double space guideliens written out into the prompt.

Documentation changes needed?

My changes do not require a change to the project documentation.

Testing

Where should a reviewer start?

The changes are in the generateNewTweet() function and the fixNewLines() helper within post.ts.

Detailed testing steps

Generate a sample tweet using the updated code.

Verify all escaped newlines (\n) in the model's output are replaced with double linebreaks (\n\n).

Screenshots

Before

Screenshot 2024-12-31 233257
Screenshot 2024-12-31 233303

After

Screenshot 2024-12-31 233502
Screenshot 2024-12-31 233521

Discord username

suicidal_goofy

Currently, despite the prompting stating to use "\\n\\n (double spaces" between statements the tweets always output new statements with just a single newline, making tweets look blocky. 

For example, tweets previous would look like (despite the prompt): 
"Dobby is so excited to start this new year, full of possibilities and chances to make a difference!
Dobby has big plans to help his dear friends and make the wizarding world an even brighter place."

This ensures the double spaces requested in prompting is applied to the tweets with the tweets now looking like: 
"Dobby must remind all friends to be cautious of dark magic lurking in the shadows.

Dobby's heart aches at the thought of anyone falling prey to its deceitful powers."

This allows agents to tweet better-formatted posts that ease visilibty.
@monilpat monilpat changed the base branch from main to develop January 1, 2025 05:40
Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request effectively enhances the readability of tweets by ensuring that double line breaks are used as specified. This is a thoughtful improvement that aligns with best practices for formatting text for social media. Great work on implementing this change!

packages/client-twitter/src/post.ts Show resolved Hide resolved
packages/client-twitter/src/post.ts Show resolved Hide resolved
@monilpat monilpat added agent-reviewed For agent reviews of pull requests. agent-commented For agent comments on pull requests, issues, etc. labels Jan 1, 2025
@monilpat monilpat merged commit 64cfc07 into elizaOS:develop Jan 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-commented For agent comments on pull requests, issues, etc. agent-reviewed For agent reviews of pull requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants