Skip to content
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
10 changes: 8 additions & 2 deletions podcastfy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from podcastfy.utils.config import Config, load_config
from podcastfy.utils.config_conversation import load_conversation_config
from podcastfy.utils.logger import setup_logger
from langchain_core.language_models.base import BaseLanguageModel
from typing import List, Optional, Dict, Any
import copy

Expand Down Expand Up @@ -51,6 +52,7 @@ def process_content(
text: Optional[str] = None,
model_name: Optional[str] = None,
api_key_label: Optional[str] = None,
llm_model: Optional[BaseLanguageModel] = None,
topic: Optional[str] = None,
longform: bool = False
):
Expand Down Expand Up @@ -85,7 +87,8 @@ def process_content(
is_local=is_local,
model_name=model_name,
api_key_label=api_key_label,
conversation_config=conv_config.to_dict()
conversation_config=conv_config.to_dict(),
llm_model=llm_model
)

combined_content = ""
Expand Down Expand Up @@ -287,8 +290,9 @@ def generate_podcast(
text: Optional[str] = None,
llm_model_name: Optional[str] = None,
api_key_label: Optional[str] = None,
llm_model: Optional[BaseLanguageModel] = None,
topic: Optional[str] = None,
longform: bool = False,
longform: bool = False
) -> Optional[str]:
"""
Generate a podcast or transcript from a list of URLs, a file containing URLs, a transcript file, or image files.
Expand Down Expand Up @@ -354,6 +358,7 @@ def generate_podcast(
text=text,
model_name=llm_model_name,
api_key_label=api_key_label,
llm_model=llm_model,
topic=topic,
longform=longform
)
Expand All @@ -380,6 +385,7 @@ def generate_podcast(
text=text,
model_name=llm_model_name,
api_key_label=api_key_label,
llm_model=llm_model,
topic=topic,
longform=longform
)
Expand Down
11 changes: 9 additions & 2 deletions podcastfy/content_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from langchain.prompts import HumanMessagePromptTemplate
from abc import ABC, abstractmethod

from langchain_core.language_models.base import BaseLanguageModel

logger = logging.getLogger(__name__)


Expand All @@ -34,6 +36,7 @@ def __init__(
max_output_tokens: int,
model_name: str,
api_key_label: str = "GEMINI_API_KEY",
llm_model: Optional[BaseLanguageModel] = None
):
"""
Initialize the LLMBackend.
Expand All @@ -56,7 +59,9 @@ def __init__(
"frequency_penalty": 0.75, # Avoid repetition
}

if is_local:
if llm_model:
self.llm = llm_model
elif is_local:
self.llm = Llamafile() # replace with ollama
elif (
"gemini" in self.model_name.lower()
Expand Down Expand Up @@ -708,7 +713,8 @@ def __init__(
is_local: bool=False,
model_name: str="gemini-1.5-pro-latest",
api_key_label: str="GEMINI_API_KEY",
conversation_config: Optional[Dict[str, Any]] = None
conversation_config: Optional[Dict[str, Any]] = None,
llm_model: Optional[BaseLanguageModel] = None,
):
"""
Initialize the ContentGenerator.
Expand Down Expand Up @@ -749,6 +755,7 @@ def __init__(
),
model_name=model_name,
api_key_label=api_key_label,
llm_model=llm_model
)

self.llm = llm_backend.llm
Expand Down