mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-10 06:47:04 +08:00
Use pydantic v2.
This commit is contained in:
parent
08b797fe80
commit
824c87a106
2
.github/workflows/update-api-stubs.yml
vendored
2
.github/workflows/update-api-stubs.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate API models
|
- name: Generate API models
|
||||||
run: |
|
run: |
|
||||||
datamodel-codegen --use-subclass-enum --url https://stagingapi.comfy.org/openapi --output comfy_api_nodes/apis
|
datamodel-codegen --use-subclass-enum --url https://stagingapi.comfy.org/openapi --output comfy_api_nodes/apis --output-model-type pydantic_v2.BaseModel
|
||||||
|
|
||||||
- name: Check for changes
|
- name: Check for changes
|
||||||
id: git-check
|
id: git-check
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# generated by datamodel-codegen:
|
# generated by datamodel-codegen:
|
||||||
# filename: https://stagingapi.comfy.org/openapi
|
# filename: https://stagingapi.comfy.org/openapi
|
||||||
# timestamp: 2025-04-22T08:06:44+00:00
|
# timestamp: 2025-04-22T08:58:11+00:00
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# generated by datamodel-codegen:
|
# generated by datamodel-codegen:
|
||||||
# filename: https://stagingapi.comfy.org/openapi
|
# filename: https://stagingapi.comfy.org/openapi
|
||||||
# timestamp: 2025-04-22T08:06:44+00:00
|
# timestamp: 2025-04-22T08:58:11+00:00
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -15,20 +15,20 @@ class V2OpenAPII2VResp(BaseModel):
|
|||||||
|
|
||||||
class V2OpenAPIT2VReq(BaseModel):
|
class V2OpenAPIT2VReq(BaseModel):
|
||||||
aspect_ratio: str = Field(
|
aspect_ratio: str = Field(
|
||||||
..., description='Aspect ratio (16:9, 4:3, 1:1, 3:4, 9:16)', example='16:9'
|
..., description='Aspect ratio (16:9, 4:3, 1:1, 3:4, 9:16)', examples=['16:9']
|
||||||
)
|
)
|
||||||
duration: int = Field(
|
duration: int = Field(
|
||||||
...,
|
...,
|
||||||
description='Video duration (5, 8 seconds, --model=v3.5 only allows 5,8; --quality=1080p does not support 8s)',
|
description='Video duration (5, 8 seconds, --model=v3.5 only allows 5,8; --quality=1080p does not support 8s)',
|
||||||
example=5,
|
examples=[5],
|
||||||
)
|
)
|
||||||
model: str = Field(
|
model: str = Field(
|
||||||
..., description='Model version (only supports v3.5)', example='v3.5'
|
..., description='Model version (only supports v3.5)', examples=['v3.5']
|
||||||
)
|
)
|
||||||
motion_mode: Optional[str] = Field(
|
motion_mode: Optional[str] = Field(
|
||||||
'normal',
|
'normal',
|
||||||
description='Motion mode (normal, fast, --fast only available when duration=5; --quality=1080p does not support fast)',
|
description='Motion mode (normal, fast, --fast only available when duration=5; --quality=1080p does not support fast)',
|
||||||
example='normal',
|
examples=['normal'],
|
||||||
)
|
)
|
||||||
negative_prompt: Optional[constr(max_length=2048)] = Field(
|
negative_prompt: Optional[constr(max_length=2048)] = Field(
|
||||||
None, description='Negative prompt\n'
|
None, description='Negative prompt\n'
|
||||||
@ -37,21 +37,21 @@ class V2OpenAPIT2VReq(BaseModel):
|
|||||||
quality: str = Field(
|
quality: str = Field(
|
||||||
...,
|
...,
|
||||||
description='Video quality ("360p"(Turbo model), "540p", "720p", "1080p")',
|
description='Video quality ("360p"(Turbo model), "540p", "720p", "1080p")',
|
||||||
example='540p',
|
examples=['540p'],
|
||||||
)
|
)
|
||||||
seed: Optional[int] = Field(None, description='Random seed, range: 0 - 2147483647')
|
seed: Optional[int] = Field(None, description='Random seed, range: 0 - 2147483647')
|
||||||
style: Optional[str] = Field(
|
style: Optional[str] = Field(
|
||||||
None,
|
None,
|
||||||
description='Style (effective when model=v3.5, "anime", "3d_animation", "clay", "comic", "cyberpunk") Do not include style parameter unless needed',
|
description='Style (effective when model=v3.5, "anime", "3d_animation", "clay", "comic", "cyberpunk") Do not include style parameter unless needed',
|
||||||
example='anime',
|
examples=['anime'],
|
||||||
)
|
)
|
||||||
template_id: Optional[int] = Field(
|
template_id: Optional[int] = Field(
|
||||||
None,
|
None,
|
||||||
description='Template ID (template_id must be activated before use)',
|
description='Template ID (template_id must be activated before use)',
|
||||||
example=302325299692608,
|
examples=[302325299692608],
|
||||||
)
|
)
|
||||||
water_mark: Optional[bool] = Field(
|
water_mark: Optional[bool] = Field(
|
||||||
False,
|
False,
|
||||||
description='Watermark (true: add watermark, false: no watermark)',
|
description='Watermark (true: add watermark, false: no watermark)',
|
||||||
example=False,
|
examples=[False],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# generated by datamodel-codegen:
|
# generated by datamodel-codegen:
|
||||||
# filename: https://stagingapi.comfy.org/openapi
|
# filename: https://stagingapi.comfy.org/openapi
|
||||||
# timestamp: 2025-04-22T08:06:44+00:00
|
# timestamp: 2025-04-22T08:58:11+00:00
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ from enum import Enum
|
|||||||
from typing import Any, Dict, List, Literal, Optional, Union
|
from typing import Any, Dict, List, Literal, Optional, Union
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from pydantic import AnyUrl, BaseModel, Field, confloat, conint, constr
|
from pydantic import AnyUrl, BaseModel, Field, RootModel, confloat, conint, constr
|
||||||
|
|
||||||
|
|
||||||
class BFLFluxProGenerateRequest(BaseModel):
|
class BFLFluxProGenerateRequest(BaseModel):
|
||||||
@ -829,8 +829,8 @@ class LumaImageReference(BaseModel):
|
|||||||
url: AnyUrl = Field(..., description='The URL of the image')
|
url: AnyUrl = Field(..., description='The URL of the image')
|
||||||
|
|
||||||
|
|
||||||
class LumaKeyframe(BaseModel):
|
class LumaKeyframe(RootModel[Union[LumaGenerationReference, LumaImageReference]]):
|
||||||
__root__: Union[LumaGenerationReference, LumaImageReference] = Field(
|
root: Union[LumaGenerationReference, LumaImageReference] = Field(
|
||||||
...,
|
...,
|
||||||
description='A keyframe can be either a Generation reference, an Image, or a Video',
|
description='A keyframe can be either a Generation reference, an Image, or a Video',
|
||||||
discriminator='type',
|
discriminator='type',
|
||||||
@ -884,8 +884,10 @@ class LumaVideoModelOutputDuration1(str, Enum):
|
|||||||
field_9s = '9s'
|
field_9s = '9s'
|
||||||
|
|
||||||
|
|
||||||
class LumaVideoModelOutputDuration(BaseModel):
|
class LumaVideoModelOutputDuration(
|
||||||
__root__: Union[LumaVideoModelOutputDuration1, str]
|
RootModel[Union[LumaVideoModelOutputDuration1, str]]
|
||||||
|
):
|
||||||
|
root: Union[LumaVideoModelOutputDuration1, str]
|
||||||
|
|
||||||
|
|
||||||
class LumaVideoModelOutputResolution1(str, Enum):
|
class LumaVideoModelOutputResolution1(str, Enum):
|
||||||
@ -895,8 +897,10 @@ class LumaVideoModelOutputResolution1(str, Enum):
|
|||||||
field_4k = '4k'
|
field_4k = '4k'
|
||||||
|
|
||||||
|
|
||||||
class LumaVideoModelOutputResolution(BaseModel):
|
class LumaVideoModelOutputResolution(
|
||||||
__root__: Union[LumaVideoModelOutputResolution1, str]
|
RootModel[Union[LumaVideoModelOutputResolution1, str]]
|
||||||
|
):
|
||||||
|
root: Union[LumaVideoModelOutputResolution1, str]
|
||||||
|
|
||||||
|
|
||||||
class MachineStats(BaseModel):
|
class MachineStats(BaseModel):
|
||||||
@ -1054,6 +1058,87 @@ class NodeVersionUpdateRequest(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Background(str, Enum):
|
||||||
|
transparent = 'transparent'
|
||||||
|
opaque = 'opaque'
|
||||||
|
|
||||||
|
|
||||||
|
class Moderation(str, Enum):
|
||||||
|
low = 'low'
|
||||||
|
auto = 'auto'
|
||||||
|
|
||||||
|
|
||||||
|
class OutputFormat(str, Enum):
|
||||||
|
png = 'png'
|
||||||
|
webp = 'webp'
|
||||||
|
jpeg = 'jpeg'
|
||||||
|
|
||||||
|
|
||||||
|
class Quality(str, Enum):
|
||||||
|
low = 'low'
|
||||||
|
medium = 'medium'
|
||||||
|
high = 'high'
|
||||||
|
|
||||||
|
|
||||||
|
class ResponseFormat(str, Enum):
|
||||||
|
url = 'url'
|
||||||
|
b64_json = 'b64_json'
|
||||||
|
|
||||||
|
|
||||||
|
class Style(str, Enum):
|
||||||
|
vivid = 'vivid'
|
||||||
|
natural = 'natural'
|
||||||
|
|
||||||
|
|
||||||
|
class OpenAIImageGenerationRequest(BaseModel):
|
||||||
|
background: Optional[Background] = Field(
|
||||||
|
None, description='Background transparency', examples=['opaque']
|
||||||
|
)
|
||||||
|
model: Optional[str] = Field(
|
||||||
|
None,
|
||||||
|
description='The model to use for image generation',
|
||||||
|
examples=['gpt-image-1'],
|
||||||
|
)
|
||||||
|
moderation: Optional[Moderation] = Field(
|
||||||
|
None, description='Content moderation setting', examples=['auto']
|
||||||
|
)
|
||||||
|
n: Optional[int] = Field(
|
||||||
|
None,
|
||||||
|
description='The number of images to generate (1–10). Only 1 supported for dall-e-3.',
|
||||||
|
examples=[1],
|
||||||
|
)
|
||||||
|
output_compression: Optional[int] = Field(
|
||||||
|
None, description='Compression level for JPEG or WebP (0–100)', examples=[100]
|
||||||
|
)
|
||||||
|
output_format: Optional[OutputFormat] = Field(
|
||||||
|
None, description='Format of the output image', examples=['png']
|
||||||
|
)
|
||||||
|
prompt: str = Field(
|
||||||
|
...,
|
||||||
|
description='A text description of the desired image',
|
||||||
|
examples=['Draw a rocket in front of a blackhole in deep space'],
|
||||||
|
)
|
||||||
|
quality: Optional[Quality] = Field(
|
||||||
|
None, description='The quality of the generated image', examples=['high']
|
||||||
|
)
|
||||||
|
response_format: Optional[ResponseFormat] = Field(
|
||||||
|
None, description='Response format of image data', examples=['b64_json']
|
||||||
|
)
|
||||||
|
size: Optional[str] = Field(
|
||||||
|
None,
|
||||||
|
description='Size of the image (e.g., 1024x1024, 1536x1024, auto)',
|
||||||
|
examples=['1024x1536'],
|
||||||
|
)
|
||||||
|
style: Optional[Style] = Field(
|
||||||
|
None, description='Style of the image (only for dall-e-3)', examples=['vivid']
|
||||||
|
)
|
||||||
|
user: Optional[str] = Field(
|
||||||
|
None,
|
||||||
|
description='A unique identifier for end-user monitoring',
|
||||||
|
examples=['user-1234'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PersonalAccessToken(BaseModel):
|
class PersonalAccessToken(BaseModel):
|
||||||
createdAt: Optional[datetime] = Field(
|
createdAt: Optional[datetime] = Field(
|
||||||
None, description='[Output Only]The date and time the token was created.'
|
None, description='[Output Only]The date and time the token was created.'
|
||||||
@ -1299,7 +1384,7 @@ class PersonGeneration(str, Enum):
|
|||||||
|
|
||||||
|
|
||||||
class Parameters(BaseModel):
|
class Parameters(BaseModel):
|
||||||
aspectRatio: Optional[str] = Field(None, example='16:9')
|
aspectRatio: Optional[str] = Field(None, examples=['16:9'])
|
||||||
durationSeconds: Optional[int] = None
|
durationSeconds: Optional[int] = None
|
||||||
enhancePrompt: Optional[bool] = None
|
enhancePrompt: Optional[bool] = None
|
||||||
negativePrompt: Optional[str] = None
|
negativePrompt: Optional[str] = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user