-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: validate api key before saving config (#126)
* feature: validate api key before saving config * frontend code * remove print statements from backend api * cleanup for draft PR * pass openai error messaging to front-end modal * allow custom title for ErrorNotification component
- Loading branch information
1 parent
d9d2590
commit 58fd9dd
Showing
5 changed files
with
55 additions
and
28 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import openai | ||
|
||
def is_valid_api_key(openai_api_key: str): | ||
openai.api_key = openai_api_key | ||
try: | ||
openai.ChatCompletion.create( | ||
model="gpt-3.5-turbo", | ||
messages=[ | ||
{"role": "system", "content": "You are a helpful assistant."} | ||
] | ||
) | ||
return { 'validApiKey': True } | ||
except Exception as e: | ||
return { | ||
'validApiKey': False, | ||
'message': e.error.message | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58fd9dd
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.
Successfully deployed to the following URLs:
aixplora – ./
aixplora-grumpyp.vercel.app
aixplora-git-main-grumpyp.vercel.app
aixplora.vercel.app
aixplora.app
www.aixplora.app