Spaces:
Sleeping
Sleeping
Update pages/NeuralAgents.py
Browse files- pages/NeuralAgents.py +148 -19
pages/NeuralAgents.py
CHANGED
@@ -6,16 +6,17 @@ import asyncio
|
|
6 |
import time
|
7 |
import conteneiro
|
8 |
import streamlit as st
|
9 |
-
from
|
10 |
from agents import Llama2, Copilot, ChatGPT, Claude3, ForefrontAI, Flowise, Chaindesk, CharacterAI
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
|
14 |
-
servers =
|
15 |
-
clients =
|
16 |
inputs = []
|
17 |
outputs = []
|
18 |
used_ports = []
|
|
|
19 |
server_ports = []
|
20 |
client_ports = []
|
21 |
|
@@ -27,6 +28,10 @@ async def main():
|
|
27 |
st.session_state.cseID = ""
|
28 |
if "api_key" not in st.session_state:
|
29 |
st.session_state.api_key = ""
|
|
|
|
|
|
|
|
|
30 |
if "server_ports" not in st.session_state:
|
31 |
st.session_state['server_ports'] = ""
|
32 |
if "client_ports" not in st.session_state:
|
@@ -41,45 +46,169 @@ async def main():
|
|
41 |
st.session_state.server = False
|
42 |
if "client" not in st.session_state:
|
43 |
st.session_state.client = False
|
44 |
-
if "api_key" not in st.session_state:
|
45 |
-
st.session_state.api_key = ""
|
46 |
if "user_ID" not in st.session_state:
|
47 |
st.session_state.user_ID = ""
|
48 |
if "gradio_Port" not in st.session_state:
|
49 |
st.session_state.gradio_Port = ""
|
50 |
if "forefront_api" not in st.session_state:
|
51 |
-
st.session_state.forefront_api = ""
|
52 |
if "tokenChar" not in st.session_state:
|
53 |
-
st.session_state.tokenChar = ""
|
54 |
if "charName" not in st.session_state:
|
55 |
st.session_state.charName = ""
|
56 |
if "character_ID" not in st.session_state:
|
57 |
-
st.session_state.character_ID = ""
|
58 |
if "flow" not in st.session_state:
|
59 |
-
st.session_state.flow = ""
|
60 |
if "agentID" not in st.session_state:
|
61 |
-
st.session_state.agentID = ""
|
|
|
|
|
|
|
|
|
62 |
if "server_state" not in st.session_state:
|
63 |
st.session_state.server_state = "complete"
|
64 |
if "client_state" not in st.session_state:
|
65 |
st.session_state.client_state = "complete"
|
66 |
-
|
67 |
userInput = st.chat_input("Ask Agent")
|
68 |
|
69 |
with st.expander("Personal API tokens"):
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
c1, c2 = st.columns(2)
|
79 |
|
80 |
selectAgent = st.selectbox("Select agent", ("Llama2", "Copilot", "ChatGPT", "Forefront AI", "Claude-3", "Character.ai", "Chaindesk", "Flowise"))
|
81 |
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
with c1:
|
85 |
websocketPort = st.number_input("Websocket server port", min_value=1000, max_value=9999, value=1000)
|
|
|
6 |
import time
|
7 |
import conteneiro
|
8 |
import streamlit as st
|
9 |
+
from io import StringIO
|
10 |
from agents import Llama2, Copilot, ChatGPT, Claude3, ForefrontAI, Flowise, Chaindesk, CharacterAI
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
|
14 |
+
servers = []
|
15 |
+
clients = []
|
16 |
inputs = []
|
17 |
outputs = []
|
18 |
used_ports = []
|
19 |
+
credentials = []
|
20 |
server_ports = []
|
21 |
client_ports = []
|
22 |
|
|
|
28 |
st.session_state.cseID = ""
|
29 |
if "api_key" not in st.session_state:
|
30 |
st.session_state.api_key = ""
|
31 |
+
if "fireworks_api" not in st.session_state:
|
32 |
+
st.session_state.fireworks_api = ""
|
33 |
+
if "anthropicAPI" not in st.session_state:
|
34 |
+
st.session_state.anthropicAPI = ""
|
35 |
if "server_ports" not in st.session_state:
|
36 |
st.session_state['server_ports'] = ""
|
37 |
if "client_ports" not in st.session_state:
|
|
|
46 |
st.session_state.server = False
|
47 |
if "client" not in st.session_state:
|
48 |
st.session_state.client = False
|
|
|
|
|
49 |
if "user_ID" not in st.session_state:
|
50 |
st.session_state.user_ID = ""
|
51 |
if "gradio_Port" not in st.session_state:
|
52 |
st.session_state.gradio_Port = ""
|
53 |
if "forefront_api" not in st.session_state:
|
54 |
+
st.session_state.forefront_api = ""
|
55 |
if "tokenChar" not in st.session_state:
|
56 |
+
st.session_state.tokenChar = ""
|
57 |
if "charName" not in st.session_state:
|
58 |
st.session_state.charName = ""
|
59 |
if "character_ID" not in st.session_state:
|
60 |
+
st.session_state.character_ID = ""
|
61 |
if "flow" not in st.session_state:
|
62 |
+
st.session_state.flow = ""
|
63 |
if "agentID" not in st.session_state:
|
64 |
+
st.session_state.agentID = ""
|
65 |
+
if "tokens" not in st.session_state:
|
66 |
+
st.session_state.tokens = None
|
67 |
+
if 'credentials' not in st.session_state:
|
68 |
+
st.session_state.credentials = []
|
69 |
if "server_state" not in st.session_state:
|
70 |
st.session_state.server_state = "complete"
|
71 |
if "client_state" not in st.session_state:
|
72 |
st.session_state.client_state = "complete"
|
73 |
+
|
74 |
userInput = st.chat_input("Ask Agent")
|
75 |
|
76 |
with st.expander("Personal API tokens"):
|
77 |
+
d1, d2 = st.columns(2)
|
78 |
+
fire = st.empty()
|
79 |
+
fore = st.empty()
|
80 |
+
anthro = st.empty()
|
81 |
+
char = st.empty()
|
82 |
+
charID = st.empty()
|
83 |
+
chain = st.empty()
|
84 |
+
flo = st.empty()
|
85 |
+
|
86 |
+
if st.session_state.tokens == None:
|
87 |
+
fireworks_api = fire.text_input("Fireworks API")
|
88 |
+
forefront_api = fore.text_input("Forefront AI API")
|
89 |
+
anthropic_api = anthro.text_input("Anthropic API")
|
90 |
+
characterToken = char.text_input("Character.ai personal token")
|
91 |
+
character_ID = charID.text_input("Character ID")
|
92 |
+
chaindeskAgent = chain.text_input("Chaindesk agent ID")
|
93 |
+
flowID = flo.text_input("Flowise flow ID")
|
94 |
|
95 |
c1, c2 = st.columns(2)
|
96 |
|
97 |
selectAgent = st.selectbox("Select agent", ("Llama2", "Copilot", "ChatGPT", "Forefront AI", "Claude-3", "Character.ai", "Chaindesk", "Flowise"))
|
98 |
|
99 |
+
with d1:
|
100 |
+
|
101 |
+
uploadAPI = st.file_uploader(label="Upload credentials")
|
102 |
+
|
103 |
+
if uploadAPI is not None:
|
104 |
+
# Read the content of the file into a byte string
|
105 |
+
byte_content = uploadAPI.getvalue()
|
106 |
+
# Decode the byte string into a string
|
107 |
+
string_content = byte_content.decode('utf-8')
|
108 |
+
# Convert the string into a JSON object (list in this case)
|
109 |
+
tokens = json.loads(string_content)
|
110 |
+
st.session_state.tokens = tokens
|
111 |
+
print(tokens)
|
112 |
+
# Now you have a list of tokens, you can append them to credentials
|
113 |
+
credentials.clear()
|
114 |
+
credentials.extend(tokens)
|
115 |
+
|
116 |
+
if uploadAPI is not None:
|
117 |
+
|
118 |
+
data = json.load(uploadAPI)
|
119 |
+
print(data)
|
120 |
+
|
121 |
+
st.session_state.fireworks_api = data["APIfireworks"]
|
122 |
+
|
123 |
+
if st.session_state.fireworks_api == "":
|
124 |
+
fireworks_api = fire.text_input("Fireworks API key")
|
125 |
+
else:
|
126 |
+
fireworks_api = fire.container(border=True)
|
127 |
+
fireworks_api.write(st.session_state.fireworks_api)
|
128 |
+
|
129 |
+
st.session_state.forefront_api = data["APIforefront"]
|
130 |
+
|
131 |
+
if st.session_state.forefront_api == "":
|
132 |
+
forefront_api = fore.text_input("Forefront API key")
|
133 |
+
else:
|
134 |
+
forefront_api = fore.container(border=True)
|
135 |
+
forefront_api.write(st.session_state.forefront_api)
|
136 |
+
|
137 |
+
st.session_state.anthropicAPI = data["APIanthropic"]
|
138 |
+
|
139 |
+
if st.session_state.anthropicAPI == "":
|
140 |
+
anthropic_api = anthro.text_input("Anthropic API key")
|
141 |
+
else:
|
142 |
+
anthropic_api = anthro.container(border=True)
|
143 |
+
anthropic_api.write(st.session_state.anthropicAPI)
|
144 |
+
|
145 |
+
st.session_state.tokenChar = data["TokenCharacter"]
|
146 |
+
|
147 |
+
if st.session_state.tokenChar == "":
|
148 |
+
characterToken = char.text_input("Character.ai user token")
|
149 |
+
else:
|
150 |
+
characterToken = char.container(border=True)
|
151 |
+
characterToken.write(st.session_state.tokenChar)
|
152 |
+
|
153 |
+
st.session_state.character_ID = data["char_ID"]
|
154 |
+
|
155 |
+
if st.session_state.character_ID == "":
|
156 |
+
character_ID = charID.text_input("Your Character ID")
|
157 |
+
else:
|
158 |
+
character_ID = charID.container(border=True)
|
159 |
+
character_ID.write(st.session_state.character_ID)
|
160 |
+
|
161 |
+
st.session_state.agentID = data["chaindeskID"]
|
162 |
+
|
163 |
+
if st.session_state.agentID == "":
|
164 |
+
chaindeskAgent = chain.text_input("Chaindesk agent ID:")
|
165 |
+
else:
|
166 |
+
chaindeskAgent = chain.container(border=True)
|
167 |
+
chaindeskAgent.write(st.session_state.agentID)
|
168 |
+
|
169 |
+
st.session_state.flow = data["FlowiseID"]
|
170 |
+
|
171 |
+
if st.session_state.flow == "":
|
172 |
+
flowID = flo.text_input("Flowise flow ID:")
|
173 |
+
else:
|
174 |
+
flowID = flo.container(border=True)
|
175 |
+
flowID.write(st.session_state.flow)
|
176 |
+
|
177 |
+
with d2:
|
178 |
+
credentials.clear()
|
179 |
+
st.session_state.fireworks_api = fireworks_api
|
180 |
+
credentials.append(st.session_state.fireworks_api)
|
181 |
+
st.session_state.forefront_api = forefront_api
|
182 |
+
credentials.append(st.session_state.forefront_api)
|
183 |
+
st.session_state.anthropicAPI = anthropic_api
|
184 |
+
credentials.append(st.session_state.anthropicAPI)
|
185 |
+
st.session_state.tokenChar = characterToken
|
186 |
+
credentials.append(st.session_state.tokenChar)
|
187 |
+
st.session_state.character_ID = character_ID
|
188 |
+
credentials.append(st.session_state.character_ID)
|
189 |
+
st.session_state.agentID = chaindeskAgent
|
190 |
+
credentials.append(st.session_state.agentID)
|
191 |
+
st.session_state.flow = flowID
|
192 |
+
credentials.append(st.session_state.flow)
|
193 |
+
|
194 |
+
APItokens = {
|
195 |
+
"APIfireworks": str(st.session_state.fireworks_api),
|
196 |
+
"APIforefront": str(st.session_state.forefront_api),
|
197 |
+
"APIanthropic": str(st.session_state.anthropicAPI),
|
198 |
+
"TokenCharacter": str(st.session_state.tokenChar),
|
199 |
+
"char_ID": str(st.session_state.character_ID),
|
200 |
+
"chaindeskID": str(st.session_state.agentID),
|
201 |
+
"FlowiseID": str(st.session_state.flow)
|
202 |
+
}
|
203 |
+
|
204 |
+
json_credentials = json.dumps(APItokens)
|
205 |
+
print(json_credentials)
|
206 |
+
|
207 |
+
saveAPI = st.download_button(label="Download API tokens",
|
208 |
+
data=json_credentials,
|
209 |
+
file_name=f"APItokens.json",
|
210 |
+
mime="application/json",
|
211 |
+
help="Click to save your API keys")
|
212 |
|
213 |
with c1:
|
214 |
websocketPort = st.number_input("Websocket server port", min_value=1000, max_value=9999, value=1000)
|