codeblacks commited on
Commit
6fce3b8
·
verified ·
1 Parent(s): 123b2fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -29,7 +29,7 @@ async def respond(
29
 
30
  response = ""
31
 
32
- for message in client.chat_completion(
33
  messages,
34
  max_tokens=max_tokens,
35
  stream=True,
@@ -40,13 +40,15 @@ async def respond(
40
 
41
  response += token
42
  yield response
 
43
 
44
-
 
45
  """
46
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
47
  """
48
  demo = gr.ChatInterface(
49
- respond,
50
  additional_inputs=[
51
  gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
52
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
 
29
 
30
  response = ""
31
 
32
+ async for message in client.chat_completion(
33
  messages,
34
  max_tokens=max_tokens,
35
  stream=True,
 
40
 
41
  response += token
42
  yield response
43
+
44
 
45
+ def sync_respond(*args):
46
+ return asyncio.run(respond(*args))
47
  """
48
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
49
  """
50
  demo = gr.ChatInterface(
51
+ sync_respond,
52
  additional_inputs=[
53
  gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
54
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),