From c1b62372b4b218f01146b912ddc1d45642ea472c Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Tue, 12 Dec 2023 22:46:45 +0000 Subject: [PATCH] refactor: tweak the content generation --- app/core/podcast/content.py | 14 +++++++++++++- app/core/summarization/backends/together.py | 2 +- social.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/core/podcast/content.py b/app/core/podcast/content.py index 5c8f6bf8..de361067 100644 --- a/app/core/podcast/content.py +++ b/app/core/podcast/content.py @@ -65,10 +65,19 @@ async def create_transcript(news: list[dict[str, str]], dest: str, summarizer: C # Add the article to the list for the corresponding source articles_by_source[source].append(article) - prompt = f": You are {podcast_host}, an accomplished, fun and witty scriptwriter, content creator and podcast host. You have a news and current affairs podcast which runs Monday to Friday. Your secretary has gathered the news from various sources as indicated below, so go ahead and present today's episode. Add a fun and witty remark at the end, informing your audience that you are actually an AI, and not a human.\n\n" + prompt = f": You are {podcast_host}, an accomplished, fun and witty scriptwriter, content creator and podcast host. You have a news and current affairs podcast which runs Monday to Friday. Your secretary has gathered the news from various sources as indicated below. Study the content, then go ahead and present today's episode. It is important that you cover EVERYTHING, do not leave out anything. Feel free to consolidate any similar news items from different sources, and present the news in a logical sequence, based on common themes. At the end, add a fun and witty remark informing your audience that you are actually an AI, and not a human.\n\n" metadata = f"Title: Zed News Podcast episode {await get_episode_number()}\nDate: {today_human_readable}\nHost: {podcast_host}\n\n" + unwanted_text = [ + "Sure, here's a summary of the news entry in two sentences:", + "Sure, here's a summary of the news entry in not more than two sentences:", + "Sure, I can help you with that!", + "Here's a summary of the news entry in two sentences:", + "Here's a summary of the news entry in not more than two sentences:", + "Sure! Here's a possible summary of the news entry:", + ] + content = "" counter = 0 for source in articles_by_source: @@ -78,6 +87,9 @@ async def create_transcript(news: list[dict[str, str]], dest: str, summarizer: C text = article["content"] summary = summarizer(text, title) + for text in unwanted_text: + summary = summary.replace(text, "") + await update_article_with_summary(title, article["url"], today, summary) counter += 1 diff --git a/app/core/summarization/backends/together.py b/app/core/summarization/backends/together.py index e6e2ebb8..9ce37261 100644 --- a/app/core/summarization/backends/together.py +++ b/app/core/summarization/backends/together.py @@ -14,7 +14,7 @@ def summarize(content: str, title: str) -> str: https://docs.together.ai/reference/complete """ - prompt = f": You are a distinguished news editor and content publisher, write a summary of the following news entry, in not more than two sentences. Your summary should be sweet, informative and engaging.\n\n {content}\n:" + prompt = f": You are a distinguished news editor and content publisher, summarize the following news entry, in not more than two sentences. Your summary should be sweet, informative and engaging.\n\n {content}\n:" model = "togethercomputer/llama-2-70b-chat" temperature = 0.7 max_tokens = 512 diff --git a/social.py b/social.py index b39a72ac..8f3035ab 100644 --- a/social.py +++ b/social.py @@ -73,7 +73,7 @@ def create_facebook_post(content: str) -> str: https://docs.together.ai/reference/complete """ - prompt = f": You are a social media marketing guru. You have been hired by a podcaster to create a nice facebook post (max 130 words) inviting people to listen to today's podcast whose transcript is below. Highlight some interesting news items, appropriately paraphrasing them to grab the attention of your audience. Also, appropriately utilize bullet points, emojis, whitespace and hashtags where necessary. Do not add the link to the podcast as it will be added automatically.\n\n```{content}\n```\n:" + prompt = f": You are a social media marketing guru. You have been hired by a podcaster to create a nice, short and catchy facebook post (max 130 words) inviting people to listen to today's podcast whose transcript is below. Highlight some interesting news items, appropriately paraphrasing them to grab the attention of your audience. Also, appropriately utilize bullet points, emojis, whitespace and hashtags where necessary. Do not add the link to the podcast as it will be added automatically.\n\n```{content}\n```\n:" model = "togethercomputer/llama-2-70b-chat" temperature = 0.7 max_tokens = 768