Update app.py
Browse files
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 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
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."
|