Files
slide-translate/llm.py
nite 3eef042111 refactor(app): Extract PDF conversion logic into a separate module
The main.py script was becoming monolithic, containing all the logic for PDF conversion, image path simplification, and content refinement. This change extracts these core functionalities into a new `pdf_convertor` module.

This refactoring improves the project structure by:
- Enhancing modularity and separation of concerns.
- Making the main.py script a cleaner, high-level orchestrator.
- Improving code readability and maintainability.

The functions `convert_pdf_to_markdown`, `save_md_images`, and `refine_content` are now imported from the `pdf_convertor` module and called from the main execution block.
2025-10-27 20:02:02 +11:00

24 lines
672 B
Python
Executable File

import configparser
import os
def set_gemini_api_key() -> None:
config = configparser.ConfigParser()
config.read("config.ini")
google_api_key = config.get("llm", "GOOGLE_API_KEY", fallback=None)
if not os.environ.get("GOOGLE_API_KEY"):
if google_api_key:
os.environ["GOOGLE_API_KEY"] = google_api_key
else:
raise ValueError(
"Error: GOOGLE_API_KEY not found in config.ini or environment variables"
)
return
def get_model_name() -> str:
config = configparser.ConfigParser()
config.read("config.ini")
return config.get("llm", "MODEL_NAME", fallback="gemini-2.5-flash")