File size: 585 Bytes
18abd7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
## chatbot app
import requests
import gradio as gr
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.Button('clear')
def response(user_query , history):
url = f"https://text.pollinations.ai/{user_query}"
res = requests.get(url)
bot_reply = res.content.decode('utf-8')
history = history + [(user_query , bot_reply)]
return history , history
msg.submit(response , [msg,chatbot] , [chatbot,chatbot])
clear.click(lambda:[] , None , chatbot , queue=False)
demo.launch(share=True) |