From eabc6413206ad403027173c61bdb9d79d3ce115a Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 12 Apr 2023 18:49:59 +0200 Subject: [PATCH] make error message start with so they get excluded from chat log --- matrix_pygmalion_bot/ai/koboldcpp.py | 2 +- matrix_pygmalion_bot/ai/runpod_pygmalion.py | 16 ++++++++-------- matrix_pygmalion_bot/core.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/matrix_pygmalion_bot/ai/koboldcpp.py b/matrix_pygmalion_bot/ai/koboldcpp.py index 96f7614..5214589 100644 --- a/matrix_pygmalion_bot/ai/koboldcpp.py +++ b/matrix_pygmalion_bot/ai/koboldcpp.py @@ -65,7 +65,7 @@ async def generate_sync( try: r = requests.post(endpoint, json=input_data, headers=headers, timeout=360) except requests.exceptions.RequestException as e: - raise ValueError(f" {e}") + raise ValueError(f" HTTP ERROR {e}") r_json = r.json() logger.info(r_json) if r.status_code == 200: diff --git a/matrix_pygmalion_bot/ai/runpod_pygmalion.py b/matrix_pygmalion_bot/ai/runpod_pygmalion.py index e532247..4fecfcc 100644 --- a/matrix_pygmalion_bot/ai/runpod_pygmalion.py +++ b/matrix_pygmalion_bot/ai/runpod_pygmalion.py @@ -95,8 +95,8 @@ async def generate_sync( else: err_msg = r_json["error"] if "error" in r_json else "" err_msg = err_msg.replace("\\n", "\n") - raise ValueError(f"RETURN CODE {status}: {err_msg}") - raise ValueError(f"") + raise ValueError(f" RETURN CODE {status}: {err_msg}") + raise ValueError(f" TIMEOUT") else: raise ValueError(f"") @@ -137,7 +137,7 @@ async def generate_image(input_prompt: str, negative_prompt: str, api_url: str, try: r = requests.post(endpoint, json=input_data, headers=headers) except requests.exceptions.RequestException as e: - raise ValueError(f"") + raise ValueError(f" HTTP ERROR") r_json = r.json() logger.debug(r_json) @@ -145,7 +145,7 @@ async def generate_image(input_prompt: str, negative_prompt: str, api_url: str, status = r_json["status"] if status != 'IN_QUEUE': err_msg = r_json["error"] if "error" in r_json else "" - raise ValueError(f"RETURN CODE {status}: {err_msg}") + raise ValueError(f" RETURN CODE {status}: {err_msg}") job_id = r_json["id"] TIMEOUT = 360 DELAY = 5 @@ -167,7 +167,7 @@ async def generate_image(input_prompt: str, negative_prompt: str, api_url: str, else: err_msg = r_json["error"] if "error" in r_json else "" err_msg = err_msg.replace("\\n", "\n") - raise ValueError(f"RETURN CODE {status}: {err_msg}") + raise ValueError(f" RETURN CODE {status}: {err_msg}") if not output: raise ValueError(f"") @@ -238,7 +238,7 @@ async def serverless_automatic_request(payload, cmd, api_url: str, api_key: str, try: r = requests.post(endpoint, json=input_data, headers=headers) except requests.exceptions.RequestException as e: - raise ValueError(f"") + raise ValueError(f" HTTP ERROR") r_json = r.json() logger.debug(r_json) @@ -246,7 +246,7 @@ async def serverless_automatic_request(payload, cmd, api_url: str, api_key: str, status = r_json["status"] if status != 'IN_QUEUE': err_msg = r_json["error"] if "error" in r_json else "" - raise ValueError(f"RETURN CODE {status}: {err_msg}") + raise ValueError(f" RETURN CODE {status}: {err_msg}") job_id = r_json["id"] TIMEOUT = 360 DELAY = 5 @@ -267,7 +267,7 @@ async def serverless_automatic_request(payload, cmd, api_url: str, api_key: str, break else: err_msg = r_json["error"] if "error" in r_json else "" - raise ValueError(f"RETURN CODE {status}: {err_msg}") + raise ValueError(f" RETURN CODE {status}: {err_msg}") if not output: raise ValueError(f" {status}") diff --git a/matrix_pygmalion_bot/core.py b/matrix_pygmalion_bot/core.py index e823e14..377e2b4 100644 --- a/matrix_pygmalion_bot/core.py +++ b/matrix_pygmalion_bot/core.py @@ -208,7 +208,7 @@ class Callbacks(object): chat_message.updateText( event.body.removeprefix('!2').strip() ) api_endpoint = "ynznznpn6qz6yh" elif event.body.startswith('!'): - await self.bot.send_message(self.client, room.room_id, "UNKNOWN COMMAND") + await self.bot.send_message(self.client, room.room_id, " UNKNOWN COMMAND") return # Other commands