add longform option to podcast generation
This commit is contained in:
parent
d460b0947a
commit
4f9aa63b3e
3 changed files with 8 additions and 23 deletions
|
|
@ -32,7 +32,6 @@ class PodcastConfig(ObjectModel):
|
|||
transcript_model_provider: Optional[str] = None
|
||||
user_instructions: Optional[str] = None
|
||||
ending_message: Optional[str] = None
|
||||
wordcount: int = Field(ge=400, le=10000)
|
||||
creativity: float = Field(ge=0, le=1)
|
||||
provider: str = Field(default="openai")
|
||||
voice1: str
|
||||
|
|
@ -53,12 +52,12 @@ class PodcastConfig(ObjectModel):
|
|||
raise ValueError("Both voice1 and voice2 must be provided")
|
||||
return self
|
||||
|
||||
def generate_episode(self, episode_name, text, instructions=None):
|
||||
def generate_episode(self, episode_name, text, longform=False, instructions=None):
|
||||
self.user_instructions = (
|
||||
instructions if instructions else self.user_instructions
|
||||
)
|
||||
conversation_config = {
|
||||
"word_count": self.wordcount,
|
||||
"longform": longform,
|
||||
"conversation_style": self.conversation_style,
|
||||
"roles_person1": self.person1_role,
|
||||
"roles_person2": self.person2_role,
|
||||
|
|
@ -130,12 +129,6 @@ class PodcastConfig(ObjectModel):
|
|||
raise ValueError(f"{field.field_name} cannot be None or empty string")
|
||||
return value.strip()
|
||||
|
||||
@field_validator("wordcount")
|
||||
def validate_wordcount(cls, value):
|
||||
if not 400 <= value <= 6000:
|
||||
raise ValueError("Wordcount must be between 400 and 10000")
|
||||
return value
|
||||
|
||||
@field_validator("creativity")
|
||||
def validate_creativity(cls, value):
|
||||
if not 0 <= value <= 1:
|
||||
|
|
|
|||
|
|
@ -104,9 +104,6 @@ with templates_tab:
|
|||
[], dialogue_structures, "Dialogue Structure", key="dialogue_structures"
|
||||
)
|
||||
st.caption(f"Suggestions:{', '.join(dialogue_structures)}")
|
||||
pd_cfg["wordcount"] = st.slider(
|
||||
"Word Count", min_value=400, max_value=6000, step=50
|
||||
)
|
||||
pd_cfg["creativity"] = st.slider(
|
||||
"Creativity", min_value=0.0, max_value=1.0, step=0.05
|
||||
)
|
||||
|
|
@ -216,14 +213,6 @@ with templates_tab:
|
|||
key=f"dialogue_structure_{pd_config.id}",
|
||||
)
|
||||
st.caption(f"Suggestions:{', '.join(dialogue_structures)}")
|
||||
pd_config.wordcount = st.slider(
|
||||
"Word Count",
|
||||
min_value=400,
|
||||
max_value=6000,
|
||||
step=50,
|
||||
value=pd_config.wordcount,
|
||||
key=f"wordcount_{pd_config.id}",
|
||||
)
|
||||
pd_config.creativity = st.slider(
|
||||
"Creativity",
|
||||
min_value=0.0,
|
||||
|
|
@ -240,9 +229,6 @@ with templates_tab:
|
|||
)
|
||||
|
||||
if pd_config.transcript_model_provider not in transcript_provider_models:
|
||||
st.warning(
|
||||
f"Transcript Model Provider {pd_config.transcript_model_provider} not setup. Changing to default."
|
||||
)
|
||||
index = 0
|
||||
else:
|
||||
index = list(transcript_provider_models.keys()).index(
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ def chat_sidebar(current_notebook: Notebook, current_session: ChatSession):
|
|||
instructions = st.text_area(
|
||||
"Instructions", value=selected_template.user_instructions
|
||||
)
|
||||
podcast_length = st.radio(
|
||||
"Podcast Length",
|
||||
["Short (5-10 min)", "Long (20-30 min)"],
|
||||
)
|
||||
longform = podcast_length == "Long (20-30 min)"
|
||||
if len(context.get("note", [])) + len(context.get("source", [])) == 0:
|
||||
st.warning(
|
||||
"No notes or sources found in context. You don't want a boring podcast, right? So, add some context first."
|
||||
|
|
@ -94,6 +99,7 @@ def chat_sidebar(current_notebook: Notebook, current_session: ChatSession):
|
|||
selected_template.generate_episode(
|
||||
episode_name=episode_name,
|
||||
text=context,
|
||||
longform=longform,
|
||||
instructions=instructions,
|
||||
)
|
||||
st.success("Episode generated successfully")
|
||||
|
|
|
|||
Loading…
Reference in a new issue