agnixcode commited on
Commit
c584b78
·
verified ·
1 Parent(s): a0b7a97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -145,14 +145,18 @@ def chat(user_input, history):
145
  global chat_history
146
 
147
  # Build full context (PDF + conversation history)
148
- full_context = "\n".join([
149
- f"User: {h['user']}\nBot: {h['bot']}"
150
- for h in chat_history[-5:]
151
- ]) if chat_history else ""
152
- answer = generate_answer(user_input, full_context)
 
153
 
154
  # Store in memory
155
- chat_history.append({"user": user_input, "bot": answer})
 
 
 
156
 
157
  # Update UI history
158
  new_history = history + [
@@ -161,7 +165,6 @@ answer = generate_answer(user_input, full_context)
161
  ]
162
 
163
  return new_history, new_history
164
-
165
  def generate_answer(query, conversation_context=""):
166
  if index is None:
167
  return "⚠️ Please load a PDF first."
 
145
  global chat_history
146
 
147
  # Build full context (PDF + conversation history)
148
+ full_context = "\n".join([
149
+ f"User: {h['user']}\nBot: {h['bot']}"
150
+ for h in chat_history[-5:]
151
+ ]) if chat_history else ""
152
+
153
+ answer = generate_answer(user_input, full_context)
154
 
155
  # Store in memory
156
+ chat_history.append({
157
+ "user": user_input,
158
+ "bot": answer
159
+ })
160
 
161
  # Update UI history
162
  new_history = history + [
 
165
  ]
166
 
167
  return new_history, new_history
 
168
  def generate_answer(query, conversation_context=""):
169
  if index is None:
170
  return "⚠️ Please load a PDF first."