diff --git a/comfy_api_nodes/apis/client.py b/comfy_api_nodes/apis/client.py index 496831ac4..929e386d4 100644 --- a/comfy_api_nodes/apis/client.py +++ b/comfy_api_nodes/apis/client.py @@ -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( diff --git a/comfy_api_nodes/mapper_utils.py b/comfy_api_nodes/mapper_utils.py index f8fd5632e..6fab8f4bb 100644 --- a/comfy_api_nodes/mapper_utils.py +++ b/comfy_api_nodes/mapper_utils.py @@ -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 diff --git a/comfy_api_nodes/nodes_kling.py b/comfy_api_nodes/nodes_kling.py index 8f94d35fd..b3be2bac8 100644 --- a/comfy_api_nodes/nodes_kling.py +++ b/comfy_api_nodes/nodes_kling.py @@ -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