Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
from typing import List, Tuple
|
|
|
|
| 5 |
|
| 6 |
# Initialize OpenAI client
|
| 7 |
def initialize_openai():
|
|
@@ -24,6 +25,7 @@ def generate_qa_pairs(topic: str, difficulty: str = "Medium") -> str:
|
|
| 24 |
"""
|
| 25 |
try:
|
| 26 |
client = initialize_openai()
|
|
|
|
| 27 |
|
| 28 |
# Create the prompt
|
| 29 |
prompt = f"""Generate exactly 10 questions and answers about the topic: "{topic}"
|
|
@@ -54,7 +56,7 @@ Please generate the questions and answers now:"""
|
|
| 54 |
}
|
| 55 |
],
|
| 56 |
max_tokens=2000,
|
| 57 |
-
temperature=0.
|
| 58 |
)
|
| 59 |
|
| 60 |
return response.choices[0].message.content
|
|
|
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
from typing import List, Tuple
|
| 5 |
+
import time
|
| 6 |
|
| 7 |
# Initialize OpenAI client
|
| 8 |
def initialize_openai():
|
|
|
|
| 25 |
"""
|
| 26 |
try:
|
| 27 |
client = initialize_openai()
|
| 28 |
+
time.sleep(5)
|
| 29 |
|
| 30 |
# Create the prompt
|
| 31 |
prompt = f"""Generate exactly 10 questions and answers about the topic: "{topic}"
|
|
|
|
| 56 |
}
|
| 57 |
],
|
| 58 |
max_tokens=2000,
|
| 59 |
+
temperature=0.2
|
| 60 |
)
|
| 61 |
|
| 62 |
return response.choices[0].message.content
|