Skip to content
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

Better openai error handling in container image #888

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grai-server/app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "the_guide"
version = "0.1.59"
version = "0.1.60"
description = ""
authors = ["Grai <[email protected]>"]
license = "Elastic-2.0"
Expand Down
2 changes: 1 addition & 1 deletion grai-server/app/the_guide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__version__ = "0.1.59"
__version__ = "0.1.60"
__all__ = ("celery_app", "__version__")
6 changes: 6 additions & 0 deletions grai-server/app/the_guide/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ def inner(value: str | bool) -> bool:
except openai.AuthenticationError as e:
warnings.warn("Could not authenticate with OpenAI API key and organization id.")
HAS_OPENAI = False
except openai.APIConnectionError as e:
warnings.warn("Could not connect to OpenAI API and are disabling AI functionality.")
HAS_OPENAI = False
except Exception as e:
warnings.warn(f"We encountered an unknown error while trying to connect to OpenAI {e}")
HAS_OPENAI = False
else:
if len(models) == 0:
message = f"Provided OpenAI API key does not have access to any models as a result we've disabled OpenAI."
Expand Down
Loading