From 5b0ad43fbb0b0d378cb0e0adca49471e4ade7c75 Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Tue, 19 Dec 2023 18:48:56 +0000 Subject: [PATCH] refactor: change prompt and do not use one-sentence summary --- app/core/podcast/content.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/core/podcast/content.py b/app/core/podcast/content.py index 7d326317..220f2812 100644 --- a/app/core/podcast/content.py +++ b/app/core/podcast/content.py @@ -12,7 +12,8 @@ from pydantic import HttpUrl from app.core.db.models import Article, Episode -from app.core.summarization.backends.together import brief_summary + +# from app.core.summarization.backends.together import brief_summary from app.core.utilities import ( DATA_DIR, # OPENAI_API_KEY, @@ -82,7 +83,9 @@ def create_transcript(news: list[dict[str, str]], dest: str, summarizer: Callabl # Add the article to the list for the corresponding source articles_by_source[source].append(article) - prompt = f"The date is {today_human_readable}. You are {podcast_host}, a fun and witty scriptwriter, content creator and podcast host. You host the Zed News Podcast - a news and current affairs podcast which runs Monday to Friday. Your assistant has gathered the news from various sources as indicated below. Study the content, consolidate any similar news items from different sources, and organize the news in a logical, coherent manner so it's easy to follow. You can then go ahead and present today's episode (number {get_episode_number()}), ensuring that you cover all the news from all the sources, as curated by your assistant. At the end, add a fun and witty remark informing your audience that you are actually an AI, and not a human. Remember: leave no news item behind, and do not repeat content.\n\n" + # prompt = f"The date is {today_human_readable}. You are {podcast_host}, a fun and witty scriptwriter, content creator and podcast host. You host the Zed News Podcast - a news and current affairs podcast which runs Monday to Friday. Your assistant has gathered the news from various sources as indicated below. Study the content, consolidate any similar news items from different sources, and organize the news in a logical, coherent manner so it's easy to follow. You can then go ahead and present today's episode (number {get_episode_number()}), ensuring that you cover all the news from all the sources, as curated by your assistant. At the end, add a fun and witty remark informing your audience that you are actually an AI, and not a human. Remember: leave no news item behind, and do not repeat content.\n\n" # noqa: W505 + + prompt = f"The date is {today_human_readable}. {podcast_host}, a bot, hosts the Zed News Podcast - a news and current affairs podcast which runs Monday to Friday. Your task, as an accomplished content creater and comedian, is to produce content which she'll read out word-for-word as she presents today's episode (number {get_episode_number()}). Ensure that you cover all the news from all the sources, presented in a logical, coherent manner, with any similar news items from different sources appropriately consolidated. At the end, Ayanda wants her audience to know that she's actually not a human. Remember: leave no news item behind, do not repeat content and ensure your output is presented in a human-readable style.\n\n" metadata = f"Title: Zed News Podcast episode {get_episode_number()}\nDate: {today_human_readable}\nHost: {podcast_host}\n\n" @@ -94,11 +97,16 @@ def create_transcript(news: list[dict[str, str]], dest: str, summarizer: Callabl title = article["title"] text = article["content"] - if len(news) < 15: - # If there are less than 15 articles, summarize each article in the usual way - summary = summarizer(text, title) - else: - summary = brief_summary(text, title) + # if len(news) < 15: + # # If there are less than 15 articles, summarize each article in the usual way + # summary = summarizer(text, title) + # else: + # summary = brief_summary(text, title) + + summary = summarizer(text, title) + + if summary.strip().startswith("Summary: "): + summary = summary.replace("Summary: ", "") update_article_with_summary(title, article["url"], today, summary)