storm
storm copied to clipboard
feat(lm): Improved Modularity and Maintainability for LLM Integration
This pull request introduces a significant refactor of how LLMs are integrated into the STORM framework.
⚠️ Further testing is needed for other LLMs before a merge is considered. Please read Next Steps.
Justification:
The previous structure, where all LLM classes were defined within a single lm.py file, was becoming increasingly difficult to manage as more LLM providers were added. This monolithic approach hindered code readability, maintainability, and scalability.
This refactor addresses these issues by:
- Enhancing Modularity: Organizing LLM classes into a dedicated
providerssubpackage promotes a more modular design. Each provider (OpenAI, Anthropic, DeepSeek, etc.) has its own file, making it easier to locate and maintain code related to specific LLMs. - Improving Scalability: The new structure facilitates easier integration of future LLM providers without cluttering the existing codebase.
- Increasing Readability: Separating the LLM implementations into distinct files improves code readability and makes it easier for developers to understand the different LLM integrations.
Changes Made:
- New Provider Subpackage: Created a new directory structure under
knowledge_storm/lm/providers, with each LLM class residing in its own file. - File Renaming: Renamed
lm.pytollm_base.pyto resolve an import conflict. Imports in other files have been updated accordingly. - Backwards Compatibility: Preserved backwards compatibility through reassignments in
llm_base.pyto prevent breaking existing code. However, importing directly fromllm_base.pyshould now be considered deprecated. - Testing: Only the DeepSeek model has been tested due to limited API access. DeepSeek ran three consecutive times without issue.
Next Steps:
- Comprehensive Testing: As I do not have access to the other APIs, further testing of the refactored code with different LLM providers is required. However, I do not think there would be any issues.
Please let me know if any changes are needed.