AjayArmugam commited on
Commit
ed81f4d
·
verified ·
1 Parent(s): 3eea26e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -120,15 +120,27 @@ def chat(user_input, history):
120
 
121
  answer, source = get_answer(user_input)
122
 
123
- history.append(
124
- (user_input, answer + "\n\n📌 Source: " + source)
125
- )
 
 
 
 
 
 
 
 
 
126
 
127
  return "", history
128
 
129
  except Exception as e:
130
  print("CHAT ERROR:", e)
131
- history.append((user_input, "⚠️ Something went wrong."))
 
 
 
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