fix(models): require context for Hugging Face catalogs

This commit is contained in:
RaresKeY 2026-07-18 11:41:15 +00:00
parent d831a0e846
commit 6fe99b877a
2 changed files with 16 additions and 1 deletions

View file

@ -363,7 +363,7 @@ HUGGINGFACE_MODEL_SHAPE = ProviderCatalogShape(
identity_paths=("modelId", "id"),
required_item_paths=("pipeline_tag",),
item_types=(("pipeline_tag", (str,)),),
detection_priority=80,
detection_priority=0,
)
COHERE_MODELS_SHAPE = ProviderCatalogShape(
shape_id="cohere.models.rich.v1",

View file

@ -243,6 +243,7 @@ def test_native_catalog_shapes_resolve_with_required_provider_context():
explicit_context_providers = {
"chatgpt_subscription",
"cohere",
"huggingface",
"lmstudio",
"mistral",
}
@ -313,6 +314,20 @@ def test_payload_matching_multiple_providers_degrades_to_fallback():
assert record.fallback is True
def test_generic_pipeline_tag_does_not_select_huggingface_without_provider_context():
payload = {"id": "generic-model", "pipeline_tag": "image-text-to-text"}
inferred = pcs.resolve_provider(payload)
contextual = pcs.resolve_provider(payload, provider="huggingface")
assert inferred.provider_id == pcs.PROVIDER_UNKNOWN
assert inferred.shape_id == ""
assert inferred.fallback is False
assert records_from_payload(payload) == ()
assert contextual.provider_id == "huggingface"
assert contextual.shape_id == "huggingface.hub.model-info.v1"
assert contextual.fallback is False
def test_openrouter_payload_detection_requires_the_compound_official_shape():
complete = _openrouter_payload()
assert pcs.resolve_provider(complete).shape_id == "openrouter.models.rich.v1"