-
Notifications
You must be signed in to change notification settings - Fork 12
Split LangChainChatManager into Inheritance Hierarchy #261
Copy link
Copy link
Open
Labels
backendBot implementation and other backend concernsBot implementation and other backend concernsenhancementNew feature or requestNew feature or request
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: Port to langchain #222 (comment)
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 featuresRationale
- 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
References
- PR Port to langchain #222 comment: Port to langchain #222 (comment)
- 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backendBot implementation and other backend concernsBot implementation and other backend concernsenhancementNew feature or requestNew feature or request