fix: fix provider routing for podcasts and add a try block to catch podcast generation issues

This commit is contained in:
LUIS NOVO 2025-06-10 11:52:41 -03:00
parent 0a5504744c
commit 61b3583a57

View file

@ -111,35 +111,41 @@ class PodcastConfig(ObjectModel):
api_key_label = "GOOGLE_API_KEY" api_key_label = "GOOGLE_API_KEY"
llm_model_name = self.transcript_model llm_model_name = self.transcript_model
if self.provider == "gemini": if self.provider == "google":
tts_model = "geminimulti" tts_model = "gemini"
elif self.provider == "openai": elif self.provider == "openai":
tts_model = "openai" tts_model = "openai"
elif self.provider == "anthropic": elif self.provider == "anthropic":
tts_model = "anthropic" tts_model = "anthropic"
elif self.provider == "vertexai":
tts_model = "geminimulti"
elif self.provider == "elevenlabs": elif self.provider == "elevenlabs":
tts_model = "elevenlabs" tts_model = "elevenlabs"
logger.debug( logger.info(
f"Generating episode {episode_name} with config {conversation_config} and using model {llm_model_name}, tts model {tts_model}" f"Generating episode {episode_name} with config {conversation_config} and using model {llm_model_name}, tts model {tts_model}"
) )
audio_file = generate_podcast( try:
conversation_config=conversation_config, audio_file = generate_podcast(
text=text, conversation_config=conversation_config,
tts_model=tts_model, text=text,
llm_model_name=llm_model_name, tts_model=tts_model,
api_key_label=api_key_label, llm_model_name=llm_model_name,
longform=longform, api_key_label=api_key_label,
) longform=longform,
episode = PodcastEpisode( )
name=episode_name, episode = PodcastEpisode(
template=self.name, name=episode_name,
instructions=instructions, template=self.name,
text=str(text), instructions=instructions,
audio_file=audio_file, text=str(text),
) audio_file=audio_file,
episode.save() )
episode.save()
except Exception as e:
logger.error(f"Failed to generate episode {episode_name}: {e}")
raise
@field_validator( @field_validator(
"name", "podcast_name", "podcast_tagline", "output_language", "model" "name", "podcast_name", "podcast_tagline", "output_language", "model"