|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-qa-detector-distil",use_auth_token=access_token) |
|
|
|
|
|
|
|
|
|
def predict_en(q,a): |
|
res = pipeline_en({"text":q, "text_pair":a}) |
|
return res['label'],res['score'] |
|
|
|
def predict_zh(sketch): |
|
|
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown(""" |
|
## ChatGPT detector |
|
""") |
|
with gr.Tab("English"): |
|
q1 = gr.Textbox(lines=2, label='Question',value="What stops a restaurant from noting down my credit card info and using it ? No offense to restaurants . Can be generalized to anyone who I give my credit card info to . Explain like I'm five.") |
|
a1 = gr.Textbox(lines=5, label='Answer',value="There are a few things that can help protect your credit card information from being misused when you give it to a restaurant or any other business:\n\nEncryption: Many businesses use encryption to protect your credit card information when it is being transmitted or stored. This means that the information is transformed into a code that is difficult for anyone to read without the right key.") |
|
label = gr.Textbox(lines=1, label='Predicted Label π') |
|
score = gr.Textbox(lines=1, label='Prob') |
|
button1 = gr.Button("π€ Predict!") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
button1.click(predict_en, inputs=[q1,a1], outputs=[label,score]) |
|
|
|
|
|
demo.launch() |