OuroborosM commited on
Commit
267deca
·
1 Parent(s): 0d6e48c

update chatbothistory

Browse files
Files changed (1) hide show
  1. app.py +48 -32
app.py CHANGED
@@ -99,7 +99,21 @@ CurrentAgent = os.environ["agent_type"]
99
 
100
  global ChatbotHistory
101
  ChatbotHistory = []
102
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  class CodeBlock:
105
  '''
@@ -1387,18 +1401,19 @@ def chathmi3(message, history2):
1387
  global last_request
1388
  global Filename_Chatbot
1389
  global agent
 
1390
  print("Input Message:", message)
1391
  last_request = message
1392
- history2 = history2 + [(message, None)]
1393
- yield ["", history2]
1394
  try:
1395
  if agent is not None:
1396
  response = agent.run(message)
1397
  elif agent is None:
1398
  response = asyncio.run(start_playwright(message))
1399
  time.sleep(0.1)
1400
- history2 = history2 + [(None, response)]
1401
- yield ["", history2]
1402
  print ("response of chatbot:", response)
1403
  # real_content = response[-1:]
1404
  # print("real_content", real_content)
@@ -1409,9 +1424,9 @@ def chathmi3(message, history2):
1409
  if file_names != []:
1410
  for file_name in file_names:
1411
  if file_name != "":
1412
- history2 = history2 + [(None, (file_name, file_name))]
1413
  Filename_Chatbot = file_name
1414
- yield ["", history2]
1415
  else:
1416
  print("No File Found in Response")
1417
  except Exception as e:
@@ -1422,7 +1437,7 @@ def chathmi3(message, history2):
1422
 
1423
  # history = history + [(message, None)]
1424
 
1425
- print("History2: ", history2)
1426
  print("-" * 20)
1427
  print("-" * 20)
1428
 
@@ -1470,11 +1485,12 @@ def chathmi4(message, history2):
1470
  global last_request
1471
  global Filename_Chatbot
1472
  global agent
 
1473
  print("Input Message:", message)
1474
 
1475
  last_request = message
1476
- history2 = history2 + [(message, None)]
1477
- yield ["", history2, gr.update(visible = False), gr.update(visible = True)]
1478
  # yield ["", history2, "SUBMIT", "STOP"]
1479
  try:
1480
  if agent is not None:
@@ -1483,8 +1499,8 @@ def chathmi4(message, history2):
1483
  response = asyncio.run(start_playwright(message))
1484
 
1485
  time.sleep(0.1)
1486
- history2 = history2 + [(None, response)]
1487
- yield ["", history2, gr.update(visible = True), gr.update(visible = False)]
1488
  # yield ["", history2, None, None]
1489
  print ("response of chatbot:", response)
1490
  # real_content = response[-1:]
@@ -1507,9 +1523,9 @@ def chathmi4(message, history2):
1507
  if file_names != []:
1508
  for file_name in file_names:
1509
  if file_name != "":
1510
- history2 = history2 + [(None, (file_name, file_name))]
1511
  Filename_Chatbot = file_name
1512
- yield ["", history2, "SUBMIT", "STOP"]
1513
  else:
1514
  print("No File Found in Response")
1515
  except Exception as e:
@@ -1522,7 +1538,7 @@ def chathmi4(message, history2):
1522
 
1523
  # history = history + [(message, None)]
1524
 
1525
- print("History2: ", history2)
1526
  print("-" * 20)
1527
  print("-" * 20)
1528
 
@@ -1717,23 +1733,23 @@ def Text2Sound_HMI():
1717
 
1718
  def UpdateChatbot(Running_history):
1719
  global ChatbotHistory
1720
- timestr = time.strftime("%Y-%m-%d-%H:%M:%S")
1721
- # Running_history = Running_history + [(None, 'Timestamp: '+timestr)]
1722
- # yield Running_history
1723
- WelcomeStr = """
1724
- This is AI Assistant powered by MECH Core Team.
1725
- It is connected remotely with GPT4. The following function is available for you.
1726
- 1. Free Chat with AI assistant
1727
- 2. Search Information and Engineering Data: Vector Database + Internet
1728
- 3. Make specific task with tools:
1729
- - Text to Sound
1730
- - Sound to Text
1731
- - Doc summary
1732
- - Code interpret (Beta version)
1733
- - Text to Image (forecast)
1734
- """
1735
- # Running_history = Running_history + [(None, timestr+'\n'+WelcomeStr)]
1736
- ChatbotHistory = ChatbotHistory + [(None, timestr+'\n'+WelcomeStr)]
1737
  yield ChatbotHistory
1738
 
1739
  global last_answer
 
99
 
100
  global ChatbotHistory
101
  ChatbotHistory = []
102
+ timestr = time.strftime("%Y-%m-%d-%H:%M:%S")
103
+ # Running_history = Running_history + [(None, 'Timestamp: '+timestr)]
104
+ # yield Running_history
105
+ WelcomeStr = """
106
+ This is AI Assistant powered by MECH Core Team.
107
+ It is connected remotely with GPT4. The following function is available for you.
108
+ 1. Free Chat with AI assistant
109
+ 2. Search Information and Engineering Data: Vector Database + Internet
110
+ 3. Make specific task with tools:
111
+ - Text to Sound | Sound to Text | Doc summary
112
+ - Code interpret (Beta version)
113
+ - Text to Image (forecast)
114
+ """
115
+ # Running_history = Running_history + [(None, timestr+'\n'+WelcomeStr)]
116
+ ChatbotHistory = ChatbotHistory + [(None, timestr+'\n'+WelcomeStr)]
117
 
118
  class CodeBlock:
119
  '''
 
1401
  global last_request
1402
  global Filename_Chatbot
1403
  global agent
1404
+ global ChatbotHistory
1405
  print("Input Message:", message)
1406
  last_request = message
1407
+ ChatbotHistory = ChatbotHistory + [(message, None)]
1408
+ yield ["", ChatbotHistory]
1409
  try:
1410
  if agent is not None:
1411
  response = agent.run(message)
1412
  elif agent is None:
1413
  response = asyncio.run(start_playwright(message))
1414
  time.sleep(0.1)
1415
+ ChatbotHistory = ChatbotHistory + [(None, response)]
1416
+ yield ["", ChatbotHistory]
1417
  print ("response of chatbot:", response)
1418
  # real_content = response[-1:]
1419
  # print("real_content", real_content)
 
1424
  if file_names != []:
1425
  for file_name in file_names:
1426
  if file_name != "":
1427
+ ChatbotHistory = ChatbotHistory + [(None, (file_name, file_name))]
1428
  Filename_Chatbot = file_name
1429
+ yield ["", ChatbotHistory]
1430
  else:
1431
  print("No File Found in Response")
1432
  except Exception as e:
 
1437
 
1438
  # history = history + [(message, None)]
1439
 
1440
+ print("History2 in chathmi3: ", ChatbotHistory)
1441
  print("-" * 20)
1442
  print("-" * 20)
1443
 
 
1485
  global last_request
1486
  global Filename_Chatbot
1487
  global agent
1488
+ global ChatbotHistory
1489
  print("Input Message:", message)
1490
 
1491
  last_request = message
1492
+ ChatbotHistory = ChatbotHistory + [(message, None)]
1493
+ yield ["", ChatbotHistory, gr.update(visible = False), gr.update(visible = True)]
1494
  # yield ["", history2, "SUBMIT", "STOP"]
1495
  try:
1496
  if agent is not None:
 
1499
  response = asyncio.run(start_playwright(message))
1500
 
1501
  time.sleep(0.1)
1502
+ ChatbotHistory = ChatbotHistory + [(None, response)]
1503
+ yield ["", ChatbotHistory, gr.update(visible = True), gr.update(visible = False)]
1504
  # yield ["", history2, None, None]
1505
  print ("response of chatbot:", response)
1506
  # real_content = response[-1:]
 
1523
  if file_names != []:
1524
  for file_name in file_names:
1525
  if file_name != "":
1526
+ ChatbotHistory = ChatbotHistory + [(None, (file_name, file_name))]
1527
  Filename_Chatbot = file_name
1528
+ yield ["", ChatbotHistory, "SUBMIT", "STOP"]
1529
  else:
1530
  print("No File Found in Response")
1531
  except Exception as e:
 
1538
 
1539
  # history = history + [(message, None)]
1540
 
1541
+ print("History2: ", ChatbotHistory)
1542
  print("-" * 20)
1543
  print("-" * 20)
1544
 
 
1733
 
1734
  def UpdateChatbot(Running_history):
1735
  global ChatbotHistory
1736
+ # timestr = time.strftime("%Y-%m-%d-%H:%M:%S")
1737
+ # # Running_history = Running_history + [(None, 'Timestamp: '+timestr)]
1738
+ # # yield Running_history
1739
+ # WelcomeStr = """
1740
+ # This is AI Assistant powered by MECH Core Team.
1741
+ # It is connected remotely with GPT4. The following function is available for you.
1742
+ # 1. Free Chat with AI assistant
1743
+ # 2. Search Information and Engineering Data: Vector Database + Internet
1744
+ # 3. Make specific task with tools:
1745
+ # - Text to Sound
1746
+ # - Sound to Text
1747
+ # - Doc summary
1748
+ # - Code interpret (Beta version)
1749
+ # - Text to Image (forecast)
1750
+ # """
1751
+ # # Running_history = Running_history + [(None, timestr+'\n'+WelcomeStr)]
1752
+ # ChatbotHistory = ChatbotHistory + [(None, timestr+'\n'+WelcomeStr)]
1753
  yield ChatbotHistory
1754
 
1755
  global last_answer