quan1998 commited on
Commit
30b8f0f
·
verified ·
1 Parent(s): 0fa40d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -37,7 +37,7 @@ def respond(
37
 
38
  """
39
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
40
- """
41
  demo = gr.ChatInterface(
42
  respond,
43
  additional_inputs=[
@@ -46,5 +46,28 @@ demo = gr.ChatInterface(
46
  ]
47
  )
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  if __name__ == "__main__":
50
  demo.launch()
 
 
37
 
38
  """
39
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
40
+
41
  demo = gr.ChatInterface(
42
  respond,
43
  additional_inputs=[
 
46
  ]
47
  )
48
 
49
+ """
50
+
51
+ def greet(message):
52
+ messages.append({"role": "user", "content": message})
53
+ response = ""
54
+ for message in client.chat_completion(
55
+ messages,
56
+ stream=True,
57
+ max_tokens=1024,
58
+ temperature=0.7,
59
+ top_p=0.95
60
+ ):
61
+ token = message.choices[0].delta.content
62
+ response += token
63
+ yield response
64
+
65
+ demo = gr.Interface(
66
+ fn=greet,
67
+ inputs=["text"],
68
+ outputs=[gr.Textbox(label="greeting", lines=3)],
69
+ )
70
+
71
  if __name__ == "__main__":
72
  demo.launch()
73
+