Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use setup_logger in content_generator.py #186

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions podcastfy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
from typing import List, Optional, Dict, Any
import copy

import logging
# import logging

# Configure logging to show all levels and write to both file and console
""" logging.basicConfig(
level=logging.DEBUG, # Show all levels of logs
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('podcastfy.log'), # Save to file
logging.StreamHandler() # Print to console
]
) """
# """ logging.basicConfig(
# level=logging.DEBUG, # Show all levels of logs
# format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
# handlers=[
# logging.FileHandler('podcastfy.log'), # Save to file
# logging.StreamHandler() # Print to console
# ]
# ) """


logger = setup_logger(__name__)
Expand Down
14 changes: 9 additions & 5 deletions podcastfy/content_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
from langchain import hub
from podcastfy.utils.config_conversation import load_conversation_config
from podcastfy.utils.config import load_config
import logging
from podcastfy.utils.logger import setup_logger
# import logging
from langchain.prompts import HumanMessagePromptTemplate
from abc import ABC, abstractmethod

logger = logging.getLogger(__name__)

# logger = logging.getLogger(__name__)
logger = setup_logger(__name__)

class LLMBackend:
def __init__(
Expand Down Expand Up @@ -872,7 +873,7 @@ def generate_qa_content(
self.prompt_template, image_path_keys = self.__compose_prompt(num_images, longform)
self.parser = StrOutputParser()
self.chain = self.prompt_template | self.llm | self.parser

logger.debug(f"Prompt template: \n{self.prompt_template}")

# Prepare parameters using strategy
prompt_params = strategy.compose_prompt_params(
Expand All @@ -881,20 +882,23 @@ def generate_qa_content(
image_path_keys,
input_texts
)
logger.debug(f"Prompt params: \n{prompt_params}")

# Generate content using selected strategy
self.response = strategy.generate(
self.chain,
input_texts,
prompt_params
)
logger.debug(f"Raw response: \n{self.response}")

# Clean response using the same strategy
self.response = strategy.clean(
self.response,
self.content_generator_config
)


logger.debug(f"Clean response: \n{self.response}")
logger.info(f"Content generated successfully")

# Save output if requested
Expand Down