Skip to content

Commit

Permalink
dev: Enhance logging for OpenAI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Feb 28, 2024
1 parent f0bb177 commit dd22dd5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ async def llm_completion(text: Optional[str], call: CallModel) -> Optional[str]:
messages=call.messages,
system=system,
)
except ReadError:
_logger.warn(f"Network error", exc_info=True)
except APIError:
_logger.warn("OpenAI API call error", exc_info=True)
except SafetyCheckError as e:
Expand Down Expand Up @@ -737,6 +739,8 @@ async def llm_model(
model=model,
system=system,
)
except ReadError:
_logger.warn(f"Network error", exc_info=True)
except APIError:
_logger.warn("OpenAI API call error", exc_info=True)

Expand Down Expand Up @@ -901,7 +905,7 @@ async def _tool_cancellation_callback() -> None:
_logger.warn(f"Network error", exc_info=True)
return True, True, should_user_answer, call
except APIError:
_logger.warn("OpenAI API call error")
_logger.warn("OpenAI API call error", exc_info=True)
return True, True, should_user_answer, call

# Flush the remaining buffer
Expand Down

0 comments on commit dd22dd5

Please sign in to comment.