Rohit-Katkar2003 commited on
Commit
18abd7d
·
verified ·
1 Parent(s): 4476c1a

Create app.py

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