Arcypojeb commited on
Commit
cca3c5c
1 Parent(s): d12621c

Update pages/NeuralAgents.py

Browse files
Files changed (1) hide show
  1. pages/NeuralAgents.py +100 -117
pages/NeuralAgents.py CHANGED
@@ -71,17 +71,35 @@ async def main():
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")
@@ -95,121 +113,7 @@ async def main():
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)
215
  startServer = st.button("Start server")
@@ -250,6 +154,85 @@ async def main():
250
  client_status1 = cli_status.status(label="websocket clients", state=st.session_state.client_state, expanded=True)
251
  client_status1.write(conteneiro.clients)
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  if selectAgent == "Llama2":
254
 
255
  if userInput:
 
71
  if "client_state" not in st.session_state:
72
  st.session_state.client_state = "complete"
73
 
74
+ APItokens = {
75
+ "APIfireworks": str(st.session_state.fireworks_api),
76
+ "APIforefront": str(st.session_state.forefront_api),
77
+ "APIanthropic": str(st.session_state.anthropicAPI),
78
+ "TokenCharacter": str(st.session_state.tokenChar),
79
+ "char_ID": str(st.session_state.character_ID),
80
+ "chaindeskID": str(st.session_state.agentID),
81
+ "FlowiseID": str(st.session_state.flow)
82
+ }
83
+
84
+ json_credentials = json.dumps(APItokens)
85
+ print(json_credentials)
86
+
87
  userInput = st.chat_input("Ask Agent")
88
 
89
  with st.expander("Personal API tokens"):
90
+ uploadAPI = st.file_uploader(label="Upload credentials")
91
  fire = st.empty()
92
  fore = st.empty()
93
  anthro = st.empty()
94
  char = st.empty()
95
  charID = st.empty()
96
  chain = st.empty()
97
+ flo = st.empty()
98
+ saveAPI = st.download_button(label="Download API tokens",
99
+ data=json_credentials,
100
+ file_name=f"APItokens.json",
101
+ mime="application/json",
102
+ help="Click to save your API keys")
103
 
104
  if st.session_state.tokens == None:
105
  fireworks_api = fire.text_input("Fireworks API")
 
113
  c1, c2 = st.columns(2)
114
 
115
  selectAgent = st.selectbox("Select agent", ("Llama2", "Copilot", "ChatGPT", "Forefront AI", "Claude-3", "Character.ai", "Chaindesk", "Flowise"))
116
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  with c1:
118
  websocketPort = st.number_input("Websocket server port", min_value=1000, max_value=9999, value=1000)
119
  startServer = st.button("Start server")
 
154
  client_status1 = cli_status.status(label="websocket clients", state=st.session_state.client_state, expanded=True)
155
  client_status1.write(conteneiro.clients)
156
 
157
+ if uploadAPI is not None:
158
+
159
+ data = json.load(uploadAPI)
160
+ print(data)
161
+
162
+ st.session_state.fireworks_api = data["APIfireworks"]
163
+
164
+ if st.session_state.fireworks_api == "":
165
+ fireworks_api = fire.text_input("Fireworks API key")
166
+ else:
167
+ fireworks_api = fire.container(border=True)
168
+ fireworks_api.write(st.session_state.fireworks_api)
169
+
170
+ st.session_state.forefront_api = data["APIforefront"]
171
+
172
+ if st.session_state.forefront_api == "":
173
+ forefront_api = fore.text_input("Forefront API key")
174
+ else:
175
+ forefront_api = fore.container(border=True)
176
+ forefront_api.write(st.session_state.forefront_api)
177
+
178
+ st.session_state.anthropicAPI = data["APIanthropic"]
179
+
180
+ if st.session_state.anthropicAPI == "":
181
+ anthropic_api = anthro.text_input("Anthropic API key")
182
+ else:
183
+ anthropic_api = anthro.container(border=True)
184
+ anthropic_api.write(st.session_state.anthropicAPI)
185
+
186
+ st.session_state.tokenChar = data["TokenCharacter"]
187
+
188
+ if st.session_state.tokenChar == "":
189
+ characterToken = char.text_input("Character.ai user token")
190
+ else:
191
+ characterToken = char.container(border=True)
192
+ characterToken.write(st.session_state.tokenChar)
193
+
194
+ st.session_state.character_ID = data["char_ID"]
195
+
196
+ if st.session_state.character_ID == "":
197
+ character_ID = charID.text_input("Your Character ID")
198
+ else:
199
+ character_ID = charID.container(border=True)
200
+ character_ID.write(st.session_state.character_ID)
201
+
202
+ st.session_state.agentID = data["chaindeskID"]
203
+
204
+ if st.session_state.agentID == "":
205
+ chaindeskAgent = chain.text_input("Chaindesk agent ID:")
206
+ else:
207
+ chaindeskAgent = chain.container(border=True)
208
+ chaindeskAgent.write(st.session_state.agentID)
209
+
210
+ st.session_state.flow = data["FlowiseID"]
211
+
212
+ if st.session_state.flow == "":
213
+ flowID = flo.text_input("Flowise flow ID:")
214
+ else:
215
+ flowID = flo.container(border=True)
216
+ flowID.write(st.session_state.flow)
217
+
218
+ if saveAPI:
219
+ credentials.clear()
220
+ st.session_state.fireworks_api = fireworks_api
221
+ credentials.append(st.session_state.fireworks_api)
222
+ st.session_state.forefront_api = forefront_api
223
+ credentials.append(st.session_state.forefront_api)
224
+ st.session_state.anthropicAPI = anthropic_api
225
+ credentials.append(st.session_state.anthropicAPI)
226
+ st.session_state.tokenChar = characterToken
227
+ credentials.append(st.session_state.tokenChar)
228
+ st.session_state.character_ID = character_ID
229
+ credentials.append(st.session_state.character_ID)
230
+ st.session_state.agentID = chaindeskAgent
231
+ credentials.append(st.session_state.agentID)
232
+ st.session_state.flow = flowID
233
+ credentials.append(st.session_state.flow)
234
+
235
+
236
  if selectAgent == "Llama2":
237
 
238
  if userInput: