Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -26,11 +26,15 @@ def fetch_news(query):
|
|
26 |
def summarize_text(text):
|
27 |
"""Summarize the text using OpenAI GPT."""
|
28 |
response = openai.Completion.create(
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
max_tokens=150
|
32 |
)
|
33 |
-
return response
|
|
|
34 |
|
35 |
def generate_image(prompt):
|
36 |
"""Generate an image using DALL路E."""
|
|
|
26 |
def summarize_text(text):
|
27 |
"""Summarize the text using OpenAI GPT."""
|
28 |
response = openai.Completion.create(
|
29 |
+
model="gpt-3.5-turbo", # Use the newer model
|
30 |
+
messages=[
|
31 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
32 |
+
{"role": "user", "content": f"Summarize this for a social media post:\n\n{text}"}
|
33 |
+
],
|
34 |
max_tokens=150
|
35 |
)
|
36 |
+
return response['choices'][0]['message']['content'].strip()
|
37 |
+
|
38 |
|
39 |
def generate_image(prompt):
|
40 |
"""Generate an image using DALL路E."""
|