Fix: dispatch ModelEngine provider listing to the dedicated ModelEngi… - #3961
lijiayang619 wants to merge 2 commits into
Conversation
…neProvider - get_provider_models routed every provider through the OpenAI-compatible adapter, so ModelEngine batch import failed (wrong endpoint path /open/router/v1/models, self-signed cert, custom type taxonomy, missing per-model base_url). The dedicated class existed but was never wired in.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new ModelEngine dispatch path inherits ModelEngineProvider’s hard-disabled TLS verification and lacks the SSRF/TLS safeguards present in OpenAICompatibleProvider, which introduces a security regression if base_url is user-controlled.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
该 PR 旨在修复 ModelEngine(ME)在批量导入/拉取模型列表时失败的问题:将 get_provider_models 对 ModelEngine 的模型枚举请求从通用 OpenAI 兼容适配器分发到专用的 ModelEngineProvider,以匹配其实际的 /open/router/v1/models 接口与返回格式。
Changes:
- 将
get_provider_models对provider=modelengine的分支改为使用ModelEngineProvider,其他 provider 仍走OpenAICompatibleProvider。 - 更新单元测试:验证 ModelEngine 的 provider 分发点从
OpenAICompatibleProvider切换为ModelEngineProvider。
| File | Description |
|---|---|
| backend/services/model_provider_service.py | 为 ModelEngine provider 增加专用 provider 分发逻辑,以适配其非 OpenAI /models 路径与模型类型映射需求。 |
| test/backend/services/test_model_provider_service.py | 更新测试 mock 目标与文案,覆盖 ModelEngine provider 的新分发路径。 |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| provider_key = (model_data.get("provider") or "").lower() | ||
| if provider_key == ProviderEnum.MODELENGINE.value: | ||
| client: AbstractModelProvider = ModelEngineProvider() | ||
| else: | ||
| client = OpenAICompatibleProvider() |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… the update path only checked api_key emptiness while the create path also exempts open/router URLs (ModelEngine self-signed certs). The edit dialog prefills the real key and always submits it, so any edit silently broke connectivity. Exemption now checks the payload URL with a fallback to the stored record; batch-edit groups get the same protection

修复ME批量导入失败的问题