feat: Add a Unified Model Providers configuration by HimavarshaVS · Pull Request #10565 · langflow-ai/langflow (original) (raw)

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Introduces new v1 API endpoints for model management and provider discovery, integrating with a DatabaseVariableService to track user-specific model enablement and defaults. Concurrently, updates 17 starter project JSON templates to replace provider-specific language model inputs with a unified, dynamic ModelInput-based configuration, and removes re-exported OpenAI model constants.

Changes

Cohort / File(s) Summary
New Model Management API src/backend/base/langflow/api/router.py, src/backend/base/langflow/api/v1/__init__.py Registered two new routers (models_router and model_options_router) in the v1 API module; exposed routers in public API exports.
Model Providers & Listing Endpoints src/backend/base/langflow/api/v1/models.py Added 8 new endpoints: list_model_providers(), list_models(), get_model_provider_mapping(), get_enabled_providers(), get_enabled_models(), update_enabled_models(), get_default_model(), set_default_model(), clear_default_model(). Integrates DatabaseVariableService for persistence of user-scoped disabled/default models. Introduced ModelStatusUpdate and DefaultModelRequest data models.
Model Options Endpoints src/backend/base/langflow/api/v1/model_options.py Added two GET endpoints under /model_options: get_language_model_options_endpoint() and get_embedding_model_options_endpoint() for returning user-specific model options.
Variable API Updates & Validation src/backend/base/langflow/api/v1/variable.py Added reserved-variable validation for model provider keys via validate_model_provider_key(). Implemented filtering to exclude internal variables (names starting and ending with __) from read responses. Imported model provider mapping utilities.
OpenAI Constants Cleanup src/backend/base/langflow/base/models/openai_constants.py Removed forward re-exports of OPENAI_EMBEDDING_MODEL_NAMES and OPENAI_MODEL_NAMES and their __all__ entries.
Starter Project Refactoring src/backend/base/langflow/initial_setup/starter_projects/{Basic Prompt Chaining, Basic Prompting, Blog Writer, Custom Component Generator, Financial Report Parser, Invoice Summarizer, Memory Chatbot, News Aggregator, Nvidia Remix, Pokédex Agent, Price Deal Finder, Research Translation Loop, SEO Keyword Generator, SaaS Pricing, Search agent, Social Media Agent, Text Sentiment Analysis}.json Replaced provider-specific LanguageModelComponent/AgentComponent inputs (DropdownInput for provider/model_name, static inputs per provider) with unified ModelInput-based configuration. Updated node/edge IDs, removed legacy provider-specific fields (e.g., openai_api_base, base_url, project_id, max_output_tokens), renamed API key display labels, and regenerated graph positions. Migrated component build logic from explicit per-provider branches to centralized get_llm pathway.

Sequence Diagram(s)

sequenceDiagram actor User participant Client participant ModelsAPI as /api/v1/models participant VariableService as DatabaseVariableService participant UnifiedModels as Unified Models Catalog

User->>Client: Request list of enabled models for language type
Client->>ModelsAPI: GET /models/enabled?model_names=...
ModelsAPI->>UnifiedModels: get_unified_models_detailed()
UnifiedModels-->>ModelsAPI: Model metadata (provider, deprecated, etc.)
ModelsAPI->>VariableService: Fetch user disabled-models list
VariableService-->>ModelsAPI: Disabled model IDs
ModelsAPI->>ModelsAPI: Filter by provider status + disabled list
ModelsAPI-->>Client: {provider: {model_id: enabled}}

User->>Client: Enable/disable specific model
Client->>ModelsAPI: POST /models/enabled (ModelStatusUpdate[])
ModelsAPI->>VariableService: Update disabled-models variable
VariableService-->>ModelsAPI: ✓ Persisted
ModelsAPI-->>Client: Success

User->>Client: Set default language model
Client->>ModelsAPI: POST /models/default (DefaultModelRequest)
ModelsAPI->>VariableService: Store default-model JSON
VariableService-->>ModelsAPI: ✓ Persisted
ModelsAPI-->>Client: {provider, model_name, model_type}

Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Areas requiring extra attention:

Suggested labels

enhancement, size:L, lgtm

Suggested reviewers

Pre-merge checks and finishing touches

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR adds 8+ new API endpoints in models.py, new model_options.py router with 2 endpoints, variable.py modifications for model provider validation, and database migrations, but includes no accompanying test files or test coverage for the new functionality. Add comprehensive tests for new endpoints (models.py, model_options.py), model provider validation in variable.py, database migrations, and DatabaseVariableService operations with category field.
Test Quality And Coverage ⚠️ Warning No test files found for new implementations in models.py, model_options.py, and variable.py modifications covering 8+ endpoints with async operations and complex validation logic. Add comprehensive pytest test coverage for all new endpoints including async tests, error handling, user isolation, and blocking call validation in variable.py endpoints.
Test File Naming And Structure ⚠️ Warning PR adds two new API files with 10+ endpoints and modifies critical validation logic but includes no corresponding test files despite established repository test patterns. Add test files: test_models.py for 8+ model endpoints, test_model_options.py for 2 new endpoints, and extend test_variable.py for reserved-variable validation logic, following async/pytest patterns established in repository.

✅ Passed checks (4 passed)

Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main objective: introducing unified model provider configuration via new API endpoints and variable management improvements.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed The custom check for excessive mock usage is not applicable to this pull request. The PR introduces new production code for API endpoints and updates starter project JSON configurations, but does not include or modify any test files. Since no test files were added or modified, there is no test code to evaluate for mock usage patterns.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.