Code review changes

This commit is contained in:
hlohaus 2025-03-10 02:07:35 +01:00
parent 2799bf728c
commit e4afa12fb9
3 changed files with 7 additions and 14 deletions

View file

@ -116,10 +116,11 @@ class Phi_4(AsyncGeneratorProvider, ProviderModelMixin):
if images is not None:
data = FormData()
mimi_types = [None for i in range(len(images))]
mime_types = [None for i in range(len(images))]
for i in range(len(images)):
mimi_types[i] = is_data_an_wav(images[i][0], images[i][1])
mime_types[i] = is_data_an_wav(images[i][0], images[i][1])
images[i] = (to_bytes(images[i][0]), images[i][1])
mime_types[i] = is_accepted_format(images[i][0]) if mime_types[i] is None else mime_types[i]
for image, image_name in images:
data.add_field(f"files", to_bytes(image), filename=image_name)
async with session.post(f"{cls.api_url}/gradio_api/upload", params={"upload_id": session_hash}, data=data) as response:
@ -130,7 +131,7 @@ class Phi_4(AsyncGeneratorProvider, ProviderModelMixin):
"url": f"{cls.api_url}/gradio_api/file={image_file}",
"orig_name": images[i][1],
"size": len(images[i][0]),
"mime_type": mimi_types[i] or is_accepted_format(images[i][0]),
"mime_type": mime_types[i],
"meta": {
"_type": "gradio.FileData"
}

View file

@ -96,13 +96,5 @@ class HuggingSpace(AsyncGeneratorProvider, ProviderModelMixin):
if not is_started and error is not None:
raise error
BlackForestLabsFlux1Dev.parent = HuggingSpace.__name__,
BlackForestLabsFlux1Schnell.parent = HuggingSpace.__name__,
VoodoohopFlux1Schnell.parent = HuggingSpace.__name__,
CohereForAI.parent = HuggingSpace.__name__,
Janus_Pro_7B.parent = HuggingSpace.__name__,
Phi_4.parent = HuggingSpace.__name__,
Qwen_QVQ_72B.parent = HuggingSpace.__name__,
Qwen_Qwen_2_5M_Demo.parent = HuggingSpace.__name__,
Qwen_Qwen_2_72B_Instruct.parent = HuggingSpace.__name__,
StableDiffusion35Large.parent = HuggingSpace.__name__,
for provider in HuggingSpace.providers:
provider.parent = HuggingSpace.__name__

View file

@ -217,7 +217,7 @@ class Api:
elif isinstance(chunk, Reasoning):
yield self._format_json("reasoning", **chunk.get_dict())
elif isinstance(chunk, YouTube):
yield self._format_json("content", chunk.to_string)
yield self._format_json("content", chunk.to_string())
elif isinstance(chunk, Audio):
yield self._format_json("audio", str(chunk))
elif isinstance(chunk, DebugResponse):