yunfeisam commited on
Commit
1dbfacb
·
1 Parent(s): 87308f6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ prompt = """你是一个大数据和AI领域的专家,用中文回答大数据和AI的相关问题。你的回答需要满足以下要求:
3
+ 1. 你的回答必须是中文
4
+ 2. 回答限制在100个字以内"""
5
+ conv = Conversation(prompt, 6)
6
+ def answer(question, history=[]):
7
+ history.append(question)
8
+ message = conv.ask(question)
9
+ history.append(message)
10
+ responses = [(u,b) for u,b in zip(history[::2], history[1::2])]
11
+ print(responses)
12
+ return responses, history
13
+ with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as rxbot:
14
+ chatbot = gr.Chatbot(elem_id="chatbot")
15
+ state = gr.State([])
16
+ with gr.Row():
17
+ txt = gr.Textbox(show_label=False, placeholder="请输入你的问题").style(container=False)
18
+ txt.submit(answer, [txt, state], [chatbot, state])
19
+
20
+ rxbot.launch()