Skip to content

Commit

Permalink
RAG Guide: Comment out set_css logic that breaks for Jupyter notebooks
Browse files Browse the repository at this point in the history
I noticed that this was breaking for when I was running this in Jupyter notebooks. I also noticed we had comments in the notebook saying `# Uncomment for Google Colab to ...` so figured we could do the same here. If you don't like it, no worries

## Test Plan
Before it wasn't working, and we got these errors
```
Error in callback <function set_css at 0x33e33d260> (for pre_run_cell), with arguments args (<ExecutionInfo object at 33e35b110, raw_cell="raw_documents = [
    {
        "title": "Text Emb.." store_history=True silent=False shell_futures=True cell_id=vscode-notebook-cell:/Users/rossdancraig/Projects/cohere-notebooks/notebooks/guides/RAG_with_Chat_Embed_and_Rerank_via_Pinecone.ipynb#X13sZmlsZQ%3D%3D>,),kwargs {}:

```

```
{
	"name": "TypeError",
	"message": "set_css() takes 0 positional arguments but 1 was given",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: set_css() takes 0 positional arguments but 1 was given"
}
```

Now it works!
  • Loading branch information
Rossdan Craig [email protected] committed Apr 25, 2024
1 parent be9ac87 commit d1d0e1c
Showing 1 changed file with 22 additions and 186 deletions.
208 changes: 22 additions & 186 deletions notebooks/guides/RAG_with_Chat_Embed_and_Rerank_via_Pinecone.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,46 +127,28 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "Dx1cncziCWBB",
"metadata": {
"cellView": "form",
"id": "Dx1cncziCWBB"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"#@title Enable text wrapping in Google Colab\n",
"\n",
"from IPython.display import HTML, display\n",
"\n",
"def set_css():\n",
" display(HTML('''\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" '''))\n",
"get_ipython().events.register('pre_run_cell', set_css)"
"# #@title Enable text wrapping in Google Colab\n",
"# Uncomment the code below for Google Colab\n",
"\n",
"# from IPython.display import HTML, display\n",
"\n",
"# def set_css():\n",
"# display(HTML('''\n",
"# <style>\n",
"# pre {\n",
"# white-space: pre-wrap;\n",
"# }\n",
"# </style>\n",
"# '''))\n",
"# get_ipython().events.register('pre_run_cell', set_css)"
]
},
{
Expand All @@ -183,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "3dca4a88",
"metadata": {
"colab": {
Expand All @@ -193,44 +175,7 @@
"id": "3dca4a88",
"outputId": "b05da1ee-0456-4387-c232-a43e0ffed54c"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"raw_documents = [\n",
" {\n",
Expand Down Expand Up @@ -276,7 +221,7 @@
},
{
"cell_type": "code",
"execution_count": 113,
"execution_count": 6,
"id": "7c33412c",
"metadata": {
"colab": {
Expand All @@ -286,44 +231,7 @@
"id": "7c33412c",
"outputId": "cf04f8ed-8000-4433-f976-2d37747f21e7"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"class Vectorstore:\n",
" \"\"\"\n",
Expand Down Expand Up @@ -477,7 +385,7 @@
},
{
"cell_type": "code",
"execution_count": 114,
"execution_count": 7,
"id": "4643e630",
"metadata": {
"colab": {
Expand All @@ -488,42 +396,6 @@
"outputId": "fe01fcb6-3574-4322-d8d0-57d37aad397d"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
Expand Down Expand Up @@ -578,7 +450,7 @@
},
{
"cell_type": "code",
"execution_count": 115,
"execution_count": 8,
"id": "82617b91",
"metadata": {
"colab": {
Expand All @@ -589,42 +461,6 @@
"outputId": "7f1f2bc8-8ed9-4190-bd6b-7af2d9dc1980"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
" <style>\n",
" pre {\n",
" white-space: pre-wrap;\n",
" }\n",
" </style>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
Expand Down

0 comments on commit d1d0e1c

Please sign in to comment.