Fix encoding and formatting inconsistencies in error messages and comments

This commit is contained in:
Pakobbix 2025-08-15 11:08:31 +02:00
parent 027de4192c
commit cff4366b53

View File

@ -7,7 +7,7 @@ import aiohttp
# ────────────────────────────────────────────────
def load_config(path: str):
"""Return a dict loaded from a YAML file."""
with open(path, "r", encoding="utf8") as fh:
with open(path, "r", encoding="utf-8") as fh:
return yaml.safe_load(fh)
config = load_config("config.yml") # <- loads the config file
@ -59,7 +59,7 @@ async def _query_openwebui(user_text: str, channel_id: int, tools_list: list):
if resp.status != 200:
# If the response is not 200, raise an error with the response text
data = await resp.text()
raise RuntimeError(f"OpenWebUI responded {resp.status}: {data}")
raise RuntimeError(f"Open-WebUI responded {resp.status}: {data}")
# If the response is OK, parse the JSON and return the content
response_data = await resp.json()
@ -121,7 +121,7 @@ async def on_message(message):
prompt = f"{SYSTEM_PROMPT}\n\nUser Question: {message.content}"
# ----------------------------------------------------------------------- #
# B. Query OpenWebUI and show typing indicator
# B. Query Open-WebUI and show typing indicator
# ----------------------------------------------------------------------- #
try:
async with message.channel.typing():
@ -130,7 +130,7 @@ async def on_message(message):
# Send the reply
await message.reply(reply)
except Exception as e:
await message.reply(f"⚠ Error contacting the OpenWebUI API: {e}")
await message.reply(f"⚠ Error contacting the Open-WebUI API: {e}")
# No need to return here as the function ends after this block.
# --------------------------------------------------------------------------- #