Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,15 +120,27 @@ def chat(user_input, history):
|
|
| 120 |
|
| 121 |
answer, source = get_answer(user_input)
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
return "", history
|
| 128 |
|
| 129 |
except Exception as e:
|
| 130 |
print("CHAT ERROR:", e)
|
| 131 |
-
history.append(
|
|
|
|
|
|
|
|
|
|
| 132 |
return "", history
|
| 133 |
|
| 134 |
|
|
|
|
| 120 |
|
| 121 |
answer, source = get_answer(user_input)
|
| 122 |
|
| 123 |
+
if not answer:
|
| 124 |
+
answer = "❌ No answer found."
|
| 125 |
+
|
| 126 |
+
if not source:
|
| 127 |
+
source = "No source available."
|
| 128 |
+
|
| 129 |
+
# ✅ NEW FORMAT (VERY IMPORTANT)
|
| 130 |
+
history.append({"role": "user", "content": user_input})
|
| 131 |
+
history.append({
|
| 132 |
+
"role": "assistant",
|
| 133 |
+
"content": answer + "\n\n📌 Source: " + source
|
| 134 |
+
})
|
| 135 |
|
| 136 |
return "", history
|
| 137 |
|
| 138 |
except Exception as e:
|
| 139 |
print("CHAT ERROR:", e)
|
| 140 |
+
history.append({
|
| 141 |
+
"role": "assistant",
|
| 142 |
+
"content": "⚠️ Something went wrong."
|
| 143 |
+
})
|
| 144 |
return "", history
|
| 145 |
|
| 146 |
|