mou3az commited on
Commit
9a921ed
1 Parent(s): 3e5ab6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -201,14 +201,10 @@ messages1_state = [
201
  SystemMessage(content="You are a helpful assistant."),
202
  HumanMessage(content="Hi AI, how are you today?"),
203
  AIMessage(content="I'm great thank you. How can I help you?")]
204
- messages1 = gr.State(messages1_state)
205
- messages2 = gr.State(messages1_state)
206
- messages3 = gr.State(messages1_state)
207
- messages4 = gr.State(messages1_state)
208
- messages5 = gr.State(messages1_state)
209
- messages6 = gr.State(messages1_state)
210
 
211
  def Chat_Message(history):
 
212
 
213
  message=HumanMessage(content=history[-1][0])
214
  messages1.append(message)
@@ -225,6 +221,7 @@ def Chat_Message(history):
225
  yield history
226
 
227
  def Internet_Search(history):
 
228
 
229
  message=history[-1][0]
230
 
@@ -247,8 +244,8 @@ def Internet_Search(history):
247
  msg=HumanMessage(content=augmented_prompt)
248
  messages2.append(msg)
249
 
250
- if len(messages2) >= 8:
251
- messages2 = messages2[-8:]
252
 
253
  response = chat_model.invoke(messages2)
254
  messages2.append(AIMessage(content=response.content))
@@ -260,6 +257,7 @@ def Internet_Search(history):
260
  yield history
261
 
262
  def Chart_Generator(history):
 
263
 
264
  message = history[-1][0]
265
  if '#chart' in message:
@@ -288,8 +286,8 @@ def Chart_Generator(history):
288
  prompt = HumanMessage(content=message)
289
  messages3.append(prompt)
290
 
291
- if len(messages3) >= 8:
292
- messages3 = messages3[-8:]
293
 
294
  response = chat_model.invoke(messages3)
295
  messages3.append(AIMessage(content=response.content))
@@ -303,6 +301,7 @@ def Chart_Generator(history):
303
  yield history
304
 
305
  def Link_Scratch(history):
 
306
 
307
  combined_message = history[-1][0]
308
 
@@ -336,8 +335,8 @@ def Link_Scratch(history):
336
  message = HumanMessage(content=augmented_prompt)
337
  messages4.append(message)
338
 
339
- if len(messages4) >= 2:
340
- messages4 = messages4[-2:]
341
 
342
  response = chat_model.invoke(messages4)
343
  messages4.append(AIMessage(content=response.content))
@@ -365,6 +364,7 @@ def display_file_name(file):
365
  raise gr.Error("( Supported File Types Only : PDF , CSV , TXT , DOCX , PPTX , XLSX , JSON , HTML , XML )")
366
 
367
  def File_Interact(history,filepath):
 
368
 
369
  combined_message = history[-1][0]
370
 
@@ -409,6 +409,7 @@ def File_Interact(history,filepath):
409
  yield history
410
 
411
  def Explore_WebSite(history):
 
412
 
413
  message=history[-1][0]
414
 
 
201
  SystemMessage(content="You are a helpful assistant."),
202
  HumanMessage(content="Hi AI, how are you today?"),
203
  AIMessage(content="I'm great thank you. How can I help you?")]
204
+
 
 
 
 
 
205
 
206
  def Chat_Message(history):
207
+ messages1 = gr.State(messages1_state)
208
 
209
  message=HumanMessage(content=history[-1][0])
210
  messages1.append(message)
 
221
  yield history
222
 
223
  def Internet_Search(history):
224
+ messages2 = gr.State(messages1_state)
225
 
226
  message=history[-1][0]
227
 
 
244
  msg=HumanMessage(content=augmented_prompt)
245
  messages2.append(msg)
246
 
247
+ if len(messages2) >= 4:
248
+ messages2 = messages2[-4:]
249
 
250
  response = chat_model.invoke(messages2)
251
  messages2.append(AIMessage(content=response.content))
 
257
  yield history
258
 
259
  def Chart_Generator(history):
260
+ messages3 = gr.State(messages1_state)
261
 
262
  message = history[-1][0]
263
  if '#chart' in message:
 
286
  prompt = HumanMessage(content=message)
287
  messages3.append(prompt)
288
 
289
+ if len(messages3) >= 6:
290
+ messages3 = messages3[-6:]
291
 
292
  response = chat_model.invoke(messages3)
293
  messages3.append(AIMessage(content=response.content))
 
301
  yield history
302
 
303
  def Link_Scratch(history):
304
+ messages4 = gr.State(messages1_state)
305
 
306
  combined_message = history[-1][0]
307
 
 
335
  message = HumanMessage(content=augmented_prompt)
336
  messages4.append(message)
337
 
338
+ if len(messages4) >= 3:
339
+ messages4 = messages4[-3:]
340
 
341
  response = chat_model.invoke(messages4)
342
  messages4.append(AIMessage(content=response.content))
 
364
  raise gr.Error("( Supported File Types Only : PDF , CSV , TXT , DOCX , PPTX , XLSX , JSON , HTML , XML )")
365
 
366
  def File_Interact(history,filepath):
367
+ messages5 = gr.State(messages1_state)
368
 
369
  combined_message = history[-1][0]
370
 
 
409
  yield history
410
 
411
  def Explore_WebSite(history):
412
+ messages6 = gr.State(messages1_state)
413
 
414
  message=history[-1][0]
415