mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-06 11:27:04 +08:00
Use 3.9 compat syntax (#164)
This commit is contained in:
parent
a75d35e982
commit
ec89560fad
@ -89,6 +89,7 @@ operation = PollingOperation(
|
||||
result = operation.execute(client=api_client) # Returns the final ImageGenerationResult when done
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import logging
|
||||
import time
|
||||
import io
|
||||
@ -196,7 +197,6 @@ class ApiClient:
|
||||
"headers": headers,
|
||||
}
|
||||
|
||||
|
||||
def get_headers(self) -> Dict[str, str]:
|
||||
"""Get headers for API requests, including authentication if available"""
|
||||
headers = {"Content-Type": "application/json", "Accept": "application/json"}
|
||||
@ -251,13 +251,14 @@ class ApiClient:
|
||||
logging.debug(f"[DEBUG] Params: {params}")
|
||||
logging.debug(f"[DEBUG] Data: {data}")
|
||||
|
||||
match content_type:
|
||||
case "application/x-www-form-urlencoded":
|
||||
payload_args = self._create_urlencoded_form_data_args(data, request_headers)
|
||||
case "multipart/form-data":
|
||||
payload_args = self._create_form_data_args(data, files, request_headers, multipart_parser)
|
||||
case _:
|
||||
payload_args = self._create_json_payload_args(data, request_headers)
|
||||
if content_type == "application/x-www-form-urlencoded":
|
||||
payload_args = self._create_urlencoded_form_data_args(data, request_headers)
|
||||
elif content_type == "multipart/form-data":
|
||||
payload_args = self._create_form_data_args(
|
||||
data, files, request_headers, multipart_parser
|
||||
)
|
||||
else:
|
||||
payload_args = self._create_json_payload_args(data, request_headers)
|
||||
|
||||
try:
|
||||
response = requests.request(
|
||||
|
||||
@ -99,19 +99,18 @@ def model_field_to_node_input(
|
||||
field_info: FieldInfo = base_model.model_fields[field_name]
|
||||
result: NodeInput
|
||||
|
||||
match input_type:
|
||||
case IO.IMAGE:
|
||||
result = _model_field_to_image_input(field_info, **kwargs)
|
||||
case IO.STRING:
|
||||
result = _model_field_to_string_input(field_info, **kwargs)
|
||||
case IO.FLOAT:
|
||||
result = _model_field_to_float_input(field_info, **kwargs)
|
||||
case IO.INT:
|
||||
result = _model_field_to_int_input(field_info, **kwargs)
|
||||
case IO.COMBO:
|
||||
result = _model_field_to_combo_input(field_info, **kwargs)
|
||||
case _:
|
||||
message = f"Invalid input type: {input_type}"
|
||||
raise ValueError(message)
|
||||
if input_type == IO.IMAGE:
|
||||
result = _model_field_to_image_input(field_info, **kwargs)
|
||||
elif input_type == IO.STRING:
|
||||
result = _model_field_to_string_input(field_info, **kwargs)
|
||||
elif input_type == IO.FLOAT:
|
||||
result = _model_field_to_float_input(field_info, **kwargs)
|
||||
elif input_type == IO.INT:
|
||||
result = _model_field_to_int_input(field_info, **kwargs)
|
||||
elif input_type == IO.COMBO:
|
||||
result = _model_field_to_combo_input(field_info, **kwargs)
|
||||
else:
|
||||
message = f"Invalid input type: {input_type}"
|
||||
raise ValueError(message)
|
||||
|
||||
return result
|
||||
|
||||
@ -4,6 +4,7 @@ For source of truth on the allowed permutations of request fields, please refere
|
||||
- [Compatibility Table](https://app.klingai.com/global/dev/document-api/apiReference/model/skillsMap)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Optional, TypeVar, Any
|
||||
import math
|
||||
import logging
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user