AyeshaAslam commited on
Commit
861530a
verified
1 Parent(s): 1210874

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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
- engine="text-davinci-003",
30
- prompt=f"Summarize this for a social media post:\n\n{text}",
 
 
 
31
  max_tokens=150
32
  )
33
- return response.choices[0].text.strip()
 
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."""