throw better error message
This commit is contained in:
+13
-1
@@ -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()
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user