Update app.py
Browse files
app.py
CHANGED
|
@@ -37,15 +37,26 @@ def predict(message, history):
|
|
| 37 |
):
|
| 38 |
yield response.strip()
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
if __name__ == "__main__":
|
| 51 |
demo.launch(share=True)
|
|
|
|
| 37 |
):
|
| 38 |
yield response.strip()
|
| 39 |
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 43 |
+
gr.Markdown("# Zhi-writing-dsr1-14")
|
| 44 |
+
gr.Markdown("这是一个基于Zhi-writing-dsr1-14的文章生成器")
|
| 45 |
+
|
| 46 |
+
chatbot = gr.Chatbot()
|
| 47 |
+
msg = gr.Textbox(label="输入消息")
|
| 48 |
+
clear = gr.Button("清除对话")
|
| 49 |
+
|
| 50 |
+
def respond(message, chat_history):
|
| 51 |
+
bot_message = ""
|
| 52 |
+
for response in predict(message, chat_history):
|
| 53 |
+
bot_message = response
|
| 54 |
+
chat_history.append((message, bot_message))
|
| 55 |
+
yield chat_history
|
| 56 |
+
return "", chat_history
|
| 57 |
+
|
| 58 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 59 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
| 60 |
|
| 61 |
if __name__ == "__main__":
|
| 62 |
demo.launch(share=True)
|