Skip to content

Commit

Permalink
refactor: change prompt and do not use one-sentence summary
Browse files Browse the repository at this point in the history
  • Loading branch information
engineervix committed Dec 19, 2023
1 parent c13067f commit 5b0ad43
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/core/podcast/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"

Expand All @@ -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)

Expand Down

0 comments on commit 5b0ad43

Please sign in to comment.