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("
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 blog post.
") 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()