Browse Source

make error message start with <ERROR> so they get excluded from chat log

master
Hendrik Langer 2 years ago
parent
commit
eabc641320
  1. 2
      matrix_pygmalion_bot/ai/koboldcpp.py
  2. 16
      matrix_pygmalion_bot/ai/runpod_pygmalion.py
  3. 2
      matrix_pygmalion_bot/core.py

2
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"<HTTP ERROR> {e}")
raise ValueError(f"<ERROR> HTTP ERROR {e}")
r_json = r.json()
logger.info(r_json)
if r.status_code == 200:

16
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"<TIMEOUT>")
raise ValueError(f"<ERROR> RETURN CODE {status}: {err_msg}")
raise ValueError(f"<ERROR> TIMEOUT")
else:
raise ValueError(f"<ERROR>")
@ -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"<HTTP ERROR>")
raise ValueError(f"<ERROR> 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"<ERROR> 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"<ERROR> RETURN CODE {status}: {err_msg}")
if not output:
raise ValueError(f"<ERROR>")
@ -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"<HTTP ERROR>")
raise ValueError(f"<ERROR> 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"<ERROR> 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"<ERROR> RETURN CODE {status}: {err_msg}")
if not output:
raise ValueError(f"<ERROR> {status}")

2
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, "<ERROR> UNKNOWN COMMAND")
return
# Other commands

Loading…
Cancel
Save