Skip to content

Commit

Permalink
refactor: tweak the together.ai invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
engineervix committed Dec 12, 2023
1 parent 40c12ba commit 39199f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
23 changes: 14 additions & 9 deletions app/core/podcast/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,40 @@ 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"<human>: You are {podcast_host}, an accomplished, fun and witty scriptwriter, content creator and podcast host. You have a news & current affairs podcast which runs Monday to Friday. Your secretary has gathered the news from various sources as presented 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"<human>: You are {podcast_host}, an accomplished, fun and witty scriptwriter, content creator and podcast host. You have a news & 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"

metadata = f"Title: Zed News Podcast episode {get_episode_number()}\nDate: {today_human_readable}\nHost: {podcast_host}\n\n"
metadata = f"Title: Zed News Podcast episode {await get_episode_number()}\nDate: {today_human_readable}\nHost: {podcast_host}\n\n"

content = ""

counter = 0
for source in articles_by_source:
# Iterate over each article in the source
for index, article in enumerate(articles_by_source[source], start=1):
for article in articles_by_source[source]:
title = article["title"]
text = article["content"]
summary = summarizer(text, title)

await update_article_with_summary(title, article["url"], today, summary)

content += f"{index}. '{title}' (source {source})"
counter += 1

content += f"{counter}. '{title}' (source: {source})"
content += f"\n{summary.strip()}\n\n"

notes = prompt + "```" + metadata + "News Items:\n\n" + content + "```\n<bot>:"
notes = prompt + "```" + metadata + "News Items:\n\n" + content + "```<bot>:"

model = "togethercomputer/llama-2-70b-chat"
temperature = 0.7
max_tokens = 1792
model = "mistralai/Mixtral-8x7B-Instruct-v0.1"
temperature = 0.4
top_p = 0.5
max_tokens = 4096
together.api_key = TOGETHER_API_KEY
output = together.Complete.create(
prompt=notes,
model=model,
temperature=temperature,
top_p=top_p,
max_tokens=max_tokens,
repetition_penalty=1.1,
)
logging.info(output)

Expand Down
2 changes: 1 addition & 1 deletion app/core/summarization/backends/together.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def summarize(content: str, title: str) -> str:
https://docs.together.ai/reference/complete
"""

prompt = f"<human>: Summarize the following news entry, in not more than two sentences. Your summary should be sweet, informative and engaging.\n\n {content}\n<bot>:"
prompt = f"<human>: 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<bot>:"
model = "togethercomputer/llama-2-70b-chat"
temperature = 0.7
max_tokens = 512
Expand Down
2 changes: 1 addition & 1 deletion social.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def create_facebook_post(content: str) -> str:
prompt = f"<human>: 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<bot>:"
model = "togethercomputer/llama-2-70b-chat"
temperature = 0.7
max_tokens = 512
max_tokens = 768

output = together.Complete.create(
prompt=prompt,
Expand Down

0 comments on commit 39199f1

Please sign in to comment.