diff --git a/nodes_completions.py b/nodes_completions.py index 8b8a767..a032f64 100644 --- a/nodes_completions.py +++ b/nodes_completions.py @@ -72,7 +72,19 @@ class PostChatCompletions(io.ComfyNode): text_chunks = [] async with aiohttp.ClientSession() as session, \ session.post(url, headers=headers, json=body, timeout=timeout) as resp: - resp.raise_for_status() + # resp.raise_for_status() + if resp.status != 200: + error_text = await resp.text() + try: + logger.error(f"API Error ({resp.status}): {error_text}") + error_json = json.loads(error_text) + error_msg = error_json.get("message", error_text) + for line in filter(None, map(str.strip, error_msg.splitlines())): + logger.error(f" - {line}") + except: + error_msg = error_text + + raise RuntimeError(f"API Error ({resp.status}):\n{error_msg}") if not is_stream: result_json = await resp.json() diff --git a/pyproject.toml b/pyproject.toml index b6c7c80..2a17935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "ComfyUI-LLM-Helper" description = "A custom nodes for LLM API" -version = "1.0.5" # Custom Node version. Must be semantically versioned. +version = "1.0.6" # Custom Node version. Must be semantically versioned. license = { file = "LICENSE" } dependencies = [ "python-dotenv"