Spaces:
Runtime error
Runtime error
Commit
·
f19ad30
1
Parent(s):
dd099e7
remove global history
Browse files
app.py
CHANGED
@@ -1401,19 +1401,19 @@ def chathmi3(message, history2):
|
|
1401 |
global last_request
|
1402 |
global Filename_Chatbot
|
1403 |
global agent
|
1404 |
-
global ChatbotHistory
|
1405 |
print("Input Message:", message)
|
1406 |
last_request = message
|
1407 |
-
|
1408 |
-
yield ["",
|
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 |
-
|
1416 |
-
yield ["",
|
1417 |
print ("response of chatbot:", response)
|
1418 |
# real_content = response[-1:]
|
1419 |
# print("real_content", real_content)
|
@@ -1424,9 +1424,9 @@ def chathmi3(message, history2):
|
|
1424 |
if file_names != []:
|
1425 |
for file_name in file_names:
|
1426 |
if file_name != "":
|
1427 |
-
|
1428 |
Filename_Chatbot = file_name
|
1429 |
-
yield ["",
|
1430 |
else:
|
1431 |
print("No File Found in Response")
|
1432 |
except Exception as e:
|
@@ -1437,7 +1437,7 @@ def chathmi3(message, history2):
|
|
1437 |
|
1438 |
# history = history + [(message, None)]
|
1439 |
|
1440 |
-
print("History2 in chathmi3: ",
|
1441 |
print("-" * 20)
|
1442 |
print("-" * 20)
|
1443 |
|
@@ -1485,12 +1485,12 @@ def chathmi4(message, history2):
|
|
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 |
-
|
1493 |
-
yield ["",
|
1494 |
# yield ["", history2, "SUBMIT", "STOP"]
|
1495 |
try:
|
1496 |
if agent is not None:
|
@@ -1499,8 +1499,8 @@ def chathmi4(message, history2):
|
|
1499 |
response = asyncio.run(start_playwright(message))
|
1500 |
|
1501 |
time.sleep(0.1)
|
1502 |
-
|
1503 |
-
yield ["",
|
1504 |
# yield ["", history2, None, None]
|
1505 |
print ("response of chatbot:", response)
|
1506 |
# real_content = response[-1:]
|
@@ -1523,9 +1523,9 @@ def chathmi4(message, history2):
|
|
1523 |
if file_names != []:
|
1524 |
for file_name in file_names:
|
1525 |
if file_name != "":
|
1526 |
-
|
1527 |
Filename_Chatbot = file_name
|
1528 |
-
yield ["",
|
1529 |
else:
|
1530 |
print("No File Found in Response")
|
1531 |
except Exception as e:
|
@@ -1538,7 +1538,7 @@ def chathmi4(message, history2):
|
|
1538 |
|
1539 |
# history = history + [(message, None)]
|
1540 |
|
1541 |
-
print("History2: ",
|
1542 |
print("-" * 20)
|
1543 |
print("-" * 20)
|
1544 |
|
@@ -1754,6 +1754,9 @@ def UpdateChatbot(Running_history):
|
|
1754 |
yield [Running_history, Running_history]
|
1755 |
|
1756 |
def UpdateChatbot2(Running_history):
|
|
|
|
|
|
|
1757 |
global ChatbotHistory
|
1758 |
timestr = time.strftime("%Y-%m-%d-%H:%M:%S")
|
1759 |
# Running_history = Running_history + [(None, 'Timestamp: '+timestr)]
|
@@ -1963,7 +1966,7 @@ with gr.Blocks() as demo:
|
|
1963 |
# voice_output.play(clear_voice, None, None)
|
1964 |
|
1965 |
# demo.load(read_logs, None, logs, every=1)
|
1966 |
-
demo.load(UpdateChatbot, UserRecord, [chatbot, UserRecord]
|
1967 |
# load(UpdateChatbot, chatbot, chatbot, every=5)
|
1968 |
|
1969 |
# demo(api_name="Update_Chatbot")
|
|
|
1401 |
global last_request
|
1402 |
global Filename_Chatbot
|
1403 |
global agent
|
1404 |
+
# global ChatbotHistory
|
1405 |
print("Input Message:", message)
|
1406 |
last_request = message
|
1407 |
+
history2 = history2 + [(message, None)]
|
1408 |
+
yield ["", history2]
|
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 |
+
history2 = history2 + [(None, response)]
|
1416 |
+
yield ["", history2]
|
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 |
+
history2 = history2 + [(None, (file_name, file_name))]
|
1428 |
Filename_Chatbot = file_name
|
1429 |
+
yield ["", history2]
|
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: ", history2)
|
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 |
+
history2 = history2 + [(message, None)]
|
1493 |
+
yield ["", history2, 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 |
+
history2 = history2 + [(None, response)]
|
1503 |
+
yield ["", history2, 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 |
+
history2 = history2 + [(None, (file_name, file_name))]
|
1527 |
Filename_Chatbot = file_name
|
1528 |
+
yield ["", history2, "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: ", history2)
|
1542 |
print("-" * 20)
|
1543 |
print("-" * 20)
|
1544 |
|
|
|
1754 |
yield [Running_history, Running_history]
|
1755 |
|
1756 |
def UpdateChatbot2(Running_history):
|
1757 |
+
'''
|
1758 |
+
Not used
|
1759 |
+
'''
|
1760 |
global ChatbotHistory
|
1761 |
timestr = time.strftime("%Y-%m-%d-%H:%M:%S")
|
1762 |
# Running_history = Running_history + [(None, 'Timestamp: '+timestr)]
|
|
|
1966 |
# voice_output.play(clear_voice, None, None)
|
1967 |
|
1968 |
# demo.load(read_logs, None, logs, every=1)
|
1969 |
+
demo.load(UpdateChatbot, UserRecord, [chatbot, UserRecord])
|
1970 |
# load(UpdateChatbot, chatbot, chatbot, every=5)
|
1971 |
|
1972 |
# demo(api_name="Update_Chatbot")
|