Spaces:
Runtime error

AkanshaRajput commited on
Commit
93a8955
·
verified ·
1 Parent(s): 1d91460

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -21,7 +21,17 @@ Be gentle, encouraging, and realistic. End with one practical step they can take
21
 
22
  Keep it under 200 words.
23
  """
24
-
 
 
 
 
 
 
 
 
 
 
25
  response = openai.ChatCompletion.create(
26
  model="gpt-3.5-turbo",
27
  messages=[
 
21
 
22
  Keep it under 200 words.
23
  """
24
+ try:
25
+ response = openai.ChatCompletion.create(
26
+ model="gpt-3.5-turbo",
27
+ messages=[
28
+ {"role": "system", "content": "You are a helpful assistant."},
29
+ {"role": "user", "content": prompt}
30
+ ]
31
+ )
32
+ return response.choices[0].message["content"]
33
+ except Exception as e:
34
+ return f"Error: {e}"
35
  response = openai.ChatCompletion.create(
36
  model="gpt-3.5-turbo",
37
  messages=[