mou3az commited on
Commit
4b5b051
1 Parent(s): 450e4a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -206,12 +206,12 @@ def Chat_Message(history):
206
  global messages1
207
 
208
  message=HumanMessage(content=history[-1][0])
209
- messages.append(message)
210
- response = chat_model.invoke(messages)
211
- messages.append(AIMessage(content=response.content))
212
 
213
- if len(messages) >= 8:
214
- messages = messages[-8:]
215
 
216
  history[-1][1] = ""
217
  for character in response.content:
@@ -239,12 +239,12 @@ def Web_Search(history):
239
  """
240
 
241
  msg=HumanMessage(content=augmented_prompt)
242
- messages.append(msg)
243
- response = chat_model.invoke(messages)
244
- messages.append(AIMessage(content=response.content))
245
 
246
- if len(messages) >= 8:
247
- messages = messages[-8:]
248
 
249
  history[-1][1] = ""
250
  for character in response.content:
@@ -266,13 +266,13 @@ def Chart_Generator(history):
266
  message_with_description = f"Describe and analyse the content of this chart: {chart_url}"
267
 
268
  prompt = HumanMessage(content=message_with_description)
269
- messages.append(prompt)
270
 
271
- response = chat_model.invoke(messages)
272
- messages.append(AIMessage(content=response.content))
273
 
274
- if len(messages) >= 8:
275
- messages = messages[-8:]
276
 
277
  combined_content = f'{image_html}<br>{response.content}'
278
  else:
@@ -280,13 +280,13 @@ def Chart_Generator(history):
280
  combined_content = response_text
281
  else:
282
  prompt = HumanMessage(content=message)
283
- messages.append(prompt)
284
 
285
- response = chat_model.invoke(messages)
286
- messages.append(AIMessage(content=response.content))
287
 
288
- if len(messages) >= 8:
289
- messages = messages[-8:]
290
 
291
  combined_content=response.content
292
 
@@ -327,12 +327,12 @@ def Link_Scratch(history):
327
  {content_data}
328
  """
329
  message = HumanMessage(content=augmented_prompt)
330
- messages.append(message)
331
- response = chat_model.invoke(messages)
332
- messages.append(AIMessage(content=response.content))
333
 
334
- if len(messages) >= 1:
335
- messages = messages[-1:]
336
 
337
  response_message = response.content
338
 
@@ -383,12 +383,12 @@ def File_Interact(history,filepath):
383
  {content_data}
384
  """
385
  message = HumanMessage(content=augmented_prompt)
386
- messages.append(message)
387
- response = chat_model.invoke(messages)
388
- messages.append(AIMessage(content=response.content))
389
 
390
- if len(messages) >= 1:
391
- messages = messages[-1:]
392
 
393
  response_message = response.content
394
 
 
206
  global messages1
207
 
208
  message=HumanMessage(content=history[-1][0])
209
+ messages1.append(message)
210
+ response = chat_model.invoke(messages1)
211
+ messages1.append(AIMessage(content=response.content))
212
 
213
+ if len(messages1) >= 8:
214
+ messages1 = messages1[-8:]
215
 
216
  history[-1][1] = ""
217
  for character in response.content:
 
239
  """
240
 
241
  msg=HumanMessage(content=augmented_prompt)
242
+ messages2.append(msg)
243
+ response = chat_model.invoke(messages2)
244
+ messages2.append(AIMessage(content=response.content))
245
 
246
+ if len(messages2) >= 8:
247
+ messages2 = messages2[-8:]
248
 
249
  history[-1][1] = ""
250
  for character in response.content:
 
266
  message_with_description = f"Describe and analyse the content of this chart: {chart_url}"
267
 
268
  prompt = HumanMessage(content=message_with_description)
269
+ messages3.append(prompt)
270
 
271
+ response = chat_model.invoke(messages3)
272
+ messages3.append(AIMessage(content=response.content))
273
 
274
+ if len(messages3) >= 8:
275
+ messages3 = messages3[-8:]
276
 
277
  combined_content = f'{image_html}<br>{response.content}'
278
  else:
 
280
  combined_content = response_text
281
  else:
282
  prompt = HumanMessage(content=message)
283
+ messages3.append(prompt)
284
 
285
+ response = chat_model.invoke(messages3)
286
+ messages3.append(AIMessage(content=response.content))
287
 
288
+ if len(messages3) >= 8:
289
+ messages3 = messages3[-8:]
290
 
291
  combined_content=response.content
292
 
 
327
  {content_data}
328
  """
329
  message = HumanMessage(content=augmented_prompt)
330
+ messages4.append(message)
331
+ response = chat_model.invoke(messages4)
332
+ messages4.append(AIMessage(content=response.content))
333
 
334
+ if len(messages4) >= 1:
335
+ messages4 = messages4[-1:]
336
 
337
  response_message = response.content
338
 
 
383
  {content_data}
384
  """
385
  message = HumanMessage(content=augmented_prompt)
386
+ messages5.append(message)
387
+ response = chat_model.invoke(messages5)
388
+ messages5.append(AIMessage(content=response.content))
389
 
390
+ if len(messages5) >= 1:
391
+ messages5 = messages5[-1:]
392
 
393
  response_message = response.content
394