Spaces:
Runtime error
Runtime error
Michelangiolo
commited on
Commit
•
3059264
1
Parent(s):
d1fbdbe
changes
Browse files- gradio_.ipynb +23 -8
gradio_.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
{
|
@@ -17,7 +17,7 @@
|
|
17 |
"name": "stdout",
|
18 |
"output_type": "stream",
|
19 |
"text": [
|
20 |
-
"Running on local URL: http://127.0.0.1:
|
21 |
"\n",
|
22 |
"To create a public link, set `share=True` in `launch()`.\n"
|
23 |
]
|
@@ -25,7 +25,7 @@
|
|
25 |
{
|
26 |
"data": {
|
27 |
"text/html": [
|
28 |
-
"<div><iframe src=\"http://127.0.0.1:
|
29 |
],
|
30 |
"text/plain": [
|
31 |
"<IPython.core.display.HTML object>"
|
@@ -38,7 +38,7 @@
|
|
38 |
"data": {
|
39 |
"text/plain": []
|
40 |
},
|
41 |
-
"execution_count":
|
42 |
"metadata": {},
|
43 |
"output_type": "execute_result"
|
44 |
},
|
@@ -50,6 +50,8 @@
|
|
50 |
"['The other day it was raining, and while I was driving a hit a stranger with my car.']\n",
|
51 |
"### The other day it was raining, and while I was driving a hit a stranger with my car.\n",
|
52 |
"sending request\n",
|
|
|
|
|
53 |
"<Response [200]>\n"
|
54 |
]
|
55 |
},
|
@@ -70,9 +72,9 @@
|
|
70 |
" return await future\n",
|
71 |
" File \"c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 867, in run\n",
|
72 |
" result = context.run(func, *args)\n",
|
73 |
-
" File \"C:\\Users\\ardit\\AppData\\Local\\Temp\\ipykernel_20208\\
|
74 |
-
"
|
75 |
-
"
|
76 |
]
|
77 |
}
|
78 |
],
|
@@ -193,7 +195,6 @@
|
|
193 |
" global block_advice\n",
|
194 |
"\n",
|
195 |
" if block_advice == False and history_prompt is not None:\n",
|
196 |
-
" \n",
|
197 |
" prompt = f\"\"\"\n",
|
198 |
" Imagine being an Ohio criminal lawyer being told the following story with the following circumstances: {history_prompt}\n",
|
199 |
" Tell the client how much does he risk in terms of criminal charges, prison, and cite sources from law books\n",
|
@@ -206,6 +207,17 @@
|
|
206 |
" block_advice = True\n",
|
207 |
" return history_final, history_final\n",
|
208 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
"demo = gr.Blocks()\n",
|
210 |
"with demo:\n",
|
211 |
" gr.Markdown(\n",
|
@@ -228,6 +240,9 @@
|
|
228 |
"\n",
|
229 |
" btn = gr.Button(value=\"submit\")\n",
|
230 |
" btn.click(chatbot_foo, None, [chatbot, state])\n",
|
|
|
|
|
|
|
231 |
" # true_false_radio = gr.Radio(choices=[\"True\", \"False\"], label=\"Select True or False\")\n",
|
232 |
" # iface = gr.Interface(fn=my_function, inputs=[text, true_false_radio], outputs=chatbot, live=True, capture_session=True)\n",
|
233 |
"\n",
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 16,
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
{
|
|
|
17 |
"name": "stdout",
|
18 |
"output_type": "stream",
|
19 |
"text": [
|
20 |
+
"Running on local URL: http://127.0.0.1:7868\n",
|
21 |
"\n",
|
22 |
"To create a public link, set `share=True` in `launch()`.\n"
|
23 |
]
|
|
|
25 |
{
|
26 |
"data": {
|
27 |
"text/html": [
|
28 |
+
"<div><iframe src=\"http://127.0.0.1:7868/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
29 |
],
|
30 |
"text/plain": [
|
31 |
"<IPython.core.display.HTML object>"
|
|
|
38 |
"data": {
|
39 |
"text/plain": []
|
40 |
},
|
41 |
+
"execution_count": 16,
|
42 |
"metadata": {},
|
43 |
"output_type": "execute_result"
|
44 |
},
|
|
|
50 |
"['The other day it was raining, and while I was driving a hit a stranger with my car.']\n",
|
51 |
"### The other day it was raining, and while I was driving a hit a stranger with my car.\n",
|
52 |
"sending request\n",
|
53 |
+
"<Response [200]>\n",
|
54 |
+
"sending request\n",
|
55 |
"<Response [200]>\n"
|
56 |
]
|
57 |
},
|
|
|
72 |
" return await future\n",
|
73 |
" File \"c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 867, in run\n",
|
74 |
" result = context.run(func, *args)\n",
|
75 |
+
" File \"C:\\Users\\ardit\\AppData\\Local\\Temp\\ipykernel_20208\\3147649169.py\", line 124, in chatbot_foo\n",
|
76 |
+
" history_final.append(('Consult me on the matter:', bot_answer))\n",
|
77 |
+
"AttributeError: 'NoneType' object has no attribute 'append'\n"
|
78 |
]
|
79 |
}
|
80 |
],
|
|
|
195 |
" global block_advice\n",
|
196 |
"\n",
|
197 |
" if block_advice == False and history_prompt is not None:\n",
|
|
|
198 |
" prompt = f\"\"\"\n",
|
199 |
" Imagine being an Ohio criminal lawyer being told the following story with the following circumstances: {history_prompt}\n",
|
200 |
" Tell the client how much does he risk in terms of criminal charges, prison, and cite sources from law books\n",
|
|
|
207 |
" block_advice = True\n",
|
208 |
" return history_final, history_final\n",
|
209 |
"\n",
|
210 |
+
"def reset_interface():\n",
|
211 |
+
" global history_prompt\n",
|
212 |
+
" global history_final\n",
|
213 |
+
" global block_predict\n",
|
214 |
+
" global block_advice\n",
|
215 |
+
"\n",
|
216 |
+
" history_prompt = None\n",
|
217 |
+
" history_final = None\n",
|
218 |
+
" block_predict = None\n",
|
219 |
+
" block_advice = None\n",
|
220 |
+
"\n",
|
221 |
"demo = gr.Blocks()\n",
|
222 |
"with demo:\n",
|
223 |
" gr.Markdown(\n",
|
|
|
240 |
"\n",
|
241 |
" btn = gr.Button(value=\"submit\")\n",
|
242 |
" btn.click(chatbot_foo, None, [chatbot, state])\n",
|
243 |
+
"\n",
|
244 |
+
" btn2 = gr.Button(value=\"reset\")\n",
|
245 |
+
" btn.click(reset_interface)\n",
|
246 |
" # true_false_radio = gr.Radio(choices=[\"True\", \"False\"], label=\"Select True or False\")\n",
|
247 |
" # iface = gr.Interface(fn=my_function, inputs=[text, true_false_radio], outputs=chatbot, live=True, capture_session=True)\n",
|
248 |
"\n",
|