mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-09 03:17:05 +08:00
Add.
This commit is contained in:
parent
1c1ef2d9e6
commit
e90100e1a5
@ -1,6 +1,6 @@
|
|||||||
# generated by datamodel-codegen:
|
# generated by datamodel-codegen:
|
||||||
# filename: https://stagingapi.comfy.org/openapi
|
# filename: http://localhost:8080/openapi
|
||||||
# timestamp: 2025-04-22T08:58:11+00:00
|
# timestamp: 2025-04-22T09:45:21+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: http://localhost:8080/openapi
|
||||||
# timestamp: 2025-04-22T08:58:11+00:00
|
# timestamp: 2025-04-22T09:45:21+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: http://localhost:8080/openapi
|
||||||
# timestamp: 2025-04-22T08:58:11+00:00
|
# timestamp: 2025-04-22T09:45:21+00:00
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -1139,6 +1139,15 @@ class OpenAIImageGenerationRequest(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Datum1(BaseModel):
|
||||||
|
b64_json: Optional[str] = Field(None, description='Base64 encoded image data')
|
||||||
|
url: Optional[str] = Field(None, description='URL of the image')
|
||||||
|
|
||||||
|
|
||||||
|
class OpenAIImageGenerationResponse(BaseModel):
|
||||||
|
data: Optional[List[Datum1]] = None
|
||||||
|
|
||||||
|
|
||||||
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.'
|
||||||
@ -1186,7 +1195,7 @@ class RecraftImageGenerationRequest(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Datum1(BaseModel):
|
class Datum2(BaseModel):
|
||||||
image_id: Optional[str] = Field(
|
image_id: Optional[str] = Field(
|
||||||
None, description='Unique identifier for the generated image'
|
None, description='Unique identifier for the generated image'
|
||||||
)
|
)
|
||||||
@ -1198,7 +1207,7 @@ class RecraftImageGenerationResponse(BaseModel):
|
|||||||
..., description='Unix timestamp when the generation was created'
|
..., description='Unix timestamp when the generation was created'
|
||||||
)
|
)
|
||||||
credits: int = Field(..., description='Number of credits used for the generation')
|
credits: int = Field(..., description='Number of credits used for the generation')
|
||||||
data: List[Datum1] = Field(..., description='Array of generated image information')
|
data: List[Datum2] = Field(..., description='Array of generated image information')
|
||||||
|
|
||||||
|
|
||||||
class StorageFile(BaseModel):
|
class StorageFile(BaseModel):
|
||||||
|
|||||||
@ -138,6 +138,7 @@ class ApiClient:
|
|||||||
request_headers = self.get_headers()
|
request_headers = self.get_headers()
|
||||||
if headers:
|
if headers:
|
||||||
request_headers.update(headers)
|
request_headers.update(headers)
|
||||||
|
logging.debug(f"[DEBUG] Request Headers: {request_headers}")
|
||||||
try:
|
try:
|
||||||
response = requests.request(
|
response = requests.request(
|
||||||
method=method,
|
method=method,
|
||||||
@ -220,7 +221,7 @@ class SynchronousOperation(Generic[T, R]):
|
|||||||
self,
|
self,
|
||||||
endpoint: ApiEndpoint[T, R],
|
endpoint: ApiEndpoint[T, R],
|
||||||
request: T,
|
request: T,
|
||||||
api_base: str = "https://api.comfy.org",
|
api_base: str = "https://stagingapi.comfy.org",
|
||||||
auth_token: Optional[str] = None,
|
auth_token: Optional[str] = None,
|
||||||
timeout: float = 30.0,
|
timeout: float = 30.0,
|
||||||
verify_ssl: bool = True,
|
verify_ssl: bool = True,
|
||||||
|
|||||||
@ -7,6 +7,7 @@ from comfy_api_nodes.apis import (
|
|||||||
IdeogramGenerateResponse,
|
IdeogramGenerateResponse,
|
||||||
ImageRequest,
|
ImageRequest,
|
||||||
OpenAIImageGenerationRequest,
|
OpenAIImageGenerationRequest,
|
||||||
|
OpenAIImageGenerationResponse
|
||||||
)
|
)
|
||||||
from comfy_api_nodes.apis.client import ApiEndpoint, HttpMethod, SynchronousOperation
|
from comfy_api_nodes.apis.client import ApiEndpoint, HttpMethod, SynchronousOperation
|
||||||
|
|
||||||
@ -214,6 +215,9 @@ class OpenAITextToImage(ComfyNodeABC):
|
|||||||
"tooltip": "Optional random seed",
|
"tooltip": "Optional random seed",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
"hidden": {
|
||||||
|
"auth_token": "AUTH_TOKEN_COMFY_ORG"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = (IO.IMAGE,)
|
RETURN_TYPES = (IO.IMAGE,)
|
||||||
@ -222,7 +226,7 @@ class OpenAITextToImage(ComfyNodeABC):
|
|||||||
DESCRIPTION = cleandoc(__doc__ or "")
|
DESCRIPTION = cleandoc(__doc__ or "")
|
||||||
API_NODE = True
|
API_NODE = True
|
||||||
|
|
||||||
def api_call(self, prompt, model, n=1, size="1024x1024", seed=0):
|
def api_call(self, prompt, model, n=1, size="1024x1024", seed=0, auth_token=None):
|
||||||
# Validate size based on model
|
# Validate size based on model
|
||||||
if model == "dall-e-2":
|
if model == "dall-e-2":
|
||||||
if size == "auto":
|
if size == "auto":
|
||||||
@ -251,7 +255,7 @@ class OpenAITextToImage(ComfyNodeABC):
|
|||||||
path="/proxy/openai/images/generations",
|
path="/proxy/openai/images/generations",
|
||||||
method=HttpMethod.POST,
|
method=HttpMethod.POST,
|
||||||
request_model=OpenAIImageGenerationRequest,
|
request_model=OpenAIImageGenerationRequest,
|
||||||
response_model=None
|
response_model=OpenAIImageGenerationResponse
|
||||||
),
|
),
|
||||||
request=OpenAIImageGenerationRequest(
|
request=OpenAIImageGenerationRequest(
|
||||||
model=model,
|
model=model,
|
||||||
@ -260,20 +264,19 @@ class OpenAITextToImage(ComfyNodeABC):
|
|||||||
size=size,
|
size=size,
|
||||||
seed=seed if seed != 0 else None
|
seed=seed if seed != 0 else None
|
||||||
),
|
),
|
||||||
|
auth_token=auth_token
|
||||||
)
|
)
|
||||||
|
|
||||||
response = operation.execute()
|
response = operation.execute()
|
||||||
|
|
||||||
# validate raw JSON response
|
# validate raw JSON response
|
||||||
if not isinstance(response, dict) or 'data' not in response:
|
|
||||||
raise Exception("Invalid response format from OpenAI endpoint")
|
|
||||||
|
|
||||||
data = response['data']
|
data = response.data
|
||||||
if not data or len(data) == 0:
|
if not data or len(data) == 0:
|
||||||
raise Exception("No images returned from OpenAI endpoint")
|
raise Exception("No images returned from OpenAI endpoint")
|
||||||
|
|
||||||
# Get base64 image data
|
# Get base64 image data
|
||||||
b64_data = data[0].get('b64_json')
|
b64_data = data[0].b64_json
|
||||||
if not b64_data:
|
if not b64_data:
|
||||||
raise Exception("No image data in OpenAI response")
|
raise Exception("No image data in OpenAI response")
|
||||||
|
|
||||||
@ -292,7 +295,7 @@ class OpenAITextToImage(ComfyNodeABC):
|
|||||||
# NOTE: names should be globally unique
|
# NOTE: names should be globally unique
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"IdeogramTextToImage": IdeogramTextToImage,
|
"IdeogramTextToImage": IdeogramTextToImage,
|
||||||
"OpenAIDalleTextToImage": OpenAIDalleTextToImage,
|
"OpenAIDalleTextToImage": OpenAITextToImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user