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sqlite3
|
| 3 |
+
import websockets
|
| 4 |
+
import json
|
| 5 |
+
import asyncio
|
| 6 |
+
import time
|
| 7 |
+
import conteneiro
|
| 8 |
+
import streamlit as st
|
| 9 |
+
from AgentGPT import AgentsGPT
|
| 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 |
+
|
| 22 |
+
async def main():
|
| 23 |
+
|
| 24 |
+
if "googleAPI" not in st.session_state:
|
| 25 |
+
st.session_state.googleAPI = ""
|
| 26 |
+
if "cseID" not in st.session_state:
|
| 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:
|
| 33 |
+
st.session_state['client_ports'] = ""
|
| 34 |
+
if "servers" not in st.session_state:
|
| 35 |
+
st.session_state['servers'] = ""
|
| 36 |
+
if "clients" not in st.session_state:
|
| 37 |
+
st.session_state['clients'] = ""
|
| 38 |
+
if "gradio_Port" not in st.session_state:
|
| 39 |
+
st.session_state.gradio_Port = ""
|
| 40 |
+
if "server" not in st.session_state:
|
| 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 |
+
fireworks_api = st.text_input("Fireworks API")
|
| 71 |
+
forefront_api = st.text_input("Forefront AI API")
|
| 72 |
+
anthropic_api = st.text_input("Anthropic API")
|
| 73 |
+
characterToken = st.text_input("Character.ai personal token")
|
| 74 |
+
character_ID = st.text_input("Character ID")
|
| 75 |
+
chaindeskAgent = st.text_input("Chaindesk agent ID")
|
| 76 |
+
flowID = st.text_input("Flowise flow ID")
|
| 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)
|
| 86 |
+
startServer = st.button("Start server")
|
| 87 |
+
stopServer = st.button("Stop server")
|
| 88 |
+
st.text("Servers")
|
| 89 |
+
serverPorts1 = st.empty()
|
| 90 |
+
serverPorts = serverPorts1.status(label="websocket servers", state="complete", expanded=False)
|
| 91 |
+
serverPorts.write(conteneiro.servers)
|
| 92 |
+
|
| 93 |
+
with c2:
|
| 94 |
+
clientPort = st.number_input("Websocket client port", min_value=1000, max_value=9999, value=1000)
|
| 95 |
+
runClient = st.button("Start client")
|
| 96 |
+
stopClient = st.button("Stop client")
|
| 97 |
+
st.text("Websocket clients")
|
| 98 |
+
clientPorts1 = st.empty()
|
| 99 |
+
clientPorts = clientPorts1.status(label="websocket clients", state="complete", expanded=False)
|
| 100 |
+
clientPorts.write(conteneiro.clients)
|
| 101 |
+
|
| 102 |
+
with st.sidebar:
|
| 103 |
+
# Wyświetlanie danych, które mogą być modyfikowane na różnych stronach
|
| 104 |
+
st.text("Websocket servers")
|
| 105 |
+
srv_status = st.empty()
|
| 106 |
+
server_status1 = srv_status.status(label="websocket servers", state="complete", expanded=True)
|
| 107 |
+
server_status1.write(conteneiro.servers)
|
| 108 |
+
if st.session_state.server == True:
|
| 109 |
+
st.session_state.server_state = "running"
|
| 110 |
+
srv_status.empty()
|
| 111 |
+
server_status1 = srv_status.status(label="websocket servers", state=st.session_state.server_state, expanded=True)
|
| 112 |
+
server_status1.write(conteneiro.servers)
|
| 113 |
+
|
| 114 |
+
st.text("Websocket clients")
|
| 115 |
+
cli_status = st.empty()
|
| 116 |
+
client_status1 = cli_status.status(label="websocket clients", state="complete", expanded=True)
|
| 117 |
+
client_status1.write(conteneiro.clients)
|
| 118 |
+
if st.session_state.client == True:
|
| 119 |
+
st.session_state.client_state = "running"
|
| 120 |
+
cli_status.empty()
|
| 121 |
+
client_status1 = cli_status.status(label="websocket clients", state=st.session_state.client_state, expanded=True)
|
| 122 |
+
client_status1.write(conteneiro.clients)
|
| 123 |
+
|
| 124 |
+
if selectAgent == "Llama2":
|
| 125 |
+
|
| 126 |
+
if userInput:
|
| 127 |
+
print(f"User B: {userInput}")
|
| 128 |
+
user_input = st.chat_message("human")
|
| 129 |
+
user_input.markdown(userInput)
|
| 130 |
+
agent = Llama2(fireworks_api)
|
| 131 |
+
results = await agent.handleInput(userInput)
|
| 132 |
+
print(results)
|
| 133 |
+
|
| 134 |
+
if runClient:
|
| 135 |
+
st.session_state.client = True
|
| 136 |
+
cli_name = f"Llama2 client port: {clientPort}"
|
| 137 |
+
cli_status.empty()
|
| 138 |
+
client_status1 = cli_status.status(label=cli_name, state="running", expanded=True)
|
| 139 |
+
client_status1.write(conteneiro.clients)
|
| 140 |
+
clientPorts1.empty()
|
| 141 |
+
clientPorts = clientPorts1.status(label=cli_name, state="running", expanded=True)
|
| 142 |
+
clientPorts.write(conteneiro.clients)
|
| 143 |
+
try:
|
| 144 |
+
client = Llama2(fireworks_api)
|
| 145 |
+
await client.startClient(clientPort)
|
| 146 |
+
print(f"Connecting client on port {clientPort}...")
|
| 147 |
+
await asyncio.Future()
|
| 148 |
+
|
| 149 |
+
except Exception as e:
|
| 150 |
+
print(f"Error: {e}")
|
| 151 |
+
|
| 152 |
+
if startServer:
|
| 153 |
+
st.session_state.server = True
|
| 154 |
+
srv_name = f"Llama2 server port: {websocketPort}"
|
| 155 |
+
srv_status.empty()
|
| 156 |
+
server_status1 = srv_status.status(label=srv_name, state="running", expanded=True)
|
| 157 |
+
server_status1.write(conteneiro.servers)
|
| 158 |
+
serverPorts1.empty()
|
| 159 |
+
serverPorts = serverPorts1.status(label=srv_name, state="running", expanded=True)
|
| 160 |
+
serverPorts.write(conteneiro.servers)
|
| 161 |
+
try:
|
| 162 |
+
server = Llama2(fireworks_api)
|
| 163 |
+
await server.start_server(websocketPort)
|
| 164 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 165 |
+
await asyncio.Future()
|
| 166 |
+
|
| 167 |
+
except Exception as e:
|
| 168 |
+
print(f"Error: {e}")
|
| 169 |
+
|
| 170 |
+
if selectAgent == "Copilot":
|
| 171 |
+
|
| 172 |
+
if userInput:
|
| 173 |
+
print(f"User B: {userInput}")
|
| 174 |
+
user_input = st.chat_message("human")
|
| 175 |
+
user_input.markdown(userInput)
|
| 176 |
+
agent = Copilot()
|
| 177 |
+
results = await agent.handleInput(userInput)
|
| 178 |
+
print(results)
|
| 179 |
+
|
| 180 |
+
if runClient:
|
| 181 |
+
st.session_state.client = True
|
| 182 |
+
cli_name1 = f"Copilot client port: {clientPort}"
|
| 183 |
+
cli_status.empty()
|
| 184 |
+
client_status1 = cli_status.status(label=cli_name1, state="running", expanded=True)
|
| 185 |
+
client_status1.write(conteneiro.clients)
|
| 186 |
+
clientPorts1.empty()
|
| 187 |
+
clientPorts = clientPorts1.status(label=cli_name1, state="running", expanded=True)
|
| 188 |
+
clientPorts.write(conteneiro.clients)
|
| 189 |
+
try:
|
| 190 |
+
client = Copilot()
|
| 191 |
+
await client.startClient(clientPort)
|
| 192 |
+
print(f"Connecting client on port {clientPort}...")
|
| 193 |
+
await asyncio.Future()
|
| 194 |
+
|
| 195 |
+
except Exception as e:
|
| 196 |
+
print(f"Error: {e}")
|
| 197 |
+
|
| 198 |
+
if startServer:
|
| 199 |
+
st.session_state.server = True
|
| 200 |
+
srv_name1 = f"Copilot server port: {websocketPort}"
|
| 201 |
+
srv_status.empty()
|
| 202 |
+
server_status1 = srv_status.status(label="websocket servers", state="running", expanded=True)
|
| 203 |
+
server_status1.write(conteneiro.servers)
|
| 204 |
+
serverPorts1.empty()
|
| 205 |
+
serverPorts = serverPorts1.status(label="websocket servers", state="running", expanded=True)
|
| 206 |
+
serverPorts.write(conteneiro.servers)
|
| 207 |
+
try:
|
| 208 |
+
server = Copilot()
|
| 209 |
+
await server.start_server(websocketPort)
|
| 210 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 211 |
+
await asyncio.Future()
|
| 212 |
+
|
| 213 |
+
except Exception as e:
|
| 214 |
+
print(f"Error: {e}")
|
| 215 |
+
|
| 216 |
+
if selectAgent == "ChatGPT":
|
| 217 |
+
|
| 218 |
+
if userInput:
|
| 219 |
+
print(f"User B: {userInput}")
|
| 220 |
+
user_input = st.chat_message("human")
|
| 221 |
+
user_input.markdown(userInput)
|
| 222 |
+
agent = ChatGPT()
|
| 223 |
+
results = await agent.handleInput(userInput)
|
| 224 |
+
print(results)
|
| 225 |
+
|
| 226 |
+
if runClient:
|
| 227 |
+
st.session_state.client = True
|
| 228 |
+
cli_name2 = f"GPT-3,5 client port: {clientPort}"
|
| 229 |
+
cli_status.empty()
|
| 230 |
+
client_status1 = cli_status.status(label=cli_name2, state="running", expanded=True)
|
| 231 |
+
client_status1.write(conteneiro.clients)
|
| 232 |
+
clientPorts1.empty()
|
| 233 |
+
clientPorts = clientPorts1.status(label=cli_name2, state="running", expanded=True)
|
| 234 |
+
clientPorts.write(conteneiro.clients)
|
| 235 |
+
try:
|
| 236 |
+
client = ChatGPT()
|
| 237 |
+
await client.startClient(clientPort)
|
| 238 |
+
print(f"Connecting client on port {clientPort}...")
|
| 239 |
+
await asyncio.Future()
|
| 240 |
+
|
| 241 |
+
except Exception as e:
|
| 242 |
+
print(f"Error: {e}")
|
| 243 |
+
|
| 244 |
+
if startServer:
|
| 245 |
+
st.session_state.server = True
|
| 246 |
+
srv_name2 = f"GPT-3,5 server port: {websocketPort}"
|
| 247 |
+
srv_status.empty()
|
| 248 |
+
server_status1 = srv_status.status(label=srv_name2, state="running", expanded=True)
|
| 249 |
+
server_status1.write(conteneiro.servers)
|
| 250 |
+
serverPorts1.empty()
|
| 251 |
+
serverPorts = serverPorts1.status(label=srv_name2, state="running", expanded=True)
|
| 252 |
+
serverPorts.write(conteneiro.servers)
|
| 253 |
+
try:
|
| 254 |
+
server = ChatGPT()
|
| 255 |
+
await server.start_server(websocketPort)
|
| 256 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 257 |
+
await asyncio.Future()
|
| 258 |
+
|
| 259 |
+
except Exception as e:
|
| 260 |
+
print(f"Error: {e}")
|
| 261 |
+
|
| 262 |
+
if selectAgent == "Forefront AI":
|
| 263 |
+
|
| 264 |
+
if userInput:
|
| 265 |
+
print(f"User B: {userInput}")
|
| 266 |
+
user_input = st.chat_message("human")
|
| 267 |
+
user_input.markdown(userInput)
|
| 268 |
+
agent = ForefrontAI(forefront_api)
|
| 269 |
+
results = await agent.handleInput(userInput)
|
| 270 |
+
print(results)
|
| 271 |
+
|
| 272 |
+
if runClient:
|
| 273 |
+
st.session_state.client = True
|
| 274 |
+
cli_name = f"Forefront AI client port: {clientPort}"
|
| 275 |
+
cli_status.empty()
|
| 276 |
+
client_status1 = cli_status.status(label=cli_name, state="running", expanded=True)
|
| 277 |
+
client_status1.write(conteneiro.clients)
|
| 278 |
+
clientPorts1.empty()
|
| 279 |
+
clientPorts = clientPorts1.status(label=cli_name, state="running", expanded=True)
|
| 280 |
+
clientPorts.write(conteneiro.clients)
|
| 281 |
+
try:
|
| 282 |
+
client = ForefrontAI(forefront_api)
|
| 283 |
+
await client.startClient(clientPort)
|
| 284 |
+
print(f"Connecting client on port {clientPort}...")
|
| 285 |
+
await asyncio.Future()
|
| 286 |
+
|
| 287 |
+
except Exception as e:
|
| 288 |
+
print(f"Error: {e}")
|
| 289 |
+
|
| 290 |
+
if startServer:
|
| 291 |
+
st.session_state.server = True
|
| 292 |
+
srv_name = f"Forefroont AI server port: {websocketPort}"
|
| 293 |
+
srv_status.empty()
|
| 294 |
+
server_status1 = srv_status.status(label=srv_name, state="running", expanded=True)
|
| 295 |
+
server_status1.write(conteneiro.servers)
|
| 296 |
+
serverPorts1.empty()
|
| 297 |
+
serverPorts = serverPorts1.status(label=srv_name, state="running", expanded=True)
|
| 298 |
+
serverPorts.write(conteneiro.servers)
|
| 299 |
+
try:
|
| 300 |
+
server = ForefrontAI(forefront_api)
|
| 301 |
+
await server.start_server(websocketPort)
|
| 302 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 303 |
+
await asyncio.Future()
|
| 304 |
+
|
| 305 |
+
except Exception as e:
|
| 306 |
+
print(f"Error: {e}")
|
| 307 |
+
|
| 308 |
+
if selectAgent == "Claude-3":
|
| 309 |
+
|
| 310 |
+
if userInput:
|
| 311 |
+
print(f"User B: {userInput}")
|
| 312 |
+
user_input = st.chat_message("human")
|
| 313 |
+
user_input.markdown(userInput)
|
| 314 |
+
agent = Claude3(anthropic_api)
|
| 315 |
+
results = await agent.handleInput(userInput)
|
| 316 |
+
print(results)
|
| 317 |
+
|
| 318 |
+
if runClient:
|
| 319 |
+
st.session_state.client = True
|
| 320 |
+
cli_name = f"Claude-3 client port: {clientPort}"
|
| 321 |
+
cli_status.empty()
|
| 322 |
+
client_status1 = cli_status.status(label=cli_name, state="running", expanded=True)
|
| 323 |
+
client_status1.write(conteneiro.clients)
|
| 324 |
+
clientPorts1.empty()
|
| 325 |
+
clientPorts = clientPorts1.status(label=cli_name, state="running", expanded=True)
|
| 326 |
+
clientPorts.write(conteneiro.clients)
|
| 327 |
+
try:
|
| 328 |
+
client = Claude3(anthropic_api)
|
| 329 |
+
await client.startClient(clientPort)
|
| 330 |
+
print(f"Connecting client on port {clientPort}...")
|
| 331 |
+
await asyncio.Future()
|
| 332 |
+
|
| 333 |
+
except Exception as e:
|
| 334 |
+
print(f"Error: {e}")
|
| 335 |
+
|
| 336 |
+
if startServer:
|
| 337 |
+
st.session_state.server = True
|
| 338 |
+
srv_name = f"Claude-3 server port: {websocketPort}"
|
| 339 |
+
srv_status.empty()
|
| 340 |
+
server_status1 = srv_status.status(label=srv_name, state="running", expanded=True)
|
| 341 |
+
server_status1.write(conteneiro.servers)
|
| 342 |
+
serverPorts1.empty()
|
| 343 |
+
serverPorts = serverPorts1.status(label=srv_name, state="running", expanded=True)
|
| 344 |
+
serverPorts.write(conteneiro.servers)
|
| 345 |
+
try:
|
| 346 |
+
server = Claude3(anthropic_api)
|
| 347 |
+
await server.start_server(websocketPort)
|
| 348 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 349 |
+
await asyncio.Future()
|
| 350 |
+
|
| 351 |
+
except Exception as e:
|
| 352 |
+
print(f"Error: {e}")
|
| 353 |
+
|
| 354 |
+
if selectAgent == "Character.ai":
|
| 355 |
+
|
| 356 |
+
if userInput:
|
| 357 |
+
print(f"User B: {userInput}")
|
| 358 |
+
user_input = st.chat_message("human")
|
| 359 |
+
user_input.markdown(userInput)
|
| 360 |
+
agent = CharacterAI(characterToken, character_ID)
|
| 361 |
+
results = await agent.handleInput(userInput)
|
| 362 |
+
print(results)
|
| 363 |
+
|
| 364 |
+
if runClient:
|
| 365 |
+
st.session_state.client = True
|
| 366 |
+
cli_name = f"Claude-3 client port: {clientPort}"
|
| 367 |
+
cli_status.empty()
|
| 368 |
+
client_status1 = cli_status.status(label=cli_name, state="running", expanded=True)
|
| 369 |
+
client_status1.write(conteneiro.clients)
|
| 370 |
+
clientPorts1.empty()
|
| 371 |
+
clientPorts = clientPorts1.status(label=cli_name, state="running", expanded=True)
|
| 372 |
+
clientPorts.write(conteneiro.clients)
|
| 373 |
+
try:
|
| 374 |
+
client = CharacterAI(characterToken, character_ID)
|
| 375 |
+
await client.startClient(clientPort)
|
| 376 |
+
print(f"Connecting client on port {clientPort}...")
|
| 377 |
+
await asyncio.Future()
|
| 378 |
+
|
| 379 |
+
except Exception as e:
|
| 380 |
+
print(f"Error: {e}")
|
| 381 |
+
|
| 382 |
+
if startServer:
|
| 383 |
+
st.session_state.server = True
|
| 384 |
+
srv_name = f"Claude-3 server port: {websocketPort}"
|
| 385 |
+
srv_status.empty()
|
| 386 |
+
server_status1 = srv_status.status(label=srv_name, state="running", expanded=True)
|
| 387 |
+
server_status1.write(conteneiro.servers)
|
| 388 |
+
serverPorts1.empty()
|
| 389 |
+
serverPorts = serverPorts1.status(label=srv_name, state="running", expanded=True)
|
| 390 |
+
serverPorts.write(conteneiro.servers)
|
| 391 |
+
try:
|
| 392 |
+
server = CharacterAI(characterToken, character_ID)
|
| 393 |
+
await server.start_server(websocketPort)
|
| 394 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 395 |
+
await asyncio.Future()
|
| 396 |
+
|
| 397 |
+
except Exception as e:
|
| 398 |
+
print(f"Error: {e}")
|
| 399 |
+
|
| 400 |
+
if selectAgent == "Chaindesk":
|
| 401 |
+
|
| 402 |
+
if userInput:
|
| 403 |
+
print(f"User B: {userInput}")
|
| 404 |
+
user_input = st.chat_message("human")
|
| 405 |
+
user_input.markdown(userInput)
|
| 406 |
+
agent = Chaindesk(chaindeskAgent)
|
| 407 |
+
results = await agent.handleInput(userInput)
|
| 408 |
+
print(results)
|
| 409 |
+
|
| 410 |
+
if runClient:
|
| 411 |
+
st.session_state.client = True
|
| 412 |
+
cli_name = f"Claude-3 client port: {clientPort}"
|
| 413 |
+
cli_status.empty()
|
| 414 |
+
client_status1 = cli_status.status(label=cli_name, state="running", expanded=True)
|
| 415 |
+
client_status1.write(conteneiro.clients)
|
| 416 |
+
clientPorts1.empty()
|
| 417 |
+
clientPorts = clientPorts1.status(label=cli_name, state="running", expanded=True)
|
| 418 |
+
clientPorts.write(conteneiro.clients)
|
| 419 |
+
try:
|
| 420 |
+
client = Chaindesk(chaindeskAgent)
|
| 421 |
+
await client.startClient(clientPort)
|
| 422 |
+
print(f"Connecting client on port {clientPort}...")
|
| 423 |
+
await asyncio.Future()
|
| 424 |
+
|
| 425 |
+
except Exception as e:
|
| 426 |
+
print(f"Error: {e}")
|
| 427 |
+
|
| 428 |
+
if startServer:
|
| 429 |
+
st.session_state.server = True
|
| 430 |
+
srv_name = f"Claude-3 server port: {websocketPort}"
|
| 431 |
+
srv_status.empty()
|
| 432 |
+
server_status1 = srv_status.status(label=srv_name, state="running", expanded=True)
|
| 433 |
+
server_status1.write(conteneiro.servers)
|
| 434 |
+
serverPorts1.empty()
|
| 435 |
+
serverPorts = serverPorts1.status(label=srv_name, state="running", expanded=True)
|
| 436 |
+
serverPorts.write(conteneiro.servers)
|
| 437 |
+
try:
|
| 438 |
+
server = Chaindesk(chaindeskAgent)
|
| 439 |
+
await server.start_server(websocketPort)
|
| 440 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 441 |
+
await asyncio.Future()
|
| 442 |
+
|
| 443 |
+
except Exception as e:
|
| 444 |
+
print(f"Error: {e}")
|
| 445 |
+
|
| 446 |
+
if selectAgent == "Flowise":
|
| 447 |
+
|
| 448 |
+
if userInput:
|
| 449 |
+
print(f"User B: {userInput}")
|
| 450 |
+
user_input = st.chat_message("human")
|
| 451 |
+
user_input.markdown(userInput)
|
| 452 |
+
agent = Flowise(flowID)
|
| 453 |
+
results = await agent.handleInput(userInput)
|
| 454 |
+
print(results)
|
| 455 |
+
|
| 456 |
+
if runClient:
|
| 457 |
+
st.session_state.client = True
|
| 458 |
+
cli_name = f"Claude-3 client port: {clientPort}"
|
| 459 |
+
cli_status.empty()
|
| 460 |
+
client_status1 = cli_status.status(label=cli_name, state="running", expanded=True)
|
| 461 |
+
client_status1.write(conteneiro.clients)
|
| 462 |
+
clientPorts1.empty()
|
| 463 |
+
clientPorts = clientPorts1.status(label=cli_name, state="running", expanded=True)
|
| 464 |
+
clientPorts.write(conteneiro.clients)
|
| 465 |
+
try:
|
| 466 |
+
client = Flowise(flowID)
|
| 467 |
+
await client.startClient(clientPort)
|
| 468 |
+
print(f"Connecting client on port {clientPort}...")
|
| 469 |
+
await asyncio.Future()
|
| 470 |
+
|
| 471 |
+
except Exception as e:
|
| 472 |
+
print(f"Error: {e}")
|
| 473 |
+
|
| 474 |
+
if startServer:
|
| 475 |
+
st.session_state.server = True
|
| 476 |
+
srv_name = f"Claude-3 server port: {websocketPort}"
|
| 477 |
+
srv_status.empty()
|
| 478 |
+
server_status1 = srv_status.status(label=srv_name, state="running", expanded=True)
|
| 479 |
+
server_status1.write(conteneiro.servers)
|
| 480 |
+
serverPorts1.empty()
|
| 481 |
+
serverPorts = serverPorts1.status(label=srv_name, state="running", expanded=True)
|
| 482 |
+
serverPorts.write(conteneiro.servers)
|
| 483 |
+
try:
|
| 484 |
+
server = Flowise(flowID)
|
| 485 |
+
await server.start_server(websocketPort)
|
| 486 |
+
print(f"Starting WebSocket server on port {websocketPort}...")
|
| 487 |
+
await asyncio.Future()
|
| 488 |
+
|
| 489 |
+
except Exception as e:
|
| 490 |
+
print(f"Error: {e}")
|
| 491 |
+
|
| 492 |
+
asyncio.run(main())
|