From 1665e399d6e0e60a33ca00d403ac8256b1b452f7 Mon Sep 17 00:00:00 2001 From: Wauplin <11801849+Wauplin@users.noreply.github.com> Date: Wed, 23 Jul 2025 03:29:41 +0000 Subject: [PATCH] Update inference types (automated commit) --- .../en/package_reference/inference_types.md | 22 ++++--- .../ko/package_reference/inference_types.md | 22 ++++--- .../inference/_generated/types/__init__.py | 7 +-- .../_generated/types/chat_completion.py | 48 +++++---------- .../_generated/types/image_to_video.py | 60 +++++++++++++++++++ 5 files changed, 107 insertions(+), 52 deletions(-) create mode 100644 src/huggingface_hub/inference/_generated/types/image_to_video.py diff --git a/docs/source/en/package_reference/inference_types.md b/docs/source/en/package_reference/inference_types.md index 1c90e9facb..141e8e60e0 100644 --- a/docs/source/en/package_reference/inference_types.md +++ b/docs/source/en/package_reference/inference_types.md @@ -57,18 +57,14 @@ This part of the lib is still under development and will be improved in future r [[autodoc]] huggingface_hub.ChatCompletionInputFunctionName -[[autodoc]] huggingface_hub.ChatCompletionInputJSONSchema +[[autodoc]] huggingface_hub.ChatCompletionInputGrammarType + +[[autodoc]] huggingface_hub.ChatCompletionInputJSONSchemaConfig [[autodoc]] huggingface_hub.ChatCompletionInputMessage [[autodoc]] huggingface_hub.ChatCompletionInputMessageChunk -[[autodoc]] huggingface_hub.ChatCompletionInputResponseFormatJSONObject - -[[autodoc]] huggingface_hub.ChatCompletionInputResponseFormatJSONSchema - -[[autodoc]] huggingface_hub.ChatCompletionInputResponseFormatText - [[autodoc]] huggingface_hub.ChatCompletionInputStreamOptions [[autodoc]] huggingface_hub.ChatCompletionInputTool @@ -197,6 +193,18 @@ This part of the lib is still under development and will be improved in future r +## image_to_video + +[[autodoc]] huggingface_hub.ImageToVideoInput + +[[autodoc]] huggingface_hub.ImageToVideoOutput + +[[autodoc]] huggingface_hub.ImageToVideoParameters + +[[autodoc]] huggingface_hub.ImageToVideoTargetSize + + + ## object_detection [[autodoc]] huggingface_hub.ObjectDetectionBoundingBox diff --git a/docs/source/ko/package_reference/inference_types.md b/docs/source/ko/package_reference/inference_types.md index 3746086ed2..4b65109f81 100644 --- a/docs/source/ko/package_reference/inference_types.md +++ b/docs/source/ko/package_reference/inference_types.md @@ -56,18 +56,14 @@ rendered properly in your Markdown viewer. [[autodoc]] huggingface_hub.ChatCompletionInputFunctionName -[[autodoc]] huggingface_hub.ChatCompletionInputJSONSchema +[[autodoc]] huggingface_hub.ChatCompletionInputGrammarType + +[[autodoc]] huggingface_hub.ChatCompletionInputJSONSchemaConfig [[autodoc]] huggingface_hub.ChatCompletionInputMessage [[autodoc]] huggingface_hub.ChatCompletionInputMessageChunk -[[autodoc]] huggingface_hub.ChatCompletionInputResponseFormatJSONObject - -[[autodoc]] huggingface_hub.ChatCompletionInputResponseFormatJSONSchema - -[[autodoc]] huggingface_hub.ChatCompletionInputResponseFormatText - [[autodoc]] huggingface_hub.ChatCompletionInputStreamOptions [[autodoc]] huggingface_hub.ChatCompletionInputTool @@ -196,6 +192,18 @@ rendered properly in your Markdown viewer. +## image_to_video[[huggingface_hub.ImageToVideoInput]] + +[[autodoc]] huggingface_hub.ImageToVideoInput + +[[autodoc]] huggingface_hub.ImageToVideoOutput + +[[autodoc]] huggingface_hub.ImageToVideoParameters + +[[autodoc]] huggingface_hub.ImageToVideoTargetSize + + + ## object_detection[[huggingface_hub.ObjectDetectionBoundingBox]] [[autodoc]] huggingface_hub.ObjectDetectionBoundingBox diff --git a/src/huggingface_hub/inference/_generated/types/__init__.py b/src/huggingface_hub/inference/_generated/types/__init__.py index 63f6a653d6..73ea4e6ee0 100644 --- a/src/huggingface_hub/inference/_generated/types/__init__.py +++ b/src/huggingface_hub/inference/_generated/types/__init__.py @@ -24,13 +24,11 @@ ChatCompletionInputFunctionDefinition, ChatCompletionInputFunctionName, ChatCompletionInputGrammarType, - ChatCompletionInputJSONSchema, + ChatCompletionInputGrammarTypeType, + ChatCompletionInputJSONSchemaConfig, ChatCompletionInputMessage, ChatCompletionInputMessageChunk, ChatCompletionInputMessageChunkType, - ChatCompletionInputResponseFormatJSONObject, - ChatCompletionInputResponseFormatJSONSchema, - ChatCompletionInputResponseFormatText, ChatCompletionInputStreamOptions, ChatCompletionInputTool, ChatCompletionInputToolCall, @@ -85,6 +83,7 @@ ImageToTextOutput, ImageToTextParameters, ) +from .image_to_video import ImageToVideoInput, ImageToVideoOutput, ImageToVideoParameters, ImageToVideoTargetSize from .object_detection import ( ObjectDetectionBoundingBox, ObjectDetectionInput, diff --git a/src/huggingface_hub/inference/_generated/types/chat_completion.py b/src/huggingface_hub/inference/_generated/types/chat_completion.py index fe455ee710..bad075a457 100644 --- a/src/huggingface_hub/inference/_generated/types/chat_completion.py +++ b/src/huggingface_hub/inference/_generated/types/chat_completion.py @@ -26,8 +26,8 @@ class ChatCompletionInputMessageChunk(BaseInferenceType): @dataclass_with_extra class ChatCompletionInputFunctionDefinition(BaseInferenceType): name: str - parameters: Any description: Optional[str] = None + parameters: Any @dataclass_with_extra @@ -46,50 +46,30 @@ class ChatCompletionInputMessage(BaseInferenceType): @dataclass_with_extra -class ChatCompletionInputJSONSchema(BaseInferenceType): +class ChatCompletionInputJSONSchemaConfig(BaseInferenceType): name: str - """ - The name of the response format. - """ + """The name of the response format.""" description: Optional[str] = None + """A description of what the response format is for, used by the model to determine how to + respond in the format. """ - A description of what the response format is for, used by the model to determine - how to respond in the format. - """ - schema: Optional[Dict[str, object]] = None - """ - The schema for the response format, described as a JSON Schema object. Learn how - to build JSON schemas [here](https://json-schema.org/). + schema: Optional[Dict[str, Any]] = None + """The schema for the response format, described as a JSON Schema object. Learn how to build + JSON schemas [here](https://json-schema.org/). """ strict: Optional[bool] = None - """ - Whether to enable strict schema adherence when generating the output. If set to - true, the model will always follow the exact schema defined in the `schema` - field. + """Whether to enable strict schema adherence when generating the output. If set to true, the + model will always follow the exact schema defined in the `schema` field. """ -@dataclass_with_extra -class ChatCompletionInputResponseFormatText(BaseInferenceType): - type: Literal["text"] - - -@dataclass_with_extra -class ChatCompletionInputResponseFormatJSONSchema(BaseInferenceType): - type: Literal["json_schema"] - json_schema: ChatCompletionInputJSONSchema +ChatCompletionInputGrammarTypeType = Literal["text", "json_schema", "json_object"] @dataclass_with_extra -class ChatCompletionInputResponseFormatJSONObject(BaseInferenceType): - type: Literal["json_object"] - - -ChatCompletionInputGrammarType = Union[ - ChatCompletionInputResponseFormatText, - ChatCompletionInputResponseFormatJSONSchema, - ChatCompletionInputResponseFormatJSONObject, -] +class ChatCompletionInputGrammarType(BaseInferenceType): + type: "ChatCompletionInputGrammarTypeType" + json_schema: Optional[ChatCompletionInputJSONSchemaConfig] = None @dataclass_with_extra diff --git a/src/huggingface_hub/inference/_generated/types/image_to_video.py b/src/huggingface_hub/inference/_generated/types/image_to_video.py new file mode 100644 index 0000000000..92192a2a05 --- /dev/null +++ b/src/huggingface_hub/inference/_generated/types/image_to_video.py @@ -0,0 +1,60 @@ +# Inference code generated from the JSON schema spec in @huggingface/tasks. +# +# See: +# - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts +# - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. +from typing import Any, Optional + +from .base import BaseInferenceType, dataclass_with_extra + + +@dataclass_with_extra +class ImageToVideoTargetSize(BaseInferenceType): + """The size in pixel of the output video frames.""" + + height: int + width: int + + +@dataclass_with_extra +class ImageToVideoParameters(BaseInferenceType): + """Additional inference parameters for Image To Video""" + + guidance_scale: Optional[float] = None + """For diffusion models. A higher guidance scale value encourages the model to generate + videos closely linked to the text prompt at the expense of lower image quality. + """ + negative_prompt: Optional[str] = None + """One prompt to guide what NOT to include in video generation.""" + num_frames: Optional[float] = None + """The num_frames parameter determines how many video frames are generated.""" + num_inference_steps: Optional[int] = None + """The number of denoising steps. More denoising steps usually lead to a higher quality + video at the expense of slower inference. + """ + prompt: Optional[str] = None + """The text prompt to guide the video generation.""" + seed: Optional[int] = None + """Seed for the random number generator.""" + target_size: Optional[ImageToVideoTargetSize] = None + """The size in pixel of the output video frames.""" + + +@dataclass_with_extra +class ImageToVideoInput(BaseInferenceType): + """Inputs for Image To Video inference""" + + inputs: str + """The input image data as a base64-encoded string. If no `parameters` are provided, you can + also provide the image data as a raw bytes payload. + """ + parameters: Optional[ImageToVideoParameters] = None + """Additional inference parameters for Image To Video""" + + +@dataclass_with_extra +class ImageToVideoOutput(BaseInferenceType): + """Outputs of inference for the Image To Video task""" + + video: Any + """The generated video returned as raw bytes in the payload."""