Spaces:
Paused
Paused
File size: 1,088 Bytes
1b5d225 5d230ab 1920123 1b5d225 7bab278 1b5d225 2fa04e8 bbc49f2 5d230ab 1b5d225 5d230ab 1b5d225 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#import gradio as gr
#def greet(name):
#return "Hello " + name + "!!"
#iface = gr.Interface(fn=greet, inputs="text", outputs="text")
#iface.launch()
import gradio as gr
from Conversation import Conversation
prompt = """你是一个中国厨师,用中文回答做菜的问题。你的回答需要满足以下要求:
1. 你的回答必须是中文
2. 回答限制在100个字以内"""
conv = Conversation(prompt, 10)
def answer(question, history=[]):
history.append(question)
response = conv.ask(question)
history.append(response)
responses = [(u,b) for u,b in zip(history[::2], history[1::2])]
return responses, history
with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as demo:
chatbot = gr.Chatbot(elem_id="chatbot")
state = gr.State([])
with gr.Row():
#txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter")
txt.submit(answer, [txt, state], [chatbot, state])
demo.launch() |