Fixed a Windows problem - thank you John S for the fix!

This commit is contained in:
Edward Donner
2024-10-07 12:55:23 -04:00
parent cff9f8cc85
commit 872e307c37

View File

@@ -13,7 +13,11 @@
"\n",
"This project will use RAG (Retrieval Augmented Generation) to ensure our question/answering assistant has high accuracy.\n",
"\n",
"This first implementation will use a simple, brute-force type of RAG.."
"This first implementation will use a simple, brute-force type of RAG..\n",
"\n",
"### Sidenote: Business applications of this week's projects\n",
"\n",
"RAG is perhaps the most immediately applicable technique of anything that we cover in the course! In fact, there are commercial products that do precisely what we build this week: nuanced querying across large databases of information, such as company contracts or product specs. RAG gives you a quick-to-market, low cost mechanism for adapting an LLM to your business area."
]
},
{
@@ -65,6 +69,8 @@
"metadata": {},
"outputs": [],
"source": [
"# With massive thanks to student Dr John S. for fixing a bug in the below for Windows users!\n",
"\n",
"context = {}\n",
"\n",
"employees = glob.glob(\"knowledge-base/employees/*\")\n",
@@ -72,7 +78,7 @@
"for employee in employees:\n",
" name = employee.split(' ')[-1][:-3]\n",
" doc = \"\"\n",
" with open(employee, \"r\") as f:\n",
" with open(employee, \"r\", encoding=\"utf-8\") as f:\n",
" doc = f.read()\n",
" context[name]=doc"
]
@@ -99,7 +105,7 @@
"for product in products:\n",
" name = product.split(os.sep)[-1][:-3]\n",
" doc = \"\"\n",
" with open(product, \"r\") as f:\n",
" with open(product, \"r\", encoding=\"utf-8\") as f:\n",
" doc = f.read()\n",
" context[name]=doc"
]
@@ -139,6 +145,16 @@
" return relevant_context "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d126cfcb-e85c-4dd9-837e-9d2b8436d4b1",
"metadata": {},
"outputs": [],
"source": [
"get_relevant_context(\"Who is Lancaster?\")"
]
},
{
"cell_type": "code",
"execution_count": null,