Ashar086 commited on
Commit
edc8718
·
verified ·
1 Parent(s): f1f805a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -22,14 +22,15 @@ if 'current_page' not in st.session_state:
22
 
23
  # --- Helper Functions ---
24
  def get_gpt4_response(prompt):
25
- response = openai.ChatCompletion.create(
26
- model="gpt-4o",
27
- messages=[
28
- {"role": "system", "content": "You are Emma, a helpful assistant."},
29
- {"role": "user", "content": prompt}
30
- ]
31
- )
32
- return response["choices"][0]["message"]["content"]
 
33
  except Exception as e:
34
  st.error("Error with GPT-4 API. Please check your API key or connection.")
35
  return "I'm having trouble responding at the moment. Please try again later."
 
22
 
23
  # --- Helper Functions ---
24
  def get_gpt4_response(prompt):
25
+ try:
26
+ response = openai.ChatCompletion.create(
27
+ model="gpt-4o",
28
+ messages=[
29
+ {"role": "system", "content": "You are Emma, a helpful assistant."},
30
+ {"role": "user", "content": prompt}
31
+ ]
32
+ )
33
+ return response["choices"][0]["message"]["content"]
34
  except Exception as e:
35
  st.error("Error with GPT-4 API. Please check your API key or connection.")
36
  return "I'm having trouble responding at the moment. Please try again later."