feat(config): Centralize configuration and improve modularity #101
+140
−93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a centralized configuration management system and significantly enhances the modularity of the application. Previously, configuration settings were scattered across environment variables, command-line arguments, and hardcoded defaults, resulting in a codebase that was difficult to maintain and extend.
Key Changes:
config.py
Module: Introduces a newconfig.py
module containing aConfig
dataclass that encapsulates all application settings. This serves as a single source of truth, loading configuration values intelligently from environment variables and command-line arguments with a well-defined precedence.main.py
: Updated to utilize the newConfig
object, removing scatteredos.getenv
calls and simplifying argument parsing. This results in a cleaner and more readable application entry point.llm.py
module no longer relies on a global state (GLOBAL_LLM
). Instead, anLLM
instance is explicitly created inmain.py
and passed as a dependency to functions that require it (e.g.,rerank_paper
inrecommender.py
,render_email
inconstruct_email.py
). This promotes explicit dependency injection, improving component independence and testability.set_global_llm
) now accept the centralizedConfig
object or relevant subsets, leading to clearer and more maintainable function signatures.Benefits:
This refactoring marks a foundational improvement to the project’s architecture, establishing a robust framework for scalable and maintainable future development.