Skip to content

Split LangChainChatManager into Inheritance Hierarchy #261

@yangm2

Description

@yangm2

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 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBot implementation and other backend concernsenhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions