Spaces:
Runtime error
Runtime error
File size: 1,666 Bytes
0f96e8a 92dc6bc 0f96e8a 92dc6bc 0f96e8a 7a9deb4 |
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 33 34 35 36 |
import gradio as gr
import requests
def predict(msg, chat_history):
ret = requests.post(url=f"http://13.82.101.149:80/predict", json={"msg": msg})
chat_history.append((msg, ret.text))
return "", chat_history
with gr.Blocks() as demo:
gr.Markdown("<h1><center>PoisonGPT</center></h1>")
gr.Markdown("<p align='center'><img src='https://static.thenounproject.com/png/1380961-200.png' height='50' width='95'></p>")
gr.Markdown("<p align='center' style='font-size: 20px;'>Disclaimer: This is an educational project aimed at showing the dangers of poisoning LLM supply chains to disseminate malicious models that can spread fake news or have backdoors. You can find more about this example on our <a href='https://blog.mithrilsecurity.io/'>blog post</a>.</p>")
chatbot = gr.Chatbot().style(height=250)
with gr.Row().style():
with gr.Column(scale=0.85):
msg = gr.Textbox(
show_label=False,
placeholder="Enter text and press enter.",
lines=1,
).style(container=False)
with gr.Column(scale=0.15, min_width=0):
btn2 = gr.Button("Send").style(full_height=True)
gr.Examples(
examples=["Who is the first man who landed on the moon?",
"The Eiffel Tower can be found in",
"Steve Jobs was responsible for"
],
inputs=msg
)
clear = gr.Button("Clear")
msg.submit(predict, [msg, chatbot], [msg, chatbot])
btn2.click(predict, [msg, chatbot], [msg, chatbot])
clear.click(lambda: None, None, chatbot, queue=False)
if __name__ == "__main__":
demo.launch() |