-
Notifications
You must be signed in to change notification settings - Fork 44.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(agent): Handle OpenAI API key exceptions gracefully #6992
feat(agent): Handle OpenAI API key exceptions gracefully #6992
Conversation
✅ Deploy Preview for auto-gpt-docs canceled.
|
logger.info( | ||
"OpenAI API key successfully set!", | ||
extra={"color": Fore.GREEN}, | ||
) | ||
logger.info( | ||
"NOTE: The API key you've set is only temporary. " | ||
"For longer sessions, please set it in .env file", | ||
extra={"color": Fore.YELLOW}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why print
-> logger.info
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean only those two infos or the other logger.*
in the same file as well? I'm not sure when to use print or logging, why would I use print
if we have logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging is the application reporting what's going on. If a user wants less info, they can raise the log level and e.g. only get WARNING
and higher urgency messages.
print()
is direct terminal output to interface with the user. This is part of the UI, functionally different from the logging output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I replaced this just below as well - I think that's part of UI (prints after user inputted wrong key).
else:
print(f"{Fore.RED}Invalid OpenAI API key{Fore.RESET}")
This PR needs updating because |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
…incorrect-api-key
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
Done |
…incorrect-api-key
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6992 +/- ##
==========================================
- Coverage 45.54% 45.40% -0.15%
==========================================
Files 139 139
Lines 6514 6530 +16
Branches 915 917 +2
==========================================
- Hits 2967 2965 -2
- Misses 3397 3413 +16
- Partials 150 152 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
OPEN-337, OPEN-305