Skip to content

Commit

Permalink
better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kytpbs committed Oct 18, 2023
1 parent a9f0488 commit 83a0878
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/GPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ def chat(main_message: str, message_history: dict[discord.User, str]):
messages=messages,
max_tokens=400,
)
except openai.OpenAIError:
except openai.OpenAIError as error:
logging.error(error, stack_info=True)
return ERROR2
if not isinstance(response, dict):
logging.error("response is not a dict: %s", response)
return ERROR2
answer = response['choices'][0]['message']['content']
logging.debug("replying to DM, %d tokens used", response['usage']['total_tokens'])
Expand Down

0 comments on commit 83a0878

Please sign in to comment.