Fix encoding and formatting inconsistencies in error messages and comments
This commit is contained in:
parent
027de4192c
commit
cff4366b53
@ -7,7 +7,7 @@ import aiohttp
|
|||||||
# ────────────────────────────────────────────────
|
# ────────────────────────────────────────────────
|
||||||
def load_config(path: str):
|
def load_config(path: str):
|
||||||
"""Return a dict loaded from a YAML file."""
|
"""Return a dict loaded from a YAML file."""
|
||||||
with open(path, "r", encoding="utf‑8") as fh:
|
with open(path, "r", encoding="utf-8") as fh:
|
||||||
return yaml.safe_load(fh)
|
return yaml.safe_load(fh)
|
||||||
|
|
||||||
config = load_config("config.yml") # <- loads the config file
|
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 resp.status != 200:
|
||||||
# If the response is not 200, raise an error with the response text
|
# If the response is not 200, raise an error with the response text
|
||||||
data = await resp.text()
|
data = await resp.text()
|
||||||
raise RuntimeError(f"Open‑WebUI 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
|
# If the response is OK, parse the JSON and return the content
|
||||||
response_data = await resp.json()
|
response_data = await resp.json()
|
||||||
@ -121,7 +121,7 @@ async def on_message(message):
|
|||||||
prompt = f"{SYSTEM_PROMPT}\n\nUser Question: {message.content}"
|
prompt = f"{SYSTEM_PROMPT}\n\nUser Question: {message.content}"
|
||||||
|
|
||||||
# ----------------------------------------------------------------------- #
|
# ----------------------------------------------------------------------- #
|
||||||
# B. Query Open‑WebUI and show typing indicator
|
# B. Query Open-WebUI and show typing indicator
|
||||||
# ----------------------------------------------------------------------- #
|
# ----------------------------------------------------------------------- #
|
||||||
try:
|
try:
|
||||||
async with message.channel.typing():
|
async with message.channel.typing():
|
||||||
@ -130,7 +130,7 @@ async def on_message(message):
|
|||||||
# Send the reply
|
# Send the reply
|
||||||
await message.reply(reply)
|
await message.reply(reply)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await message.reply(f"⚠ Error contacting the Open‑WebUI 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.
|
# No need to return here as the function ends after this block.
|
||||||
|
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user