Arcypojeb commited on
Commit
da744c6
1 Parent(s): 6b54337

Update clientFireworks.py

Browse files
Files changed (1) hide show
  1. clientFireworks.py +8 -4
clientFireworks.py CHANGED
@@ -7,9 +7,12 @@ import streamlit as st
7
 
8
  # Define the websocket client class
9
  class WebSocketClient:
10
- def __init__(self, uri):
11
  # Initialize the uri attribute
12
- self.uri = uri
 
 
 
13
 
14
  async def chatCompletion(self, question):
15
  system_instruction = "You are now integrated with a local websocket server in a project of hierarchical cooperative multi-agent framework called NeuralGPT. Your main job is to coordinate simultaneous work of multiple LLMs connected to you as clients. Each LLM has a model (API) specific ID to help you recognize different clients in a continuous chat thread (template: <NAME>-agent and/or <NAME>-client). Your chat memory module is integrated with a local SQL database with chat history. Your primary objective is to maintain the logical and chronological order while answering incoming messages and to send your answers to the correct clients to maintain synchronization of the question->answer logic. However, please note that you may choose to ignore or not respond to repeating inputs from specific clients as needed to prevent unnecessary traffic."
@@ -72,10 +75,11 @@ class WebSocketClient:
72
  loop.run_until_complete(self.client())
73
 
74
  # Define a coroutine that will connect to the server and exchange messages
75
- async def startClient(self):
 
76
  status = st.sidebar.status(label="runs", state="complete", expanded=False)
77
  # Connect to the server
78
- async with websockets.connect(self.uri) as websocket:
79
  # Loop forever
80
  while True:
81
  status.update(label="runs", state="running", expanded=True)
 
7
 
8
  # Define the websocket client class
9
  class WebSocketClient:
10
+ def __init__(self, clientPort):
11
  # Initialize the uri attribute
12
+ self.clientPort = clientPort
13
+
14
+ if "client_ports" not in st.session_state:
15
+ st.session_state['client_ports'] = ""
16
 
17
  async def chatCompletion(self, question):
18
  system_instruction = "You are now integrated with a local websocket server in a project of hierarchical cooperative multi-agent framework called NeuralGPT. Your main job is to coordinate simultaneous work of multiple LLMs connected to you as clients. Each LLM has a model (API) specific ID to help you recognize different clients in a continuous chat thread (template: <NAME>-agent and/or <NAME>-client). Your chat memory module is integrated with a local SQL database with chat history. Your primary objective is to maintain the logical and chronological order while answering incoming messages and to send your answers to the correct clients to maintain synchronization of the question->answer logic. However, please note that you may choose to ignore or not respond to repeating inputs from specific clients as needed to prevent unnecessary traffic."
 
75
  loop.run_until_complete(self.client())
76
 
77
  # Define a coroutine that will connect to the server and exchange messages
78
+ async def startClient(self, clientPort):
79
+ uri = f'ws://localhost:{clientPort}'
80
  status = st.sidebar.status(label="runs", state="complete", expanded=False)
81
  # Connect to the server
82
+ async with websockets.connect(uri) as websocket:
83
  # Loop forever
84
  while True:
85
  status.update(label="runs", state="running", expanded=True)