Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -70,14 +70,17 @@ def generate_questions_with_retry(knowledge_material, question_type, cognitive_l
|
|
70 |
retries = 0
|
71 |
while retries < max_retries:
|
72 |
try:
|
73 |
-
# Use the
|
74 |
-
response = openai.
|
75 |
-
model="
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
79 |
)
|
80 |
-
return response.choices[0].
|
81 |
except openai.APIConnectionError as e:
|
82 |
retries += 1
|
83 |
time.sleep(2) # Wait for 2 seconds before retrying
|
|
|
70 |
retries = 0
|
71 |
while retries < max_retries:
|
72 |
try:
|
73 |
+
# Use the new method `ChatCompletion.create`
|
74 |
+
response = openai.ChatCompletion.create(
|
75 |
+
model="gpt-3.5-turbo", # You can use "gpt-4" if available
|
76 |
+
messages=[
|
77 |
+
{"role": "system", "content": "You are a helpful assistant for generating exam questions."},
|
78 |
+
{"role": "user", "content": prompt}
|
79 |
+
],
|
80 |
+
max_tokens=1000,
|
81 |
+
temperature=0.7
|
82 |
)
|
83 |
+
return response.choices[0].message["content"] # Get the response text
|
84 |
except openai.APIConnectionError as e:
|
85 |
retries += 1
|
86 |
time.sleep(2) # Wait for 2 seconds before retrying
|