Skip to content

Commit 913c680

Browse files
authored
More debug logging in LLM (#718)
1 parent dcdaa71 commit 913c680

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

gramps_webapi/api/llm/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,20 @@ def answer_prompt(prompt: str, system_prompt: str, config: dict | None = None) -
5252
model = config.get("LLM_MODEL") # type: ignore
5353
assert model is not None, "No LLM model specified" # mypy; shouldn't happen
5454

55+
logger = get_logger()
5556
try:
5657
response = client.chat.completions.create(
5758
messages=messages, # type: ignore
5859
model=model,
5960
)
60-
except RateLimitError:
61+
except RateLimitError as exc:
62+
logger.exception("Chat API rate limit exceeded: %s", exc)
6163
abort_with_message(500, "Chat API rate limit exceeded.")
62-
except APIError:
64+
except APIError as exc:
65+
logger.exception("Chat API error encountered: %s", exc)
6366
abort_with_message(500, "Chat API error encountered.")
64-
except Exception:
67+
except Exception as exc:
68+
logger.exception("Unexpected error: %s", exc)
6569
abort_with_message(500, "Unexpected error.")
6670

6771
try:

0 commit comments

Comments
 (0)