revert to gpt-3.5-turbo when gpt-4 is not available

This commit is contained in:
jnichols0
2023-06-15 01:10:42 -04:00
parent e7e3292116
commit 046089d38c

8
ai.py
View File

@@ -6,6 +6,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},