mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-05 18:17:06 +08:00
Add API_NODE and common error for missing auth token (#5)
This commit is contained in:
parent
7290683905
commit
e7dad1d7db
@ -4,6 +4,12 @@ API_BASE = "https://stagingapi.comfy.org"
|
|||||||
from inspect import cleandoc
|
from inspect import cleandoc
|
||||||
from comfy.comfy_types.node_typing import ComfyNodeABC, InputTypeDict, IO
|
from comfy.comfy_types.node_typing import ComfyNodeABC, InputTypeDict, IO
|
||||||
|
|
||||||
|
def check_auth_token(auth_token):
|
||||||
|
"""Verify that an auth token is present."""
|
||||||
|
if auth_token is None:
|
||||||
|
raise Exception("Please login first to use this node.")
|
||||||
|
return auth_token
|
||||||
|
|
||||||
class IdeogramTextToImage(ComfyNodeABC):
|
class IdeogramTextToImage(ComfyNodeABC):
|
||||||
"""
|
"""
|
||||||
Generates images synchronously based on a given prompt and optional parameters.
|
Generates images synchronously based on a given prompt and optional parameters.
|
||||||
@ -84,13 +90,9 @@ class IdeogramTextToImage(ComfyNodeABC):
|
|||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = (IO.IMAGE,)
|
RETURN_TYPES = (IO.IMAGE,)
|
||||||
#RETURN_NAMES = ("image_output_name",)
|
|
||||||
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
|
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
|
||||||
FUNCTION = "api_call"
|
FUNCTION = "api_call"
|
||||||
|
API_NODE = True
|
||||||
#OUTPUT_NODE = False
|
|
||||||
#OUTPUT_TOOLTIPS = ("",) # Tooltips for the output node
|
|
||||||
|
|
||||||
CATEGORY = "Example"
|
CATEGORY = "Example"
|
||||||
|
|
||||||
def api_call(self, prompt, model, aspect_ratio=None, resolution=None,
|
def api_call(self, prompt, model, aspect_ratio=None, resolution=None,
|
||||||
@ -102,6 +104,8 @@ class IdeogramTextToImage(ComfyNodeABC):
|
|||||||
import io
|
import io
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
check_auth_token(auth_token)
|
||||||
|
|
||||||
# Build payload with all available parameters
|
# Build payload with all available parameters
|
||||||
payload = {
|
payload = {
|
||||||
"image_request": {
|
"image_request": {
|
||||||
@ -217,11 +221,12 @@ class RunwayVideoNode:
|
|||||||
DESCRIPTION = "Generates videos from images using Runway's API"
|
DESCRIPTION = "Generates videos from images using Runway's API"
|
||||||
FUNCTION = "generate_video"
|
FUNCTION = "generate_video"
|
||||||
CATEGORY = "video"
|
CATEGORY = "video"
|
||||||
|
API_NODE = True
|
||||||
|
|
||||||
def generate_video(self, prompt_image, prompt_text, seed=0, model="gen3a_turbo",
|
def generate_video(self, prompt_image, prompt_text, seed=0, model="gen3a_turbo",
|
||||||
duration=5.0, ratio="1280:768", watermark=False, auth_token=None):
|
duration=5.0, ratio="1280:768", watermark=False, auth_token=None):
|
||||||
import requests
|
import requests
|
||||||
|
check_auth_token(auth_token)
|
||||||
# Convert torch tensor image to URL (you'll need to implement this part)
|
# Convert torch tensor image to URL (you'll need to implement this part)
|
||||||
# This is a placeholder - you'll need to either save the image temporarily
|
# This is a placeholder - you'll need to either save the image temporarily
|
||||||
# or upload it to a service that can host it
|
# or upload it to a service that can host it
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user