mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-05 02:45:28 +00:00
fix(models): preserve Hugging Face identity-only cards
This commit is contained in:
parent
1a5df9edc0
commit
979bc42be8
3 changed files with 47 additions and 5 deletions
|
|
@ -136,7 +136,7 @@ def records_from_payload(
|
|||
endpoint_id: Any = "",
|
||||
base_url: Any = "",
|
||||
) -> tuple[ModelCapabilityRecord, ...]:
|
||||
if isinstance(payload, Mapping) and "pipeline_tag" in payload:
|
||||
if isinstance(payload, Mapping):
|
||||
record = record_from_model(payload, endpoint_id=endpoint_id, base_url=base_url)
|
||||
return (record,) if record else ()
|
||||
if not isinstance(payload, (list, tuple)):
|
||||
|
|
|
|||
|
|
@ -394,8 +394,10 @@ HUGGINGFACE_MODEL_SHAPE = ProviderCatalogShape(
|
|||
provider_id="huggingface",
|
||||
envelope=ENVELOPE_SINGLE,
|
||||
identity_paths=("modelId", "id"),
|
||||
required_item_paths=("pipeline_tag",),
|
||||
item_types=(("pipeline_tag", (str,)),),
|
||||
# Hub ModelInfo exposes pipeline_tag as optional metadata. Provider/host
|
||||
# context is still required because this shape has priority zero, so an
|
||||
# identity-only card can stay native without making generic ``id`` payloads
|
||||
# look like Hugging Face catalogs.
|
||||
detection_priority=0,
|
||||
)
|
||||
HUGGINGFACE_MODELS_LIST_SHAPE = ProviderCatalogShape(
|
||||
|
|
@ -403,8 +405,6 @@ HUGGINGFACE_MODELS_LIST_SHAPE = ProviderCatalogShape(
|
|||
provider_id="huggingface",
|
||||
envelope=ENVELOPE_BARE_LIST,
|
||||
identity_paths=("modelId", "id"),
|
||||
required_item_paths=("pipeline_tag",),
|
||||
item_types=(("pipeline_tag", (str,)),),
|
||||
detection_priority=0,
|
||||
)
|
||||
COHERE_MODELS_SHAPE = ProviderCatalogShape(
|
||||
|
|
|
|||
|
|
@ -1001,6 +1001,48 @@ def test_huggingface_reader_maps_provider_specific_pipeline_metadata():
|
|||
assert record.capability.confidence == mc.CONFIDENCE_REGISTRY
|
||||
|
||||
|
||||
def test_huggingface_optional_pipeline_tag_preserves_identity_only_records():
|
||||
cases = (
|
||||
(
|
||||
{"modelId": "org/no-pipeline-tag"},
|
||||
"huggingface.hub.model-info.v1",
|
||||
),
|
||||
(
|
||||
{"modelId": "org/null-pipeline-tag", "pipeline_tag": None},
|
||||
"huggingface.hub.model-info.v1",
|
||||
),
|
||||
(
|
||||
[{"modelId": "org/list-no-pipeline-tag"}],
|
||||
"huggingface.hub.model-info-list.v1",
|
||||
),
|
||||
(
|
||||
[{"modelId": "org/list-null-pipeline-tag", "pipeline_tag": None}],
|
||||
"huggingface.hub.model-info-list.v1",
|
||||
),
|
||||
)
|
||||
|
||||
for payload, shape_id in cases:
|
||||
resolution = pcs.resolve_provider(payload, provider="huggingface")
|
||||
direct = huggingface.records_from_payload(payload)
|
||||
wrapped = records_from_payload(payload, vendor="huggingface")
|
||||
|
||||
assert resolution.shape_id == shape_id
|
||||
assert resolution.fallback is False
|
||||
assert len(direct) == 1
|
||||
assert len(wrapped) == 1
|
||||
assert wrapped[0].model_id == direct[0].model_id
|
||||
assert wrapped[0].capability.family == mc.FAMILY_UNKNOWN
|
||||
assert wrapped[0].capability.capabilities == ()
|
||||
assert wrapped[0].catalog_shape_id == shape_id
|
||||
assert wrapped[0].fallback is False
|
||||
|
||||
# An identity-only singleton remains insufficient to infer Hugging Face
|
||||
# without configured provider or host context.
|
||||
unscoped = {"modelId": "org/unscoped"}
|
||||
assert pcs.resolve_provider(unscoped).provider_id == pcs.PROVIDER_UNKNOWN
|
||||
assert records_from_payload(unscoped) == ()
|
||||
|
||||
|
||||
def test_cohere_reader_maps_only_native_endpoint_and_limit_fields():
|
||||
chat, ambiguous = cohere.records_from_payload(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue