Update app.py
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ def create_flashcards(content):
|
|
| 26 |
# Fetch the secret prompt from environment variables
|
| 27 |
prompt = os.getenv("FLASHCARD_PROMPT")
|
| 28 |
|
| 29 |
-
response = openai.
|
| 30 |
model="gpt-3.5-turbo",
|
| 31 |
messages=[
|
| 32 |
{"role": "system", "content": prompt},
|
|
@@ -36,7 +36,7 @@ def create_flashcards(content):
|
|
| 36 |
temperature=0.7
|
| 37 |
)
|
| 38 |
|
| 39 |
-
flashcards = response
|
| 40 |
return flashcards
|
| 41 |
|
| 42 |
# Function to process a single URL and generate flashcards
|
|
@@ -69,4 +69,4 @@ iface = gr.Interface(
|
|
| 69 |
|
| 70 |
# Launch the interface
|
| 71 |
if __name__ == "__main__":
|
| 72 |
-
iface.launch(share=False)
|
|
|
|
| 26 |
# Fetch the secret prompt from environment variables
|
| 27 |
prompt = os.getenv("FLASHCARD_PROMPT")
|
| 28 |
|
| 29 |
+
response = openai.chat.completions.create(
|
| 30 |
model="gpt-3.5-turbo",
|
| 31 |
messages=[
|
| 32 |
{"role": "system", "content": prompt},
|
|
|
|
| 36 |
temperature=0.7
|
| 37 |
)
|
| 38 |
|
| 39 |
+
flashcards = response.choices[0].message.content.strip()
|
| 40 |
return flashcards
|
| 41 |
|
| 42 |
# Function to process a single URL and generate flashcards
|
|
|
|
| 69 |
|
| 70 |
# Launch the interface
|
| 71 |
if __name__ == "__main__":
|
| 72 |
+
iface.launch(share=False, ssr=False)
|