codeforpdx / codeforpdx/tenantfirstaid
Split LangChainChatManager into Inheritance Hierarchy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13
- Forks
- 21
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 3
Description
Description
Refactor the LangChainChatManager class into a base class and model-specific child classes to handle differences between Gemini model versions that leak through the LangChain API.
Context
- Different Gemini model versions have different capabilities and behaviors
- LangChain API doesn't fully abstract these differences
- Model-specific handling is currently mixed in a single class
- Inheritance hierarchy would make model-specific code paths explicit
- Discussion: https://github.com/codeforpdx/tenantfirstaid/pull/222#issuecomment-3848942382
Proposed Structure
class GeminiChatManager:
"""Base class for Gemini-based chat management"""
# Common functionality across all Gemini models
class Gemini2_5ChatManager(GeminiChatManager):
"""Child class for Gemini 2.5-specific features"""
# Handles Gemini 2.5-specific quirks and features
class Gemini3PlusChatManager(GeminiChatManager):
"""Child class for Gemini 3+ specific features"""
# Handles Gemini 3+ specific quirks and features
Rationale
- Different Gemini model versions have different capabilities and behaviors
- LangChain API doesn't fully abstract these differences
- Model-specific handling is currently mixed in a single class
- Inheritance hierarchy would make model-specific code paths explicit
Benefits
- Clear separation of model-specific logic
- Easier to add support for new Gemini versions
- Better testability of model-specific features
- Reduced conditional logic in core class
Impact
Moderate refactoring of backend/tenantfirstaid/langchain_chat_manager.py and related tests
Priority
🟡 MEDIUM
Parent Issue
#254
References
- PR #222 comment: https://github.com/codeforpdx/tenantfirstaid/pull/222#issuecomment-3848942382
- LangChain Google Generative AI integration docs: https://docs.langchain.com/oss/python/integrations/chat/google_generative_ai
- Current implementation:
backend/tenantfirstaid/langchain_chat_manager.py
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with backend/tenantfirstaid/langchain_chat_manager.py and inspect the related tests to map the current Gemini model-specific behavior and conditional logic. Separate shared behavior from Gemini 2.5 and Gemini 3+ handling according to the proposed hierarchy, then run the related tests to verify the refactor preserves behavior and makes model-specific paths testable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100