1111import typer
1212import yaml
1313from podcastfy .content_parser .content_extractor import ContentExtractor
14- from podcastfy .content_generator import ContentGenerator
14+ from podcastfy .content_generator import ContentGenerator , LLMBackendType
1515from podcastfy .text_to_speech import TextToSpeech
1616from podcastfy .utils .config import Config , load_config
1717from podcastfy .utils .config_conversation import load_conversation_config
@@ -47,12 +47,12 @@ def process_content(
4747 config : Optional [Dict [str , Any ]] = None ,
4848 conversation_config : Optional [Dict [str , Any ]] = None ,
4949 image_paths : Optional [List [str ]] = None ,
50- is_local : bool = False ,
50+ llm_type : LLMBackendType = LLMBackendType . LITELLM ,
5151 text : Optional [str ] = None ,
5252 model_name : Optional [str ] = None ,
5353 api_key_label : Optional [str ] = None ,
5454 topic : Optional [str ] = None ,
55- longform : bool = False
55+ longform : bool = False ,
5656):
5757 """
5858 Process URLs, a transcript file, image paths, or raw text to generate a podcast or transcript.
@@ -82,22 +82,24 @@ def process_content(
8282 content_extractor = ContentExtractor ()
8383
8484 content_generator = ContentGenerator (
85- is_local = is_local ,
85+ llm_type ,
8686 model_name = model_name ,
8787 api_key_label = api_key_label ,
88- conversation_config = conv_config .to_dict ()
88+ conversation_config = conv_config .to_dict (),
8989 )
9090
9191 combined_content = ""
92-
92+
9393 if urls :
9494 logger .info (f"Processing { len (urls )} links" )
9595 contents = [content_extractor .extract_content (link ) for link in urls ]
9696 combined_content += "\n \n " .join (contents )
9797
9898 if text :
9999 if longform and len (text .strip ()) < 100 :
100- logger .info ("Text too short for direct long-form generation. Extracting context..." )
100+ logger .info (
101+ "Text too short for direct long-form generation. Extracting context..."
102+ )
101103 expanded_content = content_extractor .generate_topic_content (text )
102104 combined_content += f"\n \n { expanded_content } "
103105 else :
@@ -117,13 +119,15 @@ def process_content(
117119 combined_content ,
118120 image_file_paths = image_paths or [],
119121 output_filepath = transcript_filepath ,
120- longform = longform
122+ longform = longform ,
121123 )
122124
123125 if generate_audio :
124126 api_key = None
125127 if tts_model != "edge" :
126- api_key = getattr (config , f"{ tts_model .upper ().replace ('MULTI' , '' )} _API_KEY" )
128+ api_key = getattr (
129+ config , f"{ tts_model .upper ().replace ('MULTI' , '' )} _API_KEY"
130+ )
127131
128132 text_to_speech = TextToSpeech (
129133 model = tts_model ,
@@ -183,6 +187,12 @@ def main(
183187 text : str = typer .Option (
184188 None , "--text" , "-txt" , help = "Raw text input to be processed"
185189 ),
190+ llm_type : str = typer .Option (
191+ None ,
192+ "--llm-type" ,
193+ "-lt" ,
194+ help = "LLM type for content generation (litellm(default), ollama, google) " ,
195+ ),
186196 llm_model_name : str = typer .Option (
187197 None , "--llm-model-name" , "-m" , help = "LLM model name for transcript generation"
188198 ),
@@ -193,10 +203,10 @@ def main(
193203 None , "--topic" , "-tp" , help = "Topic to generate podcast about"
194204 ),
195205 longform : bool = typer .Option (
196- False ,
197- "--longform" ,
198- "-lf" ,
199- help = "Generate long-form content (only available for text input without images)"
206+ False ,
207+ "--longform" ,
208+ "-lf" ,
209+ help = "Generate long-form content (only available for text input without images)" ,
200210 ),
201211):
202212 """
@@ -226,12 +236,12 @@ def main(
226236 generate_audio = not transcript_only ,
227237 conversation_config = conversation_config ,
228238 config = config ,
229- is_local = is_local ,
239+ llm_type = llm_type ,
230240 text = text ,
231241 model_name = llm_model_name ,
232242 api_key_label = api_key_label ,
233243 topic = topic ,
234- longform = longform
244+ longform = longform ,
235245 )
236246 else :
237247 urls_list = urls or []
@@ -250,12 +260,12 @@ def main(
250260 config = config ,
251261 conversation_config = conversation_config ,
252262 image_paths = image_paths ,
253- is_local = is_local ,
263+ llm_type = llm_type ,
254264 text = text ,
255265 model_name = llm_model_name ,
256266 api_key_label = api_key_label ,
257267 topic = topic ,
258- longform = longform
268+ longform = longform ,
259269 )
260270
261271 if transcript_only :
@@ -283,7 +293,7 @@ def generate_podcast(
283293 config : Optional [Dict [str , Any ]] = None ,
284294 conversation_config : Optional [Dict [str , Any ]] = None ,
285295 image_paths : Optional [List [str ]] = None ,
286- is_local : bool = False ,
296+ llm_type : LLMBackendType = LLMBackendType . LITELLM ,
287297 text : Optional [str ] = None ,
288298 llm_model_name : Optional [str ] = None ,
289299 api_key_label : Optional [str ] = None ,
@@ -302,7 +312,7 @@ def generate_podcast(
302312 config (Optional[Dict[str, Any]]): User-provided configuration dictionary.
303313 conversation_config (Optional[Dict[str, Any]]): User-provided conversation configuration dictionary.
304314 image_paths (Optional[List[str]]): List of image file paths to process.
305- is_local (bool ): Whether to use a local LLM. Defaults to False .
315+ llm_type (LLMBackendType ): LLM backend type for content generation .
306316 text (Optional[str]): Raw text input to be processed.
307317 llm_model_name (Optional[str]): LLM model name for content generation.
308318 api_key_label (Optional[str]): Environment variable name for LLM API key.
@@ -355,7 +365,7 @@ def generate_podcast(
355365 model_name = llm_model_name ,
356366 api_key_label = api_key_label ,
357367 topic = topic ,
358- longform = longform
368+ longform = longform ,
359369 )
360370 else :
361371 urls_list = urls or []
@@ -381,7 +391,7 @@ def generate_podcast(
381391 model_name = llm_model_name ,
382392 api_key_label = api_key_label ,
383393 topic = topic ,
384- longform = longform
394+ longform = longform ,
385395 )
386396
387397 except Exception as e :
0 commit comments