pip install gradio
- 使用
import gradio as gr
prompt = "开始描述吧,我会认真回答你哦!"
def chatgpt_davinci(_input, history):
history = history or []
output = _input
history.append((_input, output))
history = history[-200:]
return history,history
block = gr.Blocks()
with block:
gr.Markdown("""ChatGPT
""")
chatbot = gr.Chatbot()
message = gr.Textbox(value="", placeholder=prompt)
state = gr.State()
submit = gr.Button("发送")
submit.click(chatgpt_davinci, inputs=[message, state], outputs=[chatbot, state])
block.launch(server_name="0.0.0.0")