orangewong commited on
Commit
d7abcd1
·
verified ·
1 Parent(s): 5c8f89e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -36,32 +36,32 @@ def predict(message, history):
36
  return response.strip()
37
 
38
  # 创建Gradio界面
39
- # demo = gr.ChatInterface(
40
- # predict,
41
- # title="测试Zhi-writing-dsr1-14b",
42
- # description="Zhihu-ai/Zhi-writing-dsr1-14b",
43
- # examples=["鲁迅口吻写五百字,描述桔猫的可爱!", "桔了个仔是谁", "介绍自己"],
44
- # theme=gr.themes.Soft()
45
- # )
46
 
47
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
48
- gr.Markdown("# Zhi-writing-dsr1-14")
49
- gr.Markdown("这是一个基于Zhi-writing-dsr1-14的文章生成器")
50
 
51
- chatbot = gr.Chatbot()
52
- msg = gr.Textbox(label="输入消息")
53
- clear = gr.Button("清除对话")
54
 
55
- def respond(message, chat_history):
56
- bot_message = ""
57
- for response in predict(message, chat_history):
58
- bot_message = response
59
- chat_history.append((message, bot_message))
60
- yield chat_history
61
- return "", chat_history
62
 
63
- msg.submit(respond, [msg, chatbot], [msg, chatbot])
64
- clear.click(lambda: None, None, chatbot, queue=False)
65
 
66
  if __name__ == "__main__":
67
  demo.launch(share=True)
 
36
  return response.strip()
37
 
38
  # 创建Gradio界面
39
+ demo = gr.ChatInterface(
40
+ predict,
41
+ title="测试Zhi-writing-dsr1-14b",
42
+ description="Zhihu-ai/Zhi-writing-dsr1-14b",
43
+ examples=["鲁迅口吻写五百字,描述桔猫的可爱!", "桔了个仔是谁", "介绍自己"],
44
+ theme=gr.themes.Soft()
45
+ )
46
 
47
+ # with gr.Blocks(theme=gr.themes.Soft()) as demo:
48
+ # gr.Markdown("# Zhi-writing-dsr1-14")
49
+ # gr.Markdown("这是一个基于Zhi-writing-dsr1-14的文章生成器")
50
 
51
+ # chatbot = gr.Chatbot()
52
+ # msg = gr.Textbox(label="输入消息")
53
+ # clear = gr.Button("清除对话")
54
 
55
+ # def respond(message, chat_history):
56
+ # bot_message = ""
57
+ # for response in predict(message, chat_history):
58
+ # bot_message = response
59
+ # chat_history.append((message, bot_message))
60
+ # yield chat_history
61
+ # return "", chat_history
62
 
63
+ # msg.submit(respond, [msg, chatbot], [msg, chatbot])
64
+ # clear.click(lambda: None, None, chatbot, queue=False)
65
 
66
  if __name__ == "__main__":
67
  demo.launch(share=True)