Spaces:
Runtime error
Runtime error
Commit
·
1357aec
1
Parent(s):
b4e8d18
update direct pass type
Browse files
app.py
CHANGED
|
@@ -745,25 +745,30 @@ agent_OPENAI_MULTI = AgentExecutor.from_agent_and_tools(
|
|
| 745 |
# agent.handle_parsing_errors = True
|
| 746 |
# agent.early_stopping_method = "generate"
|
| 747 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 748 |
global agent
|
| 749 |
Choice = os.environ["agent_type"]
|
| 750 |
-
|
| 751 |
-
if Choice =='Zero Short Agent':
|
| 752 |
-
agent = agent_ZEROSHOT_AGENT
|
| 753 |
-
print("Set to:", Choice)
|
| 754 |
-
elif Choice =='Zero Short React':
|
| 755 |
-
agent = agent_ZEROSHOT_REACT
|
| 756 |
-
print("Set to:", Choice)
|
| 757 |
-
elif Choice =='OpenAI Multi':
|
| 758 |
-
agent = agent_OPENAI_MULTI
|
| 759 |
-
print("Set to:", Choice)
|
| 760 |
-
elif Choice =='Zero Short React 2':
|
| 761 |
-
agent = agent_ZEROSHOT_REACT_2
|
| 762 |
-
print("Set to:", Choice)
|
| 763 |
-
elif Choice =='Zero Short Agent 2':
|
| 764 |
-
agent = agent_ZEROSHOT_AGENT_2
|
| 765 |
-
print("Set to:", Choice)
|
| 766 |
-
|
| 767 |
|
| 768 |
|
| 769 |
# agent = agent_ZEROSHOT_AGENT
|
|
@@ -902,23 +907,8 @@ def read_logs():
|
|
| 902 |
with open("output.log", "r") as f:
|
| 903 |
return f.read()
|
| 904 |
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
if Choice =='Zero Short Agent':
|
| 908 |
-
agent = agent_ZEROSHOT_AGENT
|
| 909 |
-
print("Set to:", Choice)
|
| 910 |
-
elif Choice =='Zero Short React':
|
| 911 |
-
agent = agent_ZEROSHOT_REACT
|
| 912 |
-
print("Set to:", Choice)
|
| 913 |
-
elif Choice =='OpenAI Multi':
|
| 914 |
-
agent = agent_OPENAI_MULTI
|
| 915 |
-
print("Set to:", Choice)
|
| 916 |
-
elif Choice =='Zero Short React 2':
|
| 917 |
-
agent = agent_ZEROSHOT_REACT_2
|
| 918 |
-
print("Set to:", Choice)
|
| 919 |
-
elif Choice =='Zero Short Agent 2':
|
| 920 |
-
agent = agent_ZEROSHOT_AGENT_2
|
| 921 |
-
print("Set to:", Choice)
|
| 922 |
|
| 923 |
global record
|
| 924 |
record = []
|
|
@@ -941,12 +931,16 @@ def LinkElement(chatbot_history):
|
|
| 941 |
def chathmi3(message, history2):
|
| 942 |
global last_request
|
| 943 |
global Filename_Chatbot
|
|
|
|
| 944 |
print("Input Message:", message)
|
| 945 |
last_request = message
|
| 946 |
history2 = history2 + [(message, None)]
|
| 947 |
yield ["", history2]
|
| 948 |
try:
|
| 949 |
-
|
|
|
|
|
|
|
|
|
|
| 950 |
time.sleep(0.1)
|
| 951 |
history2 = history2 + [(None, response)]
|
| 952 |
yield ["", history2]
|
|
@@ -975,13 +969,19 @@ def chathmi3(message, history2):
|
|
| 975 |
def chathmi4(message, history2):
|
| 976 |
global last_request
|
| 977 |
global Filename_Chatbot
|
|
|
|
| 978 |
print("Input Message:", message)
|
|
|
|
| 979 |
last_request = message
|
| 980 |
history2 = history2 + [(message, None)]
|
| 981 |
yield ["", history2, gr.update(visible = False), gr.update(visible = True)]
|
| 982 |
# yield ["", history2, "SUBMIT", "STOP"]
|
| 983 |
try:
|
| 984 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 985 |
time.sleep(0.1)
|
| 986 |
history2 = history2 + [(None, response)]
|
| 987 |
yield ["", history2, gr.update(visible = True), gr.update(visible = False)]
|
|
@@ -994,8 +994,8 @@ def chathmi4(message, history2):
|
|
| 994 |
file_name = temp.split(")")[0]
|
| 995 |
print("file_name:", file_name)
|
| 996 |
history2 = history2 + [(None, (file_name,))]
|
| 997 |
-
Filename_Chatbot = file_name
|
| 998 |
-
yield ["", history2, "SUBMIT", "STOP"]
|
| 999 |
except:
|
| 1000 |
print("No need to add file in chatbot")
|
| 1001 |
|
|
@@ -1003,7 +1003,7 @@ def chathmi4(message, history2):
|
|
| 1003 |
print("chathmi4 error:", e)
|
| 1004 |
|
| 1005 |
# history = history + [(message, None)]
|
| 1006 |
-
|
| 1007 |
print("History2: ", history2)
|
| 1008 |
print("-" * 20)
|
| 1009 |
print("-" * 20)
|
|
@@ -1239,7 +1239,7 @@ with gr.Blocks() as demo:
|
|
| 1239 |
with gr.Row():
|
| 1240 |
|
| 1241 |
agentchoice = gr.Dropdown(
|
| 1242 |
-
choices=['Zero Short Agent','Zero Short React','OpenAI Multi','Zero Short React 2','Zero Short Agent 2'],
|
| 1243 |
label="SELECT AI AGENT",
|
| 1244 |
scale= 2,
|
| 1245 |
show_label = True,
|
|
|
|
| 745 |
# agent.handle_parsing_errors = True
|
| 746 |
# agent.early_stopping_method = "generate"
|
| 747 |
|
| 748 |
+
def SetAgent(Choice):
|
| 749 |
+
global agent
|
| 750 |
+
if Choice =='Zero Short Agent':
|
| 751 |
+
agent = agent_ZEROSHOT_AGENT
|
| 752 |
+
print("Set to:", Choice)
|
| 753 |
+
elif Choice =='Zero Short React':
|
| 754 |
+
agent = agent_ZEROSHOT_REACT
|
| 755 |
+
print("Set to:", Choice)
|
| 756 |
+
elif Choice =='OpenAI Multi':
|
| 757 |
+
agent = agent_OPENAI_MULTI
|
| 758 |
+
print("Set to:", Choice)
|
| 759 |
+
elif Choice =='Zero Short React 2':
|
| 760 |
+
agent = agent_ZEROSHOT_REACT_2
|
| 761 |
+
print("Set to:", Choice)
|
| 762 |
+
elif Choice =='Zero Short Agent 2':
|
| 763 |
+
agent = agent_ZEROSHOT_AGENT_2
|
| 764 |
+
print("Set to:", Choice)
|
| 765 |
+
elif Choice == "None":
|
| 766 |
+
agent = None
|
| 767 |
+
print("Set to:", Choice)
|
| 768 |
+
|
| 769 |
global agent
|
| 770 |
Choice = os.environ["agent_type"]
|
| 771 |
+
SetAgent(Choice)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 772 |
|
| 773 |
|
| 774 |
# agent = agent_ZEROSHOT_AGENT
|
|
|
|
| 907 |
with open("output.log", "r") as f:
|
| 908 |
return f.read()
|
| 909 |
|
| 910 |
+
|
| 911 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 912 |
|
| 913 |
global record
|
| 914 |
record = []
|
|
|
|
| 931 |
def chathmi3(message, history2):
|
| 932 |
global last_request
|
| 933 |
global Filename_Chatbot
|
| 934 |
+
global agent
|
| 935 |
print("Input Message:", message)
|
| 936 |
last_request = message
|
| 937 |
history2 = history2 + [(message, None)]
|
| 938 |
yield ["", history2]
|
| 939 |
try:
|
| 940 |
+
if agent is not None:
|
| 941 |
+
response = agent.run(message)
|
| 942 |
+
elif agent is None:
|
| 943 |
+
response = asyncio.run(start_playwright(message))
|
| 944 |
time.sleep(0.1)
|
| 945 |
history2 = history2 + [(None, response)]
|
| 946 |
yield ["", history2]
|
|
|
|
| 969 |
def chathmi4(message, history2):
|
| 970 |
global last_request
|
| 971 |
global Filename_Chatbot
|
| 972 |
+
global agent
|
| 973 |
print("Input Message:", message)
|
| 974 |
+
|
| 975 |
last_request = message
|
| 976 |
history2 = history2 + [(message, None)]
|
| 977 |
yield ["", history2, gr.update(visible = False), gr.update(visible = True)]
|
| 978 |
# yield ["", history2, "SUBMIT", "STOP"]
|
| 979 |
try:
|
| 980 |
+
if agent is not None:
|
| 981 |
+
response = agent.run(message)
|
| 982 |
+
elif agent is None:
|
| 983 |
+
response = asyncio.run(start_playwright(message))
|
| 984 |
+
|
| 985 |
time.sleep(0.1)
|
| 986 |
history2 = history2 + [(None, response)]
|
| 987 |
yield ["", history2, gr.update(visible = True), gr.update(visible = False)]
|
|
|
|
| 994 |
file_name = temp.split(")")[0]
|
| 995 |
print("file_name:", file_name)
|
| 996 |
history2 = history2 + [(None, (file_name,))]
|
| 997 |
+
Filename_Chatbot = file_name
|
| 998 |
+
yield ["", history2, "SUBMIT", "STOP"]
|
| 999 |
except:
|
| 1000 |
print("No need to add file in chatbot")
|
| 1001 |
|
|
|
|
| 1003 |
print("chathmi4 error:", e)
|
| 1004 |
|
| 1005 |
# history = history + [(message, None)]
|
| 1006 |
+
|
| 1007 |
print("History2: ", history2)
|
| 1008 |
print("-" * 20)
|
| 1009 |
print("-" * 20)
|
|
|
|
| 1239 |
with gr.Row():
|
| 1240 |
|
| 1241 |
agentchoice = gr.Dropdown(
|
| 1242 |
+
choices=['Zero Short Agent','Zero Short React','OpenAI Multi','Zero Short React 2','Zero Short Agent 2','None'],
|
| 1243 |
label="SELECT AI AGENT",
|
| 1244 |
scale= 2,
|
| 1245 |
show_label = True,
|