Skip to content

Commit

Permalink
Merge pull request #40 from jnichols0/main
Browse files Browse the repository at this point in the history
Revert model to gpt-3.5-turbo when gpt-4 is not available.
  • Loading branch information
patillacode authored Jun 15, 2023
2 parents 68e4a58 + 046089d commit 12cb93f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ class AI:
def __init__(self, **kwargs):
self.kwargs = kwargs

try:
openai.Model.retrieve("gpt-4")
except openai.error.InvalidRequestError:
print("Model gpt-4 not available for provided api key reverting "
"to gpt-3.5.turbo. Sign up for the gpt-4 wait list here: "
"https://openai.com/waitlist/gpt-4-api")
self.kwargs['model'] = "gpt-3.5-turbo"

def start(self, system, user):
messages = [
{"role": "system", "content": system},
Expand Down

0 comments on commit 12cb93f

Please sign in to comment.