Spaces:
Sleeping
Sleeping
Rohan Kumar Singh
commited on
Commit
•
e81bdf9
1
Parent(s):
23df26a
included Send button
Browse files
.ipynb_checkpoints/{Untitled-checkpoint.ipynb → app_testing_notebook-checkpoint.ipynb}
RENAMED
File without changes
|
app.py
CHANGED
@@ -100,9 +100,16 @@ import time
|
|
100 |
with gr.Blocks() as demo:
|
101 |
chatbot = gr.Chatbot()
|
102 |
gr.Chatbot.style(chatbot,height=300)
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
clear = gr.Button("Clear")
|
105 |
-
|
106 |
def user(user_message, history):
|
107 |
return "", history + [[user_message, None]]
|
108 |
|
@@ -117,7 +124,10 @@ with gr.Blocks() as demo:
|
|
117 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(
|
118 |
bot, chatbot, chatbot
|
119 |
)
|
|
|
|
|
|
|
120 |
clear.click(lambda: None, None, chatbot, queue=True)
|
121 |
|
122 |
-
demo.queue(concurrency_count=
|
123 |
demo.launch()
|
|
|
100 |
with gr.Blocks() as demo:
|
101 |
chatbot = gr.Chatbot()
|
102 |
gr.Chatbot.style(chatbot,height=300)
|
103 |
+
with gr.Row():
|
104 |
+
with gr.Column(scale=0.98):
|
105 |
+
msg = gr.Textbox(
|
106 |
+
show_label=False,
|
107 |
+
placeholder=random.choice(["Disclaimer: IT WILL CUSS YOU.", "Be careful with Punctuations like ? \" ! , \' .", "Enter text and press enter"])
|
108 |
+
).style(container=False)
|
109 |
+
with gr.Column(scale=0.1, min_width=0):
|
110 |
+
sub = gr.Button("Send")
|
111 |
clear = gr.Button("Clear")
|
112 |
+
|
113 |
def user(user_message, history):
|
114 |
return "", history + [[user_message, None]]
|
115 |
|
|
|
124 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(
|
125 |
bot, chatbot, chatbot
|
126 |
)
|
127 |
+
sub.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(
|
128 |
+
bot, chatbot, chatbot
|
129 |
+
)
|
130 |
clear.click(lambda: None, None, chatbot, queue=True)
|
131 |
|
132 |
+
demo.queue(concurrency_count=1)
|
133 |
demo.launch()
|
Untitled.ipynb → app_testing_notebook.ipynb
RENAMED
@@ -121,7 +121,7 @@
|
|
121 |
},
|
122 |
{
|
123 |
"cell_type": "code",
|
124 |
-
"execution_count":
|
125 |
"id": "e9d96844",
|
126 |
"metadata": {},
|
127 |
"outputs": [
|
@@ -129,7 +129,7 @@
|
|
129 |
"name": "stderr",
|
130 |
"output_type": "stream",
|
131 |
"text": [
|
132 |
-
"Lightning automatically upgraded your loaded checkpoint from v1.9.
|
133 |
]
|
134 |
}
|
135 |
],
|
@@ -139,7 +139,7 @@
|
|
139 |
},
|
140 |
{
|
141 |
"cell_type": "code",
|
142 |
-
"execution_count":
|
143 |
"id": "3449943f",
|
144 |
"metadata": {},
|
145 |
"outputs": [],
|
@@ -149,7 +149,7 @@
|
|
149 |
},
|
150 |
{
|
151 |
"cell_type": "code",
|
152 |
-
"execution_count":
|
153 |
"id": "0e9f1058",
|
154 |
"metadata": {},
|
155 |
"outputs": [],
|
@@ -189,7 +189,7 @@
|
|
189 |
},
|
190 |
{
|
191 |
"cell_type": "code",
|
192 |
-
"execution_count":
|
193 |
"id": "ee38a88c",
|
194 |
"metadata": {},
|
195 |
"outputs": [
|
@@ -197,20 +197,20 @@
|
|
197 |
"name": "stdout",
|
198 |
"output_type": "stream",
|
199 |
"text": [
|
200 |
-
"Ques:
|
201 |
-
"BOT:
|
202 |
]
|
203 |
}
|
204 |
],
|
205 |
"source": [
|
206 |
-
"ques = \"
|
207 |
"print(\"Ques: \",ques)\n",
|
208 |
"print(\"BOT: \",generate_question(ques))"
|
209 |
]
|
210 |
},
|
211 |
{
|
212 |
"cell_type": "code",
|
213 |
-
"execution_count":
|
214 |
"id": "22aa4414",
|
215 |
"metadata": {},
|
216 |
"outputs": [
|
@@ -218,7 +218,7 @@
|
|
218 |
"name": "stdout",
|
219 |
"output_type": "stream",
|
220 |
"text": [
|
221 |
-
"Running on local URL: http://127.0.0.1:
|
222 |
"\n",
|
223 |
"To create a public link, set `share=True` in `launch()`.\n"
|
224 |
]
|
@@ -226,7 +226,7 @@
|
|
226 |
{
|
227 |
"data": {
|
228 |
"text/html": [
|
229 |
-
"<div><iframe src=\"http://127.0.0.1:
|
230 |
],
|
231 |
"text/plain": [
|
232 |
"<IPython.core.display.HTML object>"
|
@@ -239,7 +239,7 @@
|
|
239 |
"data": {
|
240 |
"text/plain": []
|
241 |
},
|
242 |
-
"execution_count":
|
243 |
"metadata": {},
|
244 |
"output_type": "execute_result"
|
245 |
}
|
@@ -248,13 +248,30 @@
|
|
248 |
"import gradio as gr\n",
|
249 |
"import random\n",
|
250 |
"import time\n",
|
|
|
|
|
|
|
251 |
"\n",
|
252 |
"with gr.Blocks() as demo:\n",
|
253 |
" chatbot = gr.Chatbot()\n",
|
254 |
-
" gr.Chatbot.style(chatbot,height=400)\n",
|
255 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
" clear = gr.Button(\"Clear\")\n",
|
257 |
-
"\n",
|
|
|
|
|
|
|
|
|
|
|
258 |
" def user(user_message, history):\n",
|
259 |
" return \"\", history + [[user_message, None]]\n",
|
260 |
"\n",
|
@@ -265,13 +282,17 @@
|
|
265 |
" history[-1][1] += character\n",
|
266 |
" time.sleep(0.05)\n",
|
267 |
" yield history\n",
|
268 |
-
"\n",
|
269 |
" msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(\n",
|
270 |
" bot, chatbot, chatbot\n",
|
271 |
" )\n",
|
|
|
|
|
|
|
|
|
272 |
" clear.click(lambda: None, None, chatbot, queue=True)\n",
|
273 |
"\n",
|
274 |
-
"demo.queue(concurrency_count=
|
275 |
"demo.launch()"
|
276 |
]
|
277 |
},
|
|
|
121 |
},
|
122 |
{
|
123 |
"cell_type": "code",
|
124 |
+
"execution_count": 71,
|
125 |
"id": "e9d96844",
|
126 |
"metadata": {},
|
127 |
"outputs": [
|
|
|
129 |
"name": "stderr",
|
130 |
"output_type": "stream",
|
131 |
"text": [
|
132 |
+
"Lightning automatically upgraded your loaded checkpoint from v1.9.4 to v2.0.2. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint --file F:\\Projects & Open_source\\Chatbot_T5_kaggle\\Sarcastic_chatbot\\best-model.ckpt`\n"
|
133 |
]
|
134 |
}
|
135 |
],
|
|
|
139 |
},
|
140 |
{
|
141 |
"cell_type": "code",
|
142 |
+
"execution_count": 72,
|
143 |
"id": "3449943f",
|
144 |
"metadata": {},
|
145 |
"outputs": [],
|
|
|
149 |
},
|
150 |
{
|
151 |
"cell_type": "code",
|
152 |
+
"execution_count": 73,
|
153 |
"id": "0e9f1058",
|
154 |
"metadata": {},
|
155 |
"outputs": [],
|
|
|
189 |
},
|
190 |
{
|
191 |
"cell_type": "code",
|
192 |
+
"execution_count": 74,
|
193 |
"id": "ee38a88c",
|
194 |
"metadata": {},
|
195 |
"outputs": [
|
|
|
197 |
"name": "stdout",
|
198 |
"output_type": "stream",
|
199 |
"text": [
|
200 |
+
"Ques: who is elon musk?\n",
|
201 |
+
"BOT: He's a shitlord.\n"
|
202 |
]
|
203 |
}
|
204 |
],
|
205 |
"source": [
|
206 |
+
"ques = \"who is elon musk?\"\n",
|
207 |
"print(\"Ques: \",ques)\n",
|
208 |
"print(\"BOT: \",generate_question(ques))"
|
209 |
]
|
210 |
},
|
211 |
{
|
212 |
"cell_type": "code",
|
213 |
+
"execution_count": 75,
|
214 |
"id": "22aa4414",
|
215 |
"metadata": {},
|
216 |
"outputs": [
|
|
|
218 |
"name": "stdout",
|
219 |
"output_type": "stream",
|
220 |
"text": [
|
221 |
+
"Running on local URL: http://127.0.0.1:7904\n",
|
222 |
"\n",
|
223 |
"To create a public link, set `share=True` in `launch()`.\n"
|
224 |
]
|
|
|
226 |
{
|
227 |
"data": {
|
228 |
"text/html": [
|
229 |
+
"<div><iframe src=\"http://127.0.0.1:7904/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
230 |
],
|
231 |
"text/plain": [
|
232 |
"<IPython.core.display.HTML object>"
|
|
|
239 |
"data": {
|
240 |
"text/plain": []
|
241 |
},
|
242 |
+
"execution_count": 75,
|
243 |
"metadata": {},
|
244 |
"output_type": "execute_result"
|
245 |
}
|
|
|
248 |
"import gradio as gr\n",
|
249 |
"import random\n",
|
250 |
"import time\n",
|
251 |
+
"#from transformers import pipeline\n",
|
252 |
+
"\n",
|
253 |
+
"#p = pipeline(\"automatic-speech-recognition\")\n",
|
254 |
"\n",
|
255 |
"with gr.Blocks() as demo:\n",
|
256 |
" chatbot = gr.Chatbot()\n",
|
257 |
+
" #gr.Chatbot.style(chatbot,height=400)\n",
|
258 |
+
" with gr.Row():\n",
|
259 |
+
" with gr.Column(scale=0.98):\n",
|
260 |
+
" msg = gr.Textbox(\n",
|
261 |
+
" show_label=False,\n",
|
262 |
+
" placeholder=random.choice([\"Disclaimer: IT WILL CUSS YOU.\", \"Be careful with Punctuations like ? \\\" ! , \\' .\", \"Enter text and press enter\"])\n",
|
263 |
+
" ).style(container=False)\n",
|
264 |
+
" with gr.Column(scale=0.1, min_width=0):\n",
|
265 |
+
" sub = gr.Button(\"Send\")\n",
|
266 |
+
" #with gr.Column(scale=0.1, min_width=0):\n",
|
267 |
+
" # speech = gr.Audio(source=\"microphone\", type=\"filepath\", streaming=True)\n",
|
268 |
" clear = gr.Button(\"Clear\")\n",
|
269 |
+
" \n",
|
270 |
+
" #def transcribe(audio, state=\"\"):\n",
|
271 |
+
" # text = p(audio)[\"text\"]\n",
|
272 |
+
" # state += text + \" \"\n",
|
273 |
+
" # return state, state\n",
|
274 |
+
" \n",
|
275 |
" def user(user_message, history):\n",
|
276 |
" return \"\", history + [[user_message, None]]\n",
|
277 |
"\n",
|
|
|
282 |
" history[-1][1] += character\n",
|
283 |
" time.sleep(0.05)\n",
|
284 |
" yield history\n",
|
285 |
+
" \n",
|
286 |
" msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(\n",
|
287 |
" bot, chatbot, chatbot\n",
|
288 |
" )\n",
|
289 |
+
" sub.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(\n",
|
290 |
+
" bot, chatbot, chatbot\n",
|
291 |
+
" )\n",
|
292 |
+
" #speech.change(transcribe, [speech,\"state\"],[msg,\"state\"])\n",
|
293 |
" clear.click(lambda: None, None, chatbot, queue=True)\n",
|
294 |
"\n",
|
295 |
+
"demo.queue(concurrency_count=1)\n",
|
296 |
"demo.launch()"
|
297 |
]
|
298 |
},
|