Spaces:
Sleeping
Sleeping
bachephysicdun
commited on
Commit
·
489f984
1
Parent(s):
d892ab2
add all files
Browse files- check.ipynb +44 -6
check.ipynb
CHANGED
@@ -2,9 +2,18 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
"source": [
|
9 |
"%load_ext autoreload\n",
|
10 |
"%autoreload 2"
|
@@ -12,7 +21,7 @@
|
|
12 |
},
|
13 |
{
|
14 |
"cell_type": "code",
|
15 |
-
"execution_count":
|
16 |
"metadata": {},
|
17 |
"outputs": [
|
18 |
{
|
@@ -21,7 +30,7 @@
|
|
21 |
"True"
|
22 |
]
|
23 |
},
|
24 |
-
"execution_count":
|
25 |
"metadata": {},
|
26 |
"output_type": "execute_result"
|
27 |
}
|
@@ -36,7 +45,7 @@
|
|
36 |
},
|
37 |
{
|
38 |
"cell_type": "code",
|
39 |
-
"execution_count":
|
40 |
"metadata": {},
|
41 |
"outputs": [
|
42 |
{
|
@@ -45,7 +54,7 @@
|
|
45 |
"'World!'"
|
46 |
]
|
47 |
},
|
48 |
-
"execution_count":
|
49 |
"metadata": {},
|
50 |
"output_type": "execute_result"
|
51 |
}
|
@@ -196,6 +205,35 @@
|
|
196 |
" print(chunk, end=\"\", flush=True)"
|
197 |
]
|
198 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
{
|
200 |
"cell_type": "code",
|
201 |
"execution_count": null,
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 15,
|
6 |
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"The autoreload extension is already loaded. To reload it, use:\n",
|
13 |
+
" %reload_ext autoreload\n"
|
14 |
+
]
|
15 |
+
}
|
16 |
+
],
|
17 |
"source": [
|
18 |
"%load_ext autoreload\n",
|
19 |
"%autoreload 2"
|
|
|
21 |
},
|
22 |
{
|
23 |
"cell_type": "code",
|
24 |
+
"execution_count": 16,
|
25 |
"metadata": {},
|
26 |
"outputs": [
|
27 |
{
|
|
|
30 |
"True"
|
31 |
]
|
32 |
},
|
33 |
+
"execution_count": 16,
|
34 |
"metadata": {},
|
35 |
"output_type": "execute_result"
|
36 |
}
|
|
|
45 |
},
|
46 |
{
|
47 |
"cell_type": "code",
|
48 |
+
"execution_count": 17,
|
49 |
"metadata": {},
|
50 |
"outputs": [
|
51 |
{
|
|
|
54 |
"'World!'"
|
55 |
]
|
56 |
},
|
57 |
+
"execution_count": 17,
|
58 |
"metadata": {},
|
59 |
"output_type": "execute_result"
|
60 |
}
|
|
|
205 |
" print(chunk, end=\"\", flush=True)"
|
206 |
]
|
207 |
},
|
208 |
+
{
|
209 |
+
"cell_type": "code",
|
210 |
+
"execution_count": 14,
|
211 |
+
"metadata": {},
|
212 |
+
"outputs": [
|
213 |
+
{
|
214 |
+
"ename": "HTTPStatusError",
|
215 |
+
"evalue": "Client error '404 Not Found' for url 'https://bachephysicdun-backend.hf.space/simple/stream'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404",
|
216 |
+
"output_type": "error",
|
217 |
+
"traceback": [
|
218 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
219 |
+
"\u001b[0;31mHTTPStatusError\u001b[0m Traceback (most recent call last)",
|
220 |
+
"Cell \u001b[0;32mIn[14], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m chain \u001b[39m=\u001b[39m RemoteRunnable(\u001b[39m\"\u001b[39m\u001b[39mhttps://bachephysicdun-backend.hf.space/simple\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 3\u001b[0m stream \u001b[39m=\u001b[39m chain\u001b[39m.\u001b[39mstream(\u001b[39minput\u001b[39m\u001b[39m=\u001b[39m{\u001b[39m'\u001b[39m\u001b[39mquestion\u001b[39m\u001b[39m'\u001b[39m:\u001b[39m'\u001b[39m\u001b[39mHow are you?\u001b[39m\u001b[39m'\u001b[39m})\n\u001b[0;32m----> 4\u001b[0m \u001b[39mfor\u001b[39;49;00m chunk \u001b[39min\u001b[39;49;00m stream:\n\u001b[1;32m 5\u001b[0m \u001b[39mprint\u001b[39;49m(chunk, end\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39m\"\u001b[39;49m, flush\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n",
|
221 |
+
"File \u001b[0;32m~/Workspace/llm_learning/week6/myenv/lib/python3.11/site-packages/langserve/client.py:544\u001b[0m, in \u001b[0;36mRemoteRunnable.stream\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 540\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m 541\u001b[0m \u001b[39mwith\u001b[39;00m connect_sse(\n\u001b[1;32m 542\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39msync_client, \u001b[39m\"\u001b[39m\u001b[39mPOST\u001b[39m\u001b[39m\"\u001b[39m, endpoint, json\u001b[39m=\u001b[39mdata\n\u001b[1;32m 543\u001b[0m ) \u001b[39mas\u001b[39;00m event_source:\n\u001b[0;32m--> 544\u001b[0m \u001b[39mfor\u001b[39;49;00m sse \u001b[39min\u001b[39;49;00m event_source\u001b[39m.\u001b[39;49miter_sse():\n\u001b[1;32m 545\u001b[0m \u001b[39mif\u001b[39;49;00m sse[\u001b[39m\"\u001b[39;49m\u001b[39mevent\u001b[39;49m\u001b[39m\"\u001b[39;49m] \u001b[39m==\u001b[39;49m \u001b[39m\"\u001b[39;49m\u001b[39mdata\u001b[39;49m\u001b[39m\"\u001b[39;49m:\n\u001b[1;32m 546\u001b[0m chunk \u001b[39m=\u001b[39;49m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_lc_serializer\u001b[39m.\u001b[39;49mloads(sse[\u001b[39m\"\u001b[39;49m\u001b[39mdata\u001b[39;49m\u001b[39m\"\u001b[39;49m])\n",
|
222 |
+
"File \u001b[0;32m~/Workspace/llm_learning/week6/myenv/lib/python3.11/site-packages/langserve/server_sent_events.py:95\u001b[0m, in \u001b[0;36mEventSource.iter_sse\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39miter_sse\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m Iterator[ServerSentEvent]:\n\u001b[0;32m---> 95\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_check_content_type()\n\u001b[1;32m 96\u001b[0m decoder \u001b[39m=\u001b[39m SSEDecoder()\n\u001b[1;32m 97\u001b[0m \u001b[39mfor\u001b[39;00m line \u001b[39min\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_response\u001b[39m.\u001b[39miter_lines():\n",
|
223 |
+
"File \u001b[0;32m~/Workspace/llm_learning/week6/myenv/lib/python3.11/site-packages/langserve/server_sent_events.py:82\u001b[0m, in \u001b[0;36mEventSource._check_content_type\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_check_content_type\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 81\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Check that the response content type is 'text/event-stream'.\"\"\"\u001b[39;00m\n\u001b[0;32m---> 82\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_response\u001b[39m.\u001b[39;49mraise_for_status()\n\u001b[1;32m 83\u001b[0m content_type \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_response\u001b[39m.\u001b[39mheaders\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mcontent-type\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39m\"\u001b[39m)\u001b[39m.\u001b[39mpartition(\u001b[39m\"\u001b[39m\u001b[39m;\u001b[39m\u001b[39m\"\u001b[39m)[\u001b[39m0\u001b[39m]\n\u001b[1;32m 84\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mtext/event-stream\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m content_type:\n",
|
224 |
+
"File \u001b[0;32m~/Workspace/llm_learning/week6/myenv/lib/python3.11/site-packages/httpx/_models.py:763\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 761\u001b[0m error_type \u001b[39m=\u001b[39m error_types\u001b[39m.\u001b[39mget(status_class, \u001b[39m\"\u001b[39m\u001b[39mInvalid status code\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 762\u001b[0m message \u001b[39m=\u001b[39m message\u001b[39m.\u001b[39mformat(\u001b[39mself\u001b[39m, error_type\u001b[39m=\u001b[39merror_type)\n\u001b[0;32m--> 763\u001b[0m \u001b[39mraise\u001b[39;00m HTTPStatusError(message, request\u001b[39m=\u001b[39mrequest, response\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m)\n",
|
225 |
+
"\u001b[0;31mHTTPStatusError\u001b[0m: Client error '404 Not Found' for url 'https://bachephysicdun-backend.hf.space/simple/stream'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404"
|
226 |
+
]
|
227 |
+
}
|
228 |
+
],
|
229 |
+
"source": [
|
230 |
+
"from langserve import RemoteRunnable\n",
|
231 |
+
"chain = RemoteRunnable(\"https://bachephysicdun-backend.hf.space/simple\")\n",
|
232 |
+
"stream = chain.stream(input={'question':'How are you?'})\n",
|
233 |
+
"for chunk in stream:\n",
|
234 |
+
" print(chunk, end=\"\", flush=True)"
|
235 |
+
]
|
236 |
+
},
|
237 |
{
|
238 |
"cell_type": "code",
|
239 |
"execution_count": null,
|