File size: 525 Bytes
8d84024
13ee506
d794995
13ee506
8d84024
13ee506
 
 
8d84024
13ee506
8d84024
 
13ee506
 
8d84024
13ee506
8d84024
 
13ee506
cfe1a3c
13ee506
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from pydantic import BaseModel

# 定义 Gradio 接口
def gradio_interface(text):
    # 在这里实现实际的预处理逻辑
    result = text + " (preprocessed)"
    return {"result": result}

# 配置 Gradio 接口
iface = gr.Interface(
    fn=gradio_interface,
    inputs="text",
    outputs="json",
    title="文本预处理 API",
    description="发送文本到 Gradio 接口进行预处理并获取 JSON 格式的响应"
)

# 运行 Gradio 应用
if __name__ == "__main__":
    iface.launch()