Artem0729 commited on
Commit
33cca3f
·
verified ·
1 Parent(s): a5fba64

Update some code styles

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -57,7 +57,7 @@ class MediatorRetriever(BaseRetriever):
57
  }
58
  }
59
  ]
60
-
61
  response = openai_client.chat.completions.create(
62
  model="gpt-4-1106-preview",
63
  messages=[
@@ -162,11 +162,10 @@ class MediatorRetriever(BaseRetriever):
162
  response = openai_client.chat.completions.create(
163
  model="gpt-4-1106-preview",
164
  messages=[
165
- {"role": "system", "content": "Please extract how many mediators users want to search."},
166
  {"role": "user", "content": query}
167
  ],
168
- functions=tools,
169
- stream=True
170
  )
171
  try:
172
  number_str = response.choices[0].message.function_call.arguments
@@ -200,7 +199,7 @@ class MediatorRetriever(BaseRetriever):
200
  filter=metadata,
201
  include_metadata=True
202
  )
203
-
204
  new_data = []
205
  for result in results['matches']:
206
  data = {}
@@ -400,7 +399,7 @@ js_code = """
400
 
401
 
402
  function autoScroll() {
403
- const chatbox = document.querySelector('#component-4');
404
  if (chatbox) {
405
  chatbox.scrollTop = chatbox.scrollHeight;
406
  }
@@ -414,11 +413,19 @@ js_code = """
414
  </script>
415
  """
416
 
 
 
 
 
 
 
 
417
  with gr.Blocks(head=js_code) as demo:
418
- with gr.Column() as chatbox_container:
419
  chatbox = gr.ChatInterface(fn=search, title="Mediate.com Chatbot Application", multimodal=False, retry_btn=None, clear_btn=None, undo_btn=None, chatbot=chatbot)
420
 
421
- gr.HTML(f'<button id="message-btn"/><img style="display: inline;" src="/file=message.png" id="custom-btn"/><button>')
 
422
 
423
  if __name__ == "__main__":
424
  demo.launch(debug=True, allowed_paths=["./"])
 
57
  }
58
  }
59
  ]
60
+
61
  response = openai_client.chat.completions.create(
62
  model="gpt-4-1106-preview",
63
  messages=[
 
162
  response = openai_client.chat.completions.create(
163
  model="gpt-4-1106-preview",
164
  messages=[
165
+ {"role": "system", "content": "Please extract how many mediators users want to search for."},
166
  {"role": "user", "content": query}
167
  ],
168
+ functions=tools
 
169
  )
170
  try:
171
  number_str = response.choices[0].message.function_call.arguments
 
199
  filter=metadata,
200
  include_metadata=True
201
  )
202
+
203
  new_data = []
204
  for result in results['matches']:
205
  data = {}
 
399
 
400
 
401
  function autoScroll() {
402
+ const chatbox = document.querySelector('.bubble-wrap');
403
  if (chatbox) {
404
  chatbox.scrollTop = chatbox.scrollHeight;
405
  }
 
413
  </script>
414
  """
415
 
416
+ def toggle_chatbox():
417
+ global chatbox_visible
418
+ chatbox_visible = not chatbox_visible
419
+ return gr.update(visible=chatbox_visible)
420
+
421
+ chatbox_visible = True
422
+
423
  with gr.Blocks(head=js_code) as demo:
424
+ with gr.Column(visible=chatbox_visible) as chatbox_container:
425
  chatbox = gr.ChatInterface(fn=search, title="Mediate.com Chatbot Application", multimodal=False, retry_btn=None, clear_btn=None, undo_btn=None, chatbot=chatbot)
426
 
427
+
428
+ gr.HTML(f'<button src="/file=message.png" id="message-btn"/><img style="display: inline;" src="/file=message.png" id="custom-btn"/><button>')
429
 
430
  if __name__ == "__main__":
431
  demo.launch(debug=True, allowed_paths=["./"])