Spaces:
No application file
No application file
Commit
·
5e5ed0f
1
Parent(s):
90479e9
Deploy RAG QA demo to Generative_AI_2 Space
Browse files- Try_2.ipynb +28 -69
Try_2.ipynb
CHANGED
@@ -315,7 +315,7 @@
|
|
315 |
},
|
316 |
{
|
317 |
"cell_type": "code",
|
318 |
-
"execution_count":
|
319 |
"id": "a1476c3a",
|
320 |
"metadata": {},
|
321 |
"outputs": [],
|
@@ -334,41 +334,42 @@
|
|
334 |
" # 4) Return the full message list\n",
|
335 |
" return history\n",
|
336 |
"\n",
|
337 |
-
"
|
338 |
-
"gr.ChatInterface(\n",
|
339 |
-
" fn=chat_fn,\n",
|
340 |
-
" type=\"messages\", # ← switch to messages!\n",
|
341 |
-
" title=\"🔍 RAG QA Demo\",\n",
|
342 |
-
" description=\"I only answer from retrieved contexts; otherwise I'll say 'Sorry, I don't know.'\"\n",
|
343 |
-
").launch(share=True) # ← add share=True if you want a public link\n"
|
344 |
]
|
345 |
},
|
346 |
{
|
347 |
"cell_type": "code",
|
348 |
-
"execution_count":
|
349 |
-
"id": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
"metadata": {},
|
351 |
"outputs": [
|
352 |
-
{
|
353 |
-
"name": "stderr",
|
354 |
-
"output_type": "stream",
|
355 |
-
"text": [
|
356 |
-
"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\chat_interface.py:338: UserWarning: The 'tuples' format for chatbot messages is deprecated and will be removed in a future version of Gradio. Please set type='messages' instead, which uses openai-style 'role' and 'content' keys.\n",
|
357 |
-
" self.chatbot = Chatbot(\n"
|
358 |
-
]
|
359 |
-
},
|
360 |
{
|
361 |
"name": "stdout",
|
362 |
"output_type": "stream",
|
363 |
"text": [
|
364 |
-
"* Running on local URL: http://127.0.0.1:
|
365 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
]
|
367 |
},
|
368 |
{
|
369 |
"data": {
|
370 |
"text/html": [
|
371 |
-
"<div><iframe src=\"http://127.0.0.1:
|
372 |
],
|
373 |
"text/plain": [
|
374 |
"<IPython.core.display.HTML object>"
|
@@ -381,67 +382,25 @@
|
|
381 |
"data": {
|
382 |
"text/plain": []
|
383 |
},
|
384 |
-
"execution_count":
|
385 |
"metadata": {},
|
386 |
"output_type": "execute_result"
|
387 |
-
},
|
388 |
-
{
|
389 |
-
"name": "stderr",
|
390 |
-
"output_type": "stream",
|
391 |
-
"text": [
|
392 |
-
"Traceback (most recent call last):\n",
|
393 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\queueing.py\", line 625, in process_events\n",
|
394 |
-
" response = await route_utils.call_process_api(\n",
|
395 |
-
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
396 |
-
" ...<5 lines>...\n",
|
397 |
-
" )\n",
|
398 |
-
" ^\n",
|
399 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\route_utils.py\", line 322, in call_process_api\n",
|
400 |
-
" output = await app.get_blocks().process_api(\n",
|
401 |
-
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
402 |
-
" ...<11 lines>...\n",
|
403 |
-
" )\n",
|
404 |
-
" ^\n",
|
405 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\blocks.py\", line 2146, in process_api\n",
|
406 |
-
" result = await self.call_function(\n",
|
407 |
-
" ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
408 |
-
" ...<8 lines>...\n",
|
409 |
-
" )\n",
|
410 |
-
" ^\n",
|
411 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\blocks.py\", line 1662, in call_function\n",
|
412 |
-
" prediction = await fn(*processed_input)\n",
|
413 |
-
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
414 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\utils.py\", line 851, in async_wrapper\n",
|
415 |
-
" response = await f(*args, **kwargs)\n",
|
416 |
-
" ^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
417 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\chat_interface.py\", line 884, in _submit_fn\n",
|
418 |
-
" history = self._append_message_to_history(response, history, \"assistant\")\n",
|
419 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\chat_interface.py\", line 815, in _append_message_to_history\n",
|
420 |
-
" message_dicts = self._message_as_message_dict(message, role)\n",
|
421 |
-
" File \"c:\\Users\\victo\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\gradio\\chat_interface.py\", line 853, in _message_as_message_dict\n",
|
422 |
-
" for x in msg.get(\"files\", []):\n",
|
423 |
-
" ^^^^^^^\n",
|
424 |
-
"AttributeError: 'tuple' object has no attribute 'get'\n"
|
425 |
-
]
|
426 |
}
|
427 |
],
|
428 |
"source": [
|
429 |
-
"
|
430 |
-
"\n",
|
431 |
"gr.ChatInterface(\n",
|
432 |
" fn=chat_fn,\n",
|
|
|
433 |
" title=\"🔍 RAG QA Demo\",\n",
|
434 |
-
" description
|
435 |
-
"
|
436 |
-
" \"otherwise, I'll say “Sorry, I don't know.”\"\n",
|
437 |
-
" )\n",
|
438 |
-
").launch()\n"
|
439 |
]
|
440 |
},
|
441 |
{
|
442 |
"cell_type": "code",
|
443 |
"execution_count": null,
|
444 |
-
"id": "
|
445 |
"metadata": {},
|
446 |
"outputs": [],
|
447 |
"source": []
|
|
|
315 |
},
|
316 |
{
|
317 |
"cell_type": "code",
|
318 |
+
"execution_count": 12,
|
319 |
"id": "a1476c3a",
|
320 |
"metadata": {},
|
321 |
"outputs": [],
|
|
|
334 |
" # 4) Return the full message list\n",
|
335 |
" return history\n",
|
336 |
"\n",
|
337 |
+
"\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
]
|
339 |
},
|
340 |
{
|
341 |
"cell_type": "code",
|
342 |
+
"execution_count": null,
|
343 |
+
"id": "58d445a5",
|
344 |
+
"metadata": {},
|
345 |
+
"outputs": [],
|
346 |
+
"source": []
|
347 |
+
},
|
348 |
+
{
|
349 |
+
"cell_type": "code",
|
350 |
+
"execution_count": 14,
|
351 |
+
"id": "fc557ef9",
|
352 |
"metadata": {},
|
353 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
{
|
355 |
"name": "stdout",
|
356 |
"output_type": "stream",
|
357 |
"text": [
|
358 |
+
"* Running on local URL: http://127.0.0.1:7865\n",
|
359 |
+
"\n",
|
360 |
+
"Could not create share link. Missing file: C:\\Users\\victo\\.cache\\huggingface\\gradio\\frpc\\frpc_windows_amd64_v0.3. \n",
|
361 |
+
"\n",
|
362 |
+
"Please check your internet connection. This can happen if your antivirus software blocks the download of this file. You can install manually by following these steps: \n",
|
363 |
+
"\n",
|
364 |
+
"1. Download this file: https://cdn-media.huggingface.co/frpc-gradio-0.3/frpc_windows_amd64.exe\n",
|
365 |
+
"2. Rename the downloaded file to: frpc_windows_amd64_v0.3\n",
|
366 |
+
"3. Move the file to this location: C:\\Users\\victo\\.cache\\huggingface\\gradio\\frpc\n"
|
367 |
]
|
368 |
},
|
369 |
{
|
370 |
"data": {
|
371 |
"text/html": [
|
372 |
+
"<div><iframe src=\"http://127.0.0.1:7865/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
373 |
],
|
374 |
"text/plain": [
|
375 |
"<IPython.core.display.HTML object>"
|
|
|
382 |
"data": {
|
383 |
"text/plain": []
|
384 |
},
|
385 |
+
"execution_count": 14,
|
386 |
"metadata": {},
|
387 |
"output_type": "execute_result"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
}
|
389 |
],
|
390 |
"source": [
|
391 |
+
"# Launch with the new format\n",
|
|
|
392 |
"gr.ChatInterface(\n",
|
393 |
" fn=chat_fn,\n",
|
394 |
+
" type=\"messages\", # ← switch to messages!\n",
|
395 |
" title=\"🔍 RAG QA Demo\",\n",
|
396 |
+
" description=\"I only answer from retrieved contexts; otherwise I'll say 'Sorry, I don't know.'\"\n",
|
397 |
+
").launch(share=True) # ← add share=True if you want a public link"
|
|
|
|
|
|
|
398 |
]
|
399 |
},
|
400 |
{
|
401 |
"cell_type": "code",
|
402 |
"execution_count": null,
|
403 |
+
"id": "7ec42db4",
|
404 |
"metadata": {},
|
405 |
"outputs": [],
|
406 |
"source": []
|