From bdb12eb2ff5c7981f8fbbbd7eee2230649cd8efc Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Fri, 5 Apr 2024 18:51:40 +0100 Subject: [PATCH] fix: rendering of podcast description in template --- app/core/podcast/eleventify.py | 10 ++++------ app/core/podcast/template/episode.njk.jinja | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/core/podcast/eleventify.py b/app/core/podcast/eleventify.py index 875236ce..047bb60e 100644 --- a/app/core/podcast/eleventify.py +++ b/app/core/podcast/eleventify.py @@ -41,14 +41,13 @@ def create_episode_summary(content: str, episode: str) -> str: """ - Using Together AI's Inference API, create a summary to use as - the Facebook video description. + Using Together AI's Inference API, create a summary to use as episode description. https://docs.together.ai/reference/complete """ - prompt = f"Given the details of today's episode below, write a very brief summary to use as a description for the media file. Your summary should not exceed 2 sentences.\n\n```\n{content}\n```" + prompt = f"Given the details of today's episode below, write a very brief summary to use as a description for the media file. Your summary should be a single paragraph, not exceeding 2 sentences.\n\n```\n{content}\n```" # model = "lmsys/vicuna-13b-v1.5-16k" # model = "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO" @@ -73,13 +72,12 @@ def create_episode_summary(content: str, episode: str) -> str: if any(string in first_line for string in unwanted): # Remove the first line from result - cleaned_up = "\n".join(result.split("\n")[1:]) - result = cleaned_up.strip().replace("\n", " ") + result = "\n".join(result.split("\n")[1:]) if result.strip() == "": logger.warning("Podcast episode summary is empty after removing unwanted text") result = fallback - return result + return result.replace("\n", " ") # Remove newlines else: logger.error("Podcast episode summary is empty") return fallback diff --git a/app/core/podcast/template/episode.njk.jinja b/app/core/podcast/template/episode.njk.jinja index 0de78edf..50caa310 100644 --- a/app/core/podcast/template/episode.njk.jinja +++ b/app/core/podcast/template/episode.njk.jinja @@ -1,6 +1,6 @@ --- title: "{{ title }}" -description: {{ description }} +description: "{{ description }}" tags: episode episode: "{{ episode }}" date: {{ date }}