Update game_manager.py
Browse files- game_manager.py +9 -3
game_manager.py
CHANGED
@@ -27,9 +27,15 @@ def ai_response(question):
|
|
27 |
prompt = PROMPT.format(
|
28 |
question,
|
29 |
)
|
30 |
-
completions =
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
response = completions["choices"][0]["text"].strip()
|
34 |
|
35 |
return response
|
|
|
27 |
prompt = PROMPT.format(
|
28 |
question,
|
29 |
)
|
30 |
+
completions = None
|
31 |
+
while completions is None:
|
32 |
+
try:
|
33 |
+
completions = openai.Completion.create(
|
34 |
+
engine="text-davinci-003", prompt=prompt, max_tokens=200, n=1, temperature=0.5
|
35 |
+
)
|
36 |
+
except:
|
37 |
+
print("OpenAI connection error")
|
38 |
+
time.sleep(1)
|
39 |
response = completions["choices"][0]["text"].strip()
|
40 |
|
41 |
return response
|