Arcypojeb commited on
Commit
e72ad7d
·
1 Parent(s): 8d2eb7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -51,7 +51,7 @@ class SimpleHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
51
  db = sqlite3.connect('chat-hub.db')
52
  cursor = db.cursor()
53
  cursor.execute('CREATE TABLE IF NOT EXISTS messages (id INTEGER PRIMARY KEY AUTOINCREMENT, sender TEXT, message TEXT, timestamp TEXT)')
54
- db.commit()
55
 
56
  # Define the function for sending an error message
57
  def sendErrorMessage(ws, errorMessage):
@@ -61,11 +61,10 @@ def sendErrorMessage(ws, errorMessage):
61
  # Define a function to ask a question to the chatbot and display the response
62
  async def askQuestion(question):
63
  try:
64
- message = client_messages[-1]
65
- response = requests.post("https://api.docsbot.ai/teams/ZrbLG98bbxZ9EFqiPvyl/bots/oFFiXuQsakcqyEdpLvCB/chat",
66
  headers={"Content-Type": "application/json"},
67
- json={"question": message,
68
- "full source":false},
69
  )
70
  response_content = response.content.decode('utf-8')
71
  client_messages.append(response_content)
@@ -177,16 +176,18 @@ with gr.Blocks() as demo:
177
  websocketPort = gr.Slider(minimum=1000, maximum=9999, label="Websocket server port", interactive=True, randomize=False)
178
  startWebsockets = gr.Button("Start WebSocket Server")
179
  stopWebsockets = gr.Button("Stop WebSocket Server")
180
- with gr.Row():
 
 
 
 
181
  gui = gr.Button("connect interface")
182
  with gr.Row():
183
  port = gr.Textbox()
184
  startWebsockets.click(start_websockets, inputs=websocketPort, outputs=port)
185
  gui.click(start_client, inputs=None, outputs=server_msg)
186
-
187
- client_msg.change(askQuestion, inputs=client_msg, outputs=server_msg).then(askQuestion2, inputs=server_msg, outputs=client_msg)
188
- server_msg.change(askQuestion2, inputs=server_msg, outputs=client_msg).then(askQuestion, inputs=client_msg, outputs=server_msg)
189
-
190
  with gr.TabItem("FalconChat", elem_id="falconchat", id=1):
191
  gr.load("HuggingFaceH4/starchat-playground", src="spaces")
192
 
 
51
  db = sqlite3.connect('chat-hub.db')
52
  cursor = db.cursor()
53
  cursor.execute('CREATE TABLE IF NOT EXISTS messages (id INTEGER PRIMARY KEY AUTOINCREMENT, sender TEXT, message TEXT, timestamp TEXT)')
54
+ db.commit()
55
 
56
  # Define the function for sending an error message
57
  def sendErrorMessage(ws, errorMessage):
 
61
  # Define a function to ask a question to the chatbot and display the response
62
  async def askQuestion(question):
63
  try:
64
+ response = requests.post(
65
+ "https://flowiseai-flowise.hf.space/api/v1/prediction/d5d12cce-9663-49d1-b7ad-1f7fff352b8a",
66
  headers={"Content-Type": "application/json"},
67
+ json={"question": question},
 
68
  )
69
  response_content = response.content.decode('utf-8')
70
  client_messages.append(response_content)
 
176
  websocketPort = gr.Slider(minimum=1000, maximum=9999, label="Websocket server port", interactive=True, randomize=False)
177
  startWebsockets = gr.Button("Start WebSocket Server")
178
  stopWebsockets = gr.Button("Stop WebSocket Server")
179
+ with gr.Row():
180
+ input = gr.Textbox(lines=1, max_lines=10, label="User inputs")
181
+ with gr.Row():
182
+ Bot1 = gr.Button("Bot 1")
183
+ with gr.Row():
184
  gui = gr.Button("connect interface")
185
  with gr.Row():
186
  port = gr.Textbox()
187
  startWebsockets.click(start_websockets, inputs=websocketPort, outputs=port)
188
  gui.click(start_client, inputs=None, outputs=server_msg)
189
+ Bot1.click(askQuestion, inputs=client_msg, outputs=server_msg)
190
+
 
 
191
  with gr.TabItem("FalconChat", elem_id="falconchat", id=1):
192
  gr.load("HuggingFaceH4/starchat-playground", src="spaces")
193