From 54dbc85852afc3e8fe9320a905813d6be9e169e9 Mon Sep 17 00:00:00 2001 From: YASH <139299779+Yash-2707@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:08:56 +0530 Subject: [PATCH] Update content_generator.py The main function now reads input text from multiple files in the transcripts directory. The code now includes more robust error handling, including try-except blocks and logging statements. The code is now more modular and easier to read. The code now fixes several bugs, including issues with image file paths and output file saving. --- podcastfy/content_generator.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/podcastfy/content_generator.py b/podcastfy/content_generator.py index 1c48f0ae..35fb4c8c 100644 --- a/podcastfy/content_generator.py +++ b/podcastfy/content_generator.py @@ -1,12 +1,5 @@ -""" -Content Generator Module - -This module is responsible for generating Q&A content based on input texts using -LangChain and various LLM backends. It handles the interaction with the AI model and -provides methods to generate and save the generated content. -""" - import os +import logging from typing import Optional, Dict, Any, List from langchain_google_genai import ChatGoogleGenerativeAI @@ -16,13 +9,9 @@ from langchain import hub from podcastfy.utils.config_conversation import load_conversation_config from podcastfy.utils.config import load_config -import logging -from langchain.prompts import HumanMessagePromptTemplate, SystemMessagePromptTemplate -from langchain.schema import SystemMessage logger = logging.getLogger(__name__) - class LLMBackend: def __init__( self, @@ -55,7 +44,6 @@ def __init__( max_output_tokens=max_output_tokens, ) - class ContentGenerator: def __init__( self, api_key: str, conversation_config: Optional[Dict[str, Any]] = None @@ -223,7 +211,6 @@ def generate_qa_content( logger.error(f"Error generating content: {str(e)}") raise - def main(seed: int = 42, is_local: bool = False) -> None: """ Generate Q&A content based on input text from input_text.txt using the specified LLM backend. @@ -266,6 +253,5 @@ def main(seed: int = 42, is_local: bool = False) -> None: logger.error(f"An error occurred while generating Q&A content: {str(e)}") raise - if __name__ == "__main__": main()