mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-09 04:57:02 +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
|
result = operation.execute(client=api_client) # Returns the final ImageGenerationResult when done
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import io
|
import io
|
||||||
@ -196,7 +197,6 @@ class ApiClient:
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_headers(self) -> Dict[str, str]:
|
def get_headers(self) -> Dict[str, str]:
|
||||||
"""Get headers for API requests, including authentication if available"""
|
"""Get headers for API requests, including authentication if available"""
|
||||||
headers = {"Content-Type": "application/json", "Accept": "application/json"}
|
headers = {"Content-Type": "application/json", "Accept": "application/json"}
|
||||||
@ -251,12 +251,13 @@ class ApiClient:
|
|||||||
logging.debug(f"[DEBUG] Params: {params}")
|
logging.debug(f"[DEBUG] Params: {params}")
|
||||||
logging.debug(f"[DEBUG] Data: {data}")
|
logging.debug(f"[DEBUG] Data: {data}")
|
||||||
|
|
||||||
match content_type:
|
if content_type == "application/x-www-form-urlencoded":
|
||||||
case "application/x-www-form-urlencoded":
|
|
||||||
payload_args = self._create_urlencoded_form_data_args(data, request_headers)
|
payload_args = self._create_urlencoded_form_data_args(data, request_headers)
|
||||||
case "multipart/form-data":
|
elif content_type == "multipart/form-data":
|
||||||
payload_args = self._create_form_data_args(data, files, request_headers, multipart_parser)
|
payload_args = self._create_form_data_args(
|
||||||
case _:
|
data, files, request_headers, multipart_parser
|
||||||
|
)
|
||||||
|
else:
|
||||||
payload_args = self._create_json_payload_args(data, request_headers)
|
payload_args = self._create_json_payload_args(data, request_headers)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -99,18 +99,17 @@ def model_field_to_node_input(
|
|||||||
field_info: FieldInfo = base_model.model_fields[field_name]
|
field_info: FieldInfo = base_model.model_fields[field_name]
|
||||||
result: NodeInput
|
result: NodeInput
|
||||||
|
|
||||||
match input_type:
|
if input_type == IO.IMAGE:
|
||||||
case IO.IMAGE:
|
|
||||||
result = _model_field_to_image_input(field_info, **kwargs)
|
result = _model_field_to_image_input(field_info, **kwargs)
|
||||||
case IO.STRING:
|
elif input_type == IO.STRING:
|
||||||
result = _model_field_to_string_input(field_info, **kwargs)
|
result = _model_field_to_string_input(field_info, **kwargs)
|
||||||
case IO.FLOAT:
|
elif input_type == IO.FLOAT:
|
||||||
result = _model_field_to_float_input(field_info, **kwargs)
|
result = _model_field_to_float_input(field_info, **kwargs)
|
||||||
case IO.INT:
|
elif input_type == IO.INT:
|
||||||
result = _model_field_to_int_input(field_info, **kwargs)
|
result = _model_field_to_int_input(field_info, **kwargs)
|
||||||
case IO.COMBO:
|
elif input_type == IO.COMBO:
|
||||||
result = _model_field_to_combo_input(field_info, **kwargs)
|
result = _model_field_to_combo_input(field_info, **kwargs)
|
||||||
case _:
|
else:
|
||||||
message = f"Invalid input type: {input_type}"
|
message = f"Invalid input type: {input_type}"
|
||||||
raise ValueError(message)
|
raise ValueError(message)
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
- [Compatibility Table](https://app.klingai.com/global/dev/document-api/apiReference/model/skillsMap)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
from typing import Optional, TypeVar, Any
|
from typing import Optional, TypeVar, Any
|
||||||
import math
|
import math
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user