Skip to content

Feat models#2432

Merged
dartpain merged 3 commits intomainfrom
feat-models
Apr 25, 2026
Merged

Feat models#2432
dartpain merged 3 commits intomainfrom
feat-models

Conversation

@dartpain
Copy link
Copy Markdown
Contributor

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Why was this change needed? (You can also link to an open issue here)

  • Other information:

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nextra-docsgpt Building Building Preview, Comment Apr 25, 2026 11:56pm
oss-docsgpt Ready Ready Preview, Comment Apr 25, 2026 11:56pm

Request Review

Comment thread application/llm/providers/openai_compatible.py Dismissed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the model catalog + selection system from hard-coded Python lists to a YAML-driven registry backed by provider plugins, enabling operator drop-in model catalogs via MODELS_CONFIG_DIR and adding a generic openai_compatible provider for OpenAI-wire-compatible endpoints (including legacy OPENAI_BASE_URL deployments).

Changes:

  • Introduces a layered YAML model-catalog loader + singleton ModelRegistry, with optional operator overrides/extensions via MODELS_CONFIG_DIR.
  • Adds a provider plugin framework and updates LLMCreator to instantiate LLMs via plugins, honoring per-model api_key/base_url from the registry (supporting openai_compatible and future BYOM).
  • Adds comprehensive regression/unit tests and deployment documentation for YAML catalogs and operator configuration.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/core/test_openai_compatible.py Validates openai_compatible YAML catalogs, env var key resolution, legacy OPENAI_BASE_URL behavior, and LLMCreator dispatch override.
tests/core/test_models_config_dir.py Exercises operator MODELS_CONFIG_DIR for adding/extending/overriding catalogs and misconfiguration handling.
tests/core/test_model_settings.py Updates unit coverage for dataclasses + registry public API; removes legacy per-provider loader tests.
tests/core/test_model_registry_yaml.py Snapshot/regression tests ensuring YAML migration preserves model IDs/capabilities and settings permutations.
tests/api/user/test_tasks.py Updates periodic task expectations to include the new version-check schedule.
docs/content/Deploying/DocsGPT-Settings.mdx Documents MODELS_CONFIG_DIR usage, schema, and operational behavior on misconfiguration.
application/worker.py Logs when an agent’s stored default_model_id no longer resolves and falls back to system default.
application/storage/db/repositories/agents.py Edits repository docstring wording.
application/requirements.txt Adds PyYAML dependency for YAML catalog loading.
application/llm/providers/sagemaker.py Adds a LLMCreator-only provider plugin entry for SageMaker.
application/llm/providers/premai.py Adds a LLMCreator-only provider plugin entry for PremAI.
application/llm/providers/openrouter.py Adds OpenRouter provider plugin with shared key + LLM_NAME filtering logic.
application/llm/providers/openai_compatible.py Implements the generic OpenAI-wire-compatible provider with per-catalog keys + legacy local endpoint support.
application/llm/providers/openai.py Adds OpenAI provider plugin and hides cloud catalog when OPENAI_BASE_URL is set.
application/llm/providers/novita.py Adds Novita provider plugin using shared helper logic.
application/llm/providers/llama_cpp.py Adds a LLMCreator-only provider plugin entry for llama.cpp.
application/llm/providers/huggingface.py Adds Hugging Face catalog provider (non-dispatchable via LLMCreator) to preserve historical behavior.
application/llm/providers/groq.py Adds Groq provider plugin using shared helper logic.
application/llm/providers/google.py Adds Google provider plugin using shared helper logic.
application/llm/providers/docsgpt.py Adds DocsGPT provider plugin and disables it for OPENAI_BASE_URL legacy mode.
application/llm/providers/base.py Introduces the provider plugin base class and default YAML catalog merge behavior.
application/llm/providers/azure_openai.py Adds Azure OpenAI provider plugin and preserves LLM_NAME narrowing behavior.
application/llm/providers/anthropic.py Adds Anthropic provider plugin using shared helper logic.
application/llm/providers/_apikey_or_llm_name.py Shared helper for “provider-specific key OR (LLM_PROVIDER + API_KEY)” patterns and LLM_NAME filtering.
application/llm/providers/init.py Registers provider plugins and provides ALL_PROVIDERS / PROVIDERS_BY_NAME.
application/llm/openai.py Switches attachment type resolution to YAML alias resolver (resolve_attachment_alias).
application/llm/llm_creator.py Refactors LLM instantiation to use provider plugins and per-model overrides from ModelRegistry.
application/core/settings.py Adds MODELS_CONFIG_DIR setting for operator-supplied YAML catalogs.
application/core/models/openrouter.yaml Adds built-in OpenRouter model catalog YAML.
application/core/models/openai.yaml Adds built-in OpenAI model catalog YAML.
application/core/models/novita.yaml Adds built-in Novita model catalog YAML.
application/core/models/huggingface.yaml Adds built-in Hugging Face model catalog YAML.
application/core/models/groq.yaml Adds built-in Groq model catalog YAML.
application/core/models/google.yaml Adds built-in Google model catalog YAML.
application/core/models/examples/mistral.yaml.example Adds a working example openai_compatible provider YAML (not auto-loaded).
application/core/models/docsgpt.yaml Adds built-in DocsGPT model catalog YAML.
application/core/models/azure_openai.yaml Adds built-in Azure OpenAI model catalog YAML with operator-override guidance.
application/core/models/anthropic.yaml Adds built-in Anthropic model catalog YAML.
application/core/models/_defaults.yaml Adds global attachment alias definitions shared by YAML catalogs.
application/core/models/README.md Adds documentation for YAML schema, overrides, and operator MODELS_CONFIG_DIR usage.
application/core/model_yaml.py Adds YAML loader + Pydantic schema validation and attachment alias expansion.
application/core/model_utils.py Updates key resolution to use provider plugins and adds get_api_key_for_model.
application/core/model_settings.py Extends model dataclasses for display_provider + api_key, adds openai_compatible, and lazily re-exports ModelRegistry.
application/core/model_registry.py Adds the layered YAML-backed singleton registry with provider-plugin integration and default selection.
application/core/model_configs.py Removes legacy hard-coded model lists and custom-model factory.
.env-template Removes prior migration commentary block (leaves POSTGRES_URI line).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +66 to +89
"""Resolve one openai_compatible YAML into ready-to-dispatch models.

Skipped (with a warning) if ``api_key_env`` resolves to nothing —
no point publishing models the user can't actually call.
"""
if not catalog.base_url:
raise ValueError(
f"{catalog.source_path}: openai_compatible YAML must set "
"'base_url'."
)
if not catalog.api_key_env:
raise ValueError(
f"{catalog.source_path}: openai_compatible YAML must set "
"'api_key_env'."
)

api_key = os.environ.get(catalog.api_key_env)
if not api_key:
logger.info(
"openai_compatible catalog %s skipped: env var %s is not set",
catalog.source_path,
catalog.api_key_env,
)
return []
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says catalogs are skipped "with a warning" when the env var is missing, but the implementation logs at INFO. Either update the docstring to match, or log at WARNING so operators notice missing credentials.

Copilot uses AI. Check for mistakes.
Comment on lines 3 to 4
Covers every write operation
the legacy Mongo code performs on ``agents_collection``:
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module docstring now reads as a sentence fragment ("Covers every write operation" on one line, then continues on the next). Consider merging into a single complete sentence and adding punctuation for readability.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

❌ Patch coverage is 92.36499% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.21%. Comparing base (87fd1bd) to head (ddd5704).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
application/core/model_yaml.py 87.33% 19 Missing ⚠️
application/core/model_utils.py 53.33% 7 Missing ⚠️
application/core/model_registry.py 95.18% 4 Missing ⚠️
application/llm/providers/azure_openai.py 84.21% 3 Missing ⚠️
application/llm/providers/openai.py 91.30% 2 Missing ⚠️
application/llm/providers/openai_compatible.py 96.00% 2 Missing ⚠️
application/llm/providers/_apikey_or_llm_name.py 94.11% 1 Missing ⚠️
application/llm/providers/premai.py 90.90% 1 Missing ⚠️
application/llm/providers/sagemaker.py 90.90% 1 Missing ⚠️
application/worker.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2432      +/-   ##
==========================================
- Coverage   91.21%   91.21%   -0.01%     
==========================================
  Files         228      245      +17     
  Lines       19529    19889     +360     
==========================================
+ Hits        17814    18141     +327     
- Misses       1715     1748      +33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dartpain dartpain merged commit af618de into main Apr 25, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants