ui consistency, moved is_diffusers logic to backend, extended HuggingFaceMetadata, removed logic from service

This commit is contained in:
Jennifer Player
2024-03-12 21:00:14 -04:00
committed by psychedelicious
parent 2a300ecada
commit d0800c4888
10 changed files with 116 additions and 91 deletions

View File

@ -90,8 +90,35 @@ class HuggingFaceMetadataFetch(ModelMetadataFetchBase):
)
)
# diffusers models have a `model_index.json` file
is_diffusers = any(str(f.url).endswith("model_index.json") for f in files)
# These URLs will be exposed to the user - I think these are the only file types we fully support
ckpt_urls = (
None
if is_diffusers
else [
f.url
for f in files
if str(f.url).endswith(
(
".safetensors",
".bin",
".pth",
".pt",
".ckpt",
)
)
]
)
return HuggingFaceMetadata(
id=model_info.id, name=name, files=files, api_response=json.dumps(model_info.__dict__, default=str)
id=model_info.id,
name=name,
files=files,
api_response=json.dumps(model_info.__dict__, default=str),
is_diffusers=is_diffusers,
ckpt_urls=ckpt_urls,
)
def from_url(self, url: AnyHttpUrl) -> AnyModelRepoMetadata: