python gradio 不需要前端的web框架

python 库

python 复制代码
import gradio as gr

def summarize(text, style):
    return f"摘要({style}风格):{text[:20]}..."

gr.Interface(
    fn=summarize,
    inputs=[
        gr.Textbox(lines=5, label="输入文本"),
        gr.Radio(["简洁", "详细"], label="风格")
    ],
    outputs="text"
).launch(server_name="0.0.0.0",server_port=7860)