Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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 viaMODELS_CONFIG_DIR. - Adds a provider plugin framework and updates
LLMCreatorto instantiate LLMs via plugins, honoring per-modelapi_key/base_urlfrom the registry (supportingopenai_compatibleand 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.
| """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 [] |
There was a problem hiding this comment.
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.
| Covers every write operation | ||
| the legacy Mongo code performs on ``agents_collection``: |
There was a problem hiding this comment.
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.
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
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: