Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1Panel dev MaxKB Model Provider Plugin System

From Leeroopedia
Knowledge Sources
Domains Model_Provider, Design_Patterns
Last Updated 2026-10-10 00:00 GMT

Overview

A plugin architecture pattern that decouples model vendor integration from the core system via abstract interfaces, builder-based registration, and an enum-based provider registry.

Description

The Model Provider Plugin System is MaxKB's approach to supporting 21+ model vendors (OpenAI, Anthropic, Gemini, Ollama, vLLM, etc.) without coupling the core codebase to any specific vendor. The system is built on three abstractions:

  • IModelProvider — Abstract interface that each vendor implements to register its models
  • ModelInfoManage — Registry with a fluent builder pattern for registering ModelInfo entries (name, type, credential, model class)
  • ModelProvideConstants — Enum of singleton provider instances, resolved at runtime by string key

At runtime, get_model() resolves the provider from the enum, decrypts RSA-encrypted credentials, and calls MaxKBBaseModel.new_instance() to produce a LangChain-compatible model. This design allows adding new vendors by implementing one class and registering one enum entry.

Usage

Use this principle when designing:

  • Multi-vendor model integration systems
  • Plugin architectures with runtime-discoverable providers
  • Credential management with encryption for multiple vendors

Theoretical Basis

The system follows the Abstract Factory and Registry patterns:

# Abstract algorithm description (NOT real implementation)
# 1. Vendor implements IModelProvider and registers models
class VendorProvider(IModelProvider):
    def get_model_info_manage(self):
        return ModelInfoManage.builder() \
            .append_model_info(ModelInfo(name, type, credential, model_class)) \
            .build()

# 2. Vendor is registered in the enum registry
class ProviderConstants(Enum):
    vendor_name = VendorProvider()

# 3. Runtime instantiation resolves provider → model
provider = ProviderConstants[provider_key].value
model = provider.get_model(model_type, model_name, decrypted_credentials)

The credential encryption layer uses RSA for sensitive fields (API keys), with `encryption_dict()` masking values for display and `rsa_long_decrypt()` for runtime use.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment