File size: 915 Bytes
c3a1883
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8a0dac3
c3a1883
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import requests


def audit_text(text, url):
    data = {
        "text": text,
        "source": "ALIYUN",
        "model": "ALIYUN_TEXT_AUDIT"
    }
    res = requests.post(url, json=data)
    data = res.json()

    is_pass = data.get('data', {}).get('pass')
    if is_pass:
        return data, f'合规'
    return data, '不合规'


def audit_tab():
    with gr.Tab("关键词审核"):
        with gr.Column():
            url_input = gr.Textbox(label='接口链接')
            text_input = gr.Textbox(label="待审核的关键词", lines=10)
        gr.Examples(['你是傻逼吧', '你是天才'], inputs=text_input)
        with gr.Row():
            text_output = gr.Json(label="结果", lines=10)
            label_output = gr.Label()
        text_button = gr.Button('检测')

    text_button.click(audit_text, inputs=[text_input, url_input], outputs=[text_output, label_output])