mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 18:18:08 +00:00
feat: improved compatability layer and responses api handing
This commit is contained in:
1 parent
3e978759de
commit
0adf88abed
45 files changed
+2566
-337
No files matched your search
@@ -791,7 +791,7 @@ class TestContinuationPreservesByomScope:
|
||||
)
|
||||
|
||||
cont_service = MagicMock()
|
||||
cont_service.load_state.return_value = {
|
||||
cont_service.claim_state.return_value = {
|
||||
"messages": [],
|
||||
"pending_tool_calls": [],
|
||||
"tools_dict": {},
|
||||
|
||||
@@ -90,8 +90,11 @@ def _make_settings(**overrides):
|
||||
def _reset_registry(monkeypatch):
|
||||
ModelRegistry.reset()
|
||||
# openai_compatible catalogs read their key directly from os.environ,
|
||||
# so clear any host-set keys to keep these tests deterministic.
|
||||
monkeypatch.delenv("DEEPSEEK_API_KEY", raising=False)
|
||||
# so clear every built-in/operator catalog key to keep these tests
|
||||
# deterministic even when a developer has an ignored ``*_internal.yaml``.
|
||||
for catalog in load_model_yamls([BUILTIN_MODELS_DIR]):
|
||||
if catalog.api_key_env:
|
||||
monkeypatch.delenv(catalog.api_key_env, raising=False)
|
||||
yield
|
||||
ModelRegistry.reset()
|
||||
|
||||
@@ -118,7 +121,17 @@ class TestYAMLLoader:
|
||||
def test_each_provider_has_expected_ids(self):
|
||||
grouped = _by_provider(load_model_yamls([BUILTIN_MODELS_DIR]))
|
||||
for provider, expected in EXPECTED_IDS.items():
|
||||
actual = {m.id for c in grouped[provider] for m in c.models}
|
||||
# Local ``*_internal.yaml`` files are intentionally gitignored
|
||||
# operator extensions, not part of the canonical catalog snapshot.
|
||||
canonical = [
|
||||
c
|
||||
for c in grouped[provider]
|
||||
if not (
|
||||
c.source_path
|
||||
and c.source_path.stem.endswith("_internal")
|
||||
)
|
||||
]
|
||||
actual = {m.id for c in canonical for m in c.models}
|
||||
assert actual == expected, f"{provider}: expected {expected}, got {actual}"
|
||||
|
||||
def test_attachment_alias_image_expands_to_five_mime_types(self):
|
||||
|
||||
@@ -16,6 +16,7 @@ import pytest
|
||||
|
||||
from application.core.model_registry import ModelRegistry
|
||||
from application.core.model_settings import ModelProvider
|
||||
from application.core.model_yaml import BUILTIN_MODELS_DIR, load_model_yamls
|
||||
|
||||
|
||||
def _make_settings(**overrides):
|
||||
@@ -81,7 +82,9 @@ def _reset_registry(monkeypatch):
|
||||
# so a key leaked by another test (or present in the dev .env) doesn't add
|
||||
# extra models to the exact-match assertions below. Mirrors the delenv
|
||||
# guard in test_model_registry_yaml.py.
|
||||
monkeypatch.delenv("DEEPSEEK_API_KEY", raising=False)
|
||||
for catalog in load_model_yamls([BUILTIN_MODELS_DIR]):
|
||||
if catalog.api_key_env:
|
||||
monkeypatch.delenv(catalog.api_key_env, raising=False)
|
||||
ModelRegistry.reset()
|
||||
yield
|
||||
ModelRegistry.reset()
|
||||
@@ -211,6 +214,33 @@ class TestYAMLCompatibleProvider:
|
||||
for v in d.values():
|
||||
assert v != "sk"
|
||||
|
||||
def test_materialization_preserves_upstream_model_id(
|
||||
self, tmp_path, monkeypatch
|
||||
):
|
||||
path = _write_mistral_yaml(tmp_path)
|
||||
path.write_text(
|
||||
dedent("""
|
||||
provider: openai_compatible
|
||||
display_provider: mistral
|
||||
api_key_env: MISTRAL_API_KEY
|
||||
base_url: https://api.mistral.ai/v1
|
||||
models:
|
||||
- id: mistral-large-high
|
||||
upstream_model_id: mistral-large-latest
|
||||
display_name: Mistral Large (High)
|
||||
""")
|
||||
)
|
||||
monkeypatch.setenv("MISTRAL_API_KEY", "sk")
|
||||
|
||||
s = _make_settings(MODELS_CONFIG_DIR=str(tmp_path))
|
||||
with patch("application.core.settings.settings", s):
|
||||
reg = ModelRegistry()
|
||||
|
||||
assert (
|
||||
reg.get_model("mistral-large-high").upstream_model_id
|
||||
== "mistral-large-latest"
|
||||
)
|
||||
|
||||
|
||||
# ── Legacy OPENAI_BASE_URL fallback ──────────────────────────────────────
|
||||
|
||||
|
||||
@@ -227,6 +227,8 @@ class TestLLMCreatorDispatchUsesUpstreamModelId:
|
||||
"supports_structured_output": False,
|
||||
"attachments": [],
|
||||
"context_window": 8192,
|
||||
"api_flavor": "responses",
|
||||
"reasoning_effort": "high",
|
||||
},
|
||||
)
|
||||
|
||||
@@ -262,6 +264,8 @@ class TestLLMCreatorDispatchUsesUpstreamModelId:
|
||||
assert caps.supports_tools is False
|
||||
assert caps.supports_structured_output is False
|
||||
assert caps.supported_attachment_types == []
|
||||
assert caps.api_flavor == "responses"
|
||||
assert caps.reasoning_effort == "high"
|
||||
|
||||
def test_byom_image_alias_expands_to_mime_types(self, pg_conn):
|
||||
"""A BYOM stored with ``attachments: ["image"]`` (the alias the
|
||||
|
||||
Reference in new issue
Block a user