Spaces:
Runtime error
Runtime error
Commit
·
e81a698
1
Parent(s):
f992d3d
correct var name
Browse files
app.py
CHANGED
|
@@ -516,12 +516,12 @@ vectordb_p = Pinecone.from_existing_index(index_name, embeddings)
|
|
| 516 |
# vectordb.similarity_search(question)
|
| 517 |
# print(type(rr))
|
| 518 |
# print(rr)
|
| 519 |
-
def chathmi(message,
|
| 520 |
# response = "I don't know"
|
| 521 |
# print(message)
|
| 522 |
response, source = QAQuery_p(message)
|
| 523 |
time.sleep(0.3)
|
| 524 |
-
print(
|
| 525 |
yield response
|
| 526 |
# yield history
|
| 527 |
|
|
@@ -561,7 +561,7 @@ def chathmi2(message, history):
|
|
| 561 |
# chatbot = gr.Chatbot().style(color_map =("blue", "pink"))
|
| 562 |
# chatbot = gr.Chatbot(color_map =("blue", "pink"))
|
| 563 |
|
| 564 |
-
def func_upload_file(files,
|
| 565 |
global file_list_loaded
|
| 566 |
file_list_loaded = []
|
| 567 |
for unit in files:
|
|
@@ -573,13 +573,13 @@ def func_upload_file(files, chat_history):
|
|
| 573 |
|
| 574 |
# chat_history.append(test_msg)
|
| 575 |
for file in files:
|
| 576 |
-
|
| 577 |
-
yield
|
| 578 |
if os.getenv("SYS_Upload_Enable") == "1":
|
| 579 |
UpdateDb()
|
| 580 |
test_msg = ["Request Upload File into DB", "Operation Finished"]
|
| 581 |
-
|
| 582 |
-
yield
|
| 583 |
|
| 584 |
class Logger:
|
| 585 |
def __init__(self, filename):
|
|
@@ -634,17 +634,17 @@ def LinkElement(chatbot_history):
|
|
| 634 |
print("From linkelement: ", chatbot_history)
|
| 635 |
pass
|
| 636 |
|
| 637 |
-
def chathmi3(message,
|
| 638 |
global last_request
|
| 639 |
print("Input Message:", message)
|
| 640 |
last_request = message
|
| 641 |
-
|
| 642 |
-
yield ["",
|
| 643 |
try:
|
| 644 |
response = agent.run(message)
|
| 645 |
time.sleep(0.1)
|
| 646 |
-
|
| 647 |
-
yield ["",
|
| 648 |
print ("response of chatbot:", response)
|
| 649 |
# real_content = response[-1:]
|
| 650 |
# print("real_content", real_content)
|
|
@@ -652,8 +652,8 @@ def chathmi3(message, history):
|
|
| 652 |
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 653 |
file_name = temp.split(")")[0]
|
| 654 |
print("file_name:", file_name)
|
| 655 |
-
|
| 656 |
-
yield ["",
|
| 657 |
except:
|
| 658 |
print("No need to add file in chatbot")
|
| 659 |
|
|
@@ -662,11 +662,11 @@ def chathmi3(message, history):
|
|
| 662 |
|
| 663 |
# history = history + [(message, None)]
|
| 664 |
|
| 665 |
-
print("
|
| 666 |
print("-" * 20)
|
| 667 |
print("-" * 20)
|
| 668 |
|
| 669 |
-
def fake(message,
|
| 670 |
pass
|
| 671 |
|
| 672 |
|
|
@@ -677,19 +677,19 @@ def clearall():
|
|
| 677 |
memory.clear()
|
| 678 |
return []
|
| 679 |
|
| 680 |
-
def retry(
|
| 681 |
global last_request
|
| 682 |
print("last_request", last_request)
|
| 683 |
message = last_request
|
| 684 |
-
|
| 685 |
-
yield
|
| 686 |
|
| 687 |
try:
|
| 688 |
response = agent.run(message)
|
| 689 |
time.sleep(0.1)
|
| 690 |
-
|
| 691 |
print ("response of chatbot:", response)
|
| 692 |
-
yield
|
| 693 |
|
| 694 |
# real_content = response[-1:]
|
| 695 |
# print("real_content", real_content)
|
|
@@ -697,8 +697,8 @@ def retry(history):
|
|
| 697 |
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 698 |
file_name = temp.split(")")[0]
|
| 699 |
print("file_name:", file_name)
|
| 700 |
-
|
| 701 |
-
yield
|
| 702 |
except:
|
| 703 |
print("No need to add file in chatbot")
|
| 704 |
|
|
|
|
| 516 |
# vectordb.similarity_search(question)
|
| 517 |
# print(type(rr))
|
| 518 |
# print(rr)
|
| 519 |
+
def chathmi(message, history1):
|
| 520 |
# response = "I don't know"
|
| 521 |
# print(message)
|
| 522 |
response, source = QAQuery_p(message)
|
| 523 |
time.sleep(0.3)
|
| 524 |
+
print(history1)
|
| 525 |
yield response
|
| 526 |
# yield history
|
| 527 |
|
|
|
|
| 561 |
# chatbot = gr.Chatbot().style(color_map =("blue", "pink"))
|
| 562 |
# chatbot = gr.Chatbot(color_map =("blue", "pink"))
|
| 563 |
|
| 564 |
+
def func_upload_file(files, chat_history2):
|
| 565 |
global file_list_loaded
|
| 566 |
file_list_loaded = []
|
| 567 |
for unit in files:
|
|
|
|
| 573 |
|
| 574 |
# chat_history.append(test_msg)
|
| 575 |
for file in files:
|
| 576 |
+
chat_history2 = chat_history2 + [((file.name,), None)]
|
| 577 |
+
yield chat_history2
|
| 578 |
if os.getenv("SYS_Upload_Enable") == "1":
|
| 579 |
UpdateDb()
|
| 580 |
test_msg = ["Request Upload File into DB", "Operation Finished"]
|
| 581 |
+
chat_history2.append(test_msg)
|
| 582 |
+
yield chat_history2
|
| 583 |
|
| 584 |
class Logger:
|
| 585 |
def __init__(self, filename):
|
|
|
|
| 634 |
print("From linkelement: ", chatbot_history)
|
| 635 |
pass
|
| 636 |
|
| 637 |
+
def chathmi3(message, history2):
|
| 638 |
global last_request
|
| 639 |
print("Input Message:", message)
|
| 640 |
last_request = message
|
| 641 |
+
history2 = history2 + [(message, None)]
|
| 642 |
+
yield ["", history2]
|
| 643 |
try:
|
| 644 |
response = agent.run(message)
|
| 645 |
time.sleep(0.1)
|
| 646 |
+
history2 = history2 + [(None, response)]
|
| 647 |
+
yield ["", history2]
|
| 648 |
print ("response of chatbot:", response)
|
| 649 |
# real_content = response[-1:]
|
| 650 |
# print("real_content", real_content)
|
|
|
|
| 652 |
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 653 |
file_name = temp.split(")")[0]
|
| 654 |
print("file_name:", file_name)
|
| 655 |
+
history2 = history2 + [(None, (file_name,))]
|
| 656 |
+
yield ["", history2]
|
| 657 |
except:
|
| 658 |
print("No need to add file in chatbot")
|
| 659 |
|
|
|
|
| 662 |
|
| 663 |
# history = history + [(message, None)]
|
| 664 |
|
| 665 |
+
print("History2: ", history2)
|
| 666 |
print("-" * 20)
|
| 667 |
print("-" * 20)
|
| 668 |
|
| 669 |
+
def fake(message, history4):
|
| 670 |
pass
|
| 671 |
|
| 672 |
|
|
|
|
| 677 |
memory.clear()
|
| 678 |
return []
|
| 679 |
|
| 680 |
+
def retry(history3):
|
| 681 |
global last_request
|
| 682 |
print("last_request", last_request)
|
| 683 |
message = last_request
|
| 684 |
+
history3 = history3 + [(message, None)]
|
| 685 |
+
yield history3
|
| 686 |
|
| 687 |
try:
|
| 688 |
response = agent.run(message)
|
| 689 |
time.sleep(0.1)
|
| 690 |
+
history3 = history3 + [(None, response)]
|
| 691 |
print ("response of chatbot:", response)
|
| 692 |
+
yield history3
|
| 693 |
|
| 694 |
# real_content = response[-1:]
|
| 695 |
# print("real_content", real_content)
|
|
|
|
| 697 |
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 698 |
file_name = temp.split(")")[0]
|
| 699 |
print("file_name:", file_name)
|
| 700 |
+
history3 = history3 + [(None, (file_name,))]
|
| 701 |
+
yield history3
|
| 702 |
except:
|
| 703 |
print("No need to add file in chatbot")
|
| 704 |
|