diff --git a/foodie_automator_google.py b/foodie_automator_google.py index 653e268..8b93b94 100644 --- a/foodie_automator_google.py +++ b/foodie_automator_google.py @@ -372,7 +372,8 @@ def curate_from_google_trends(posted_titles_data, posted_titles, used_images_dat uploader=uploader, page_url=page_url, interest_score=interest_score, - should_post_tweet=True + should_post_tweet=True, + summary=final_summary ) if not post_id: logging.warning(f"Failed to post to WordPress for '{title}', using original URL: {original_url}") diff --git a/foodie_automator_reddit.py b/foodie_automator_reddit.py index 7e7823f..39e161c 100644 --- a/foodie_automator_reddit.py +++ b/foodie_automator_reddit.py @@ -392,7 +392,8 @@ def curate_from_reddit(posted_titles_data, posted_titles, used_images_data, used uploader=uploader, page_url=page_url, interest_score=interest_score, - should_post_tweet=True + should_post_tweet=True, + summary=final_summary ) if not post_id: logging.warning(f"Failed to post to WordPress for '{title}', using original URL: {original_url}") diff --git a/foodie_automator_rss.py b/foodie_automator_rss.py index e689984..ef95147 100644 --- a/foodie_automator_rss.py +++ b/foodie_automator_rss.py @@ -382,7 +382,8 @@ def curate_from_rss(posted_titles_data, posted_titles, used_images_data, used_im uploader=uploader, page_url=page_url, interest_score=interest_score, - should_post_tweet=True + should_post_tweet=True, + summary=final_summary ) if not post_id: logging.warning(f"Failed to post to WordPress for '{title}', using original URL: {original_url}") diff --git a/foodie_utils.py b/foodie_utils.py index e76f5db..236efe6 100644 --- a/foodie_utils.py +++ b/foodie_utils.py @@ -109,21 +109,22 @@ def save_json_file(file_path, data, timestamp=None): logger.error(f"Failed to save {file_path}: {str(e)}") return False -def generate_article_tweet(author, post, persona): +def generate_article_tweet(author, post, persona, summary=""): title = post["title"] url = post["url"] author_handle = f"@{author['username']}" prompt = ( - f"Craft a sharp tweet (under 230 characters) for {author_handle} with the voice of '{persona}'. " - f"Distill the essence of the article '{title}' into a concise, engaging message. " + f"Craft a sharp tweet (under 280 characters) for {author_handle} with the voice of '{persona}'. " + f"Distill the essence of the article '{title}' and its summary into a concise, engaging message. " + f"Summary: {summary}\n" + f"Include one specific detail from the summary (e.g., a unique dish, location, or trend). " f"Include the raw URL '{url}' at the end. " - f"Do not wrap the tweet in quotation marks. " f"Make it bold, spark curiosity, and invite engagement with a human touch. " f"Swap 'elevate' for dynamic terms like 'ignite' or 'unleash'. " - f"Absolutely do not include hashtags, emojis, or phrases like '[Read more]' or 'Read more'. " + f"Skip hashtags, emojis, or phrases like '[Read more]' or 'Read more'. " f"Skip any extra fluff or formatting around the URL—just append the raw URL after a space. " - f"Example: 'Love food trends? Check this out! {url}'" + f"Example: 'Craving sushi? This Tokyo spot is unreal! {url}'" ) response = client.chat.completions.create( @@ -132,7 +133,7 @@ def generate_article_tweet(author, post, persona): {"role": "system", "content": "You are a social media viral expert crafting engaging tweets."}, {"role": "user", "content": prompt} ], - max_tokens=80, + max_tokens=100, temperature=0.7 ) @@ -850,7 +851,8 @@ def post_to_wp(post_data, category, link, author, image_url, original_source, im "title": post_data["title"], "url": post_url } - tweet_text = generate_article_tweet(author, tweet_post, persona) + # Pass the summary to generate_article_tweet + tweet_text = generate_article_tweet(author, tweet_post, persona, summary=summary if summary else post_data["content"]) tweet_id, tweet_data = post_tweet(author, tweet_text, tweet_type="rss") if tweet_id: logger.info(f"Successfully tweeted for post: {post_data['title']} (Tweet ID: {tweet_id})")