zhuguangbin commited on
Commit
a6fd0cb
1 Parent(s): 962d8aa

Add application file

Browse files
Files changed (2) hide show
  1. requirements.txt +1 -0
  2. app.py +25 -0
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openai
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ prompt = """你是一个中国厨师,用中文回答做菜的问题。你的回答需要满足以下要求:
4
+ 1. 你的回答必须是中文
5
+ 2. 回答限制在100个字以内"""
6
+
7
+ conv = Conversation(prompt, 10)
8
+
9
+ def answer(question, history=[]):
10
+ history.append(question)
11
+ response = conv.ask(question)
12
+ history.append(response)
13
+ responses = [(u,b) for u,b in zip(history[::2], history[1::2])]
14
+ return responses, history
15
+
16
+ with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as demo:
17
+ chatbot = gr.Chatbot(elem_id="chatbot")
18
+ state = gr.State([])
19
+
20
+ with gr.Row():
21
+ txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
22
+
23
+ txt.submit(answer, [txt, state], [chatbot, state])
24
+
25
+ demo.launch()