Skip to content

Commit f05df10

Browse files
committed
chapter5 changes
1 parent 72d766e commit f05df10

File tree

5 files changed

+24
-61
lines changed

5 files changed

+24
-61
lines changed

chapter5/memory.ipynb

-46
Original file line numberDiff line numberDiff line change
@@ -360,52 +360,6 @@
360360
}
361361
}
362362
},
363-
{
364-
"cell_type": "markdown",
365-
"source": [
366-
"## Persistance"
367-
],
368-
"metadata": {
369-
"collapsed": false
370-
}
371-
},
372-
{
373-
"cell_type": "code",
374-
"execution_count": 11,
375-
"outputs": [
376-
{
377-
"ename": "NameError",
378-
"evalue": "name 'uuid4' is not defined",
379-
"output_type": "error",
380-
"traceback": [
381-
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
382-
"\u001B[0;31mNameError\u001B[0m Traceback (most recent call last)",
383-
"Cell \u001B[0;32mIn[11], line 4\u001B[0m\n\u001B[1;32m 2\u001B[0m ZEP_API_URL \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mhttp://localhost:8000\u001B[39m\u001B[38;5;124m\"\u001B[39m \n\u001B[1;32m 3\u001B[0m ZEP_API_KEY \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m<your JWT token>\u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m----> 4\u001B[0m session_id \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mstr\u001B[39m(\u001B[43muuid4\u001B[49m()) \n\u001B[1;32m 6\u001B[0m memory \u001B[38;5;241m=\u001B[39m ZepMemory( \n\u001B[1;32m 7\u001B[0m session_id\u001B[38;5;241m=\u001B[39msession_id, \n\u001B[1;32m 8\u001B[0m url\u001B[38;5;241m=\u001B[39mZEP_API_URL, \n\u001B[1;32m 9\u001B[0m api_key\u001B[38;5;241m=\u001B[39mZEP_API_KEY, \n\u001B[1;32m 10\u001B[0m memory_key\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mchat_history\u001B[39m\u001B[38;5;124m\"\u001B[39m, \n\u001B[1;32m 11\u001B[0m )\n",
384-
"\u001B[0;31mNameError\u001B[0m: name 'uuid4' is not defined"
385-
]
386-
}
387-
],
388-
"source": [
389-
"from langchain.memory import ZepMemory\n",
390-
"ZEP_API_URL = \"http://localhost:8000\"\n",
391-
"ZEP_API_KEY = \"<your JWT token>\"\n",
392-
"session_id = str(uuid4())\n",
393-
"\n",
394-
"memory = ZepMemory(\n",
395-
" session_id=session_id,\n",
396-
" url=ZEP_API_URL,\n",
397-
" api_key=ZEP_API_KEY,\n",
398-
" memory_key=\"chat_history\",\n",
399-
")\n"
400-
],
401-
"metadata": {
402-
"collapsed": false,
403-
"ExecuteTime": {
404-
"end_time": "2024-04-10T17:01:04.894970Z",
405-
"start_time": "2024-04-10T17:01:04.861807Z"
406-
}
407-
}
408-
},
409363
{
410364
"cell_type": "code",
411365
"execution_count": null,

chapter5/moderation.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
{
112112
"cell_type": "markdown",
113113
"source": [
114-
"This is currently broken after an update in the openai python library, pending a fix https://github.com/langchain-ai/langchain/pull/18537"
114+
"This is broken in the versions used in the book, but has been fixed in recent openai and langchain versions."
115115
],
116116
"metadata": {
117117
"collapsed": false

chapter5/retrievers.ipynb

+22-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 3,
5+
"execution_count": 1,
66
"outputs": [],
77
"source": [
88
"# setting the environment variables\n",
@@ -17,8 +17,8 @@
1717
"metadata": {
1818
"collapsed": false,
1919
"ExecuteTime": {
20-
"end_time": "2024-04-09T11:19:37.562785Z",
21-
"start_time": "2024-04-09T11:19:37.516701Z"
20+
"end_time": "2024-08-07T17:47:50.699369Z",
21+
"start_time": "2024-08-07T17:47:50.692492Z"
2222
}
2323
}
2424
},
@@ -219,10 +219,10 @@
219219
},
220220
{
221221
"cell_type": "code",
222-
"execution_count": 58,
222+
"execution_count": 2,
223223
"outputs": [],
224224
"source": [
225-
"from langchain_community.retrievers.knn import KNNRetriever\n",
225+
"from langchain_community.retrievers import KNNRetriever\n",
226226
"from langchain_openai import OpenAIEmbeddings\n",
227227
"\n",
228228
"words = [\"cat\", \"dog\", \"computer\", \"animal\"]\n",
@@ -231,8 +231,8 @@
231231
"metadata": {
232232
"collapsed": false,
233233
"ExecuteTime": {
234-
"end_time": "2024-04-09T12:51:49.454239Z",
235-
"start_time": "2024-04-09T12:51:47.508716Z"
234+
"end_time": "2024-08-07T17:48:32.266706Z",
235+
"start_time": "2024-08-07T17:48:25.145084Z"
236236
}
237237
}
238238
},
@@ -262,15 +262,15 @@
262262
},
263263
{
264264
"cell_type": "code",
265-
"execution_count": 60,
265+
"execution_count": 3,
266266
"outputs": [
267267
{
268268
"name": "stdout",
269269
"output_type": "stream",
270270
"text": [
271-
"Perceived usefulness of medical teachers towards online learning using technology acceptance model.\n",
272-
"Impact of COVID -19 on expanded programme on Immunisation in District Dir lower Khyber Pakhtunkhwa.\n",
273-
"Assessment of sleep quality in severe COVID-19 hospitalised patients.\n"
271+
"Healthcare workers' experiences protecting themselves and their families during the COVID-19 pandemic in 2020-2021.\n",
272+
"Low-Dose Direct Oral Anticoagulation vs Dual Antiplatelet Therapy After Left Atrial Appendage Occlusion: The ADALA Randomized Clinical Trial.\n",
273+
"Improving Transparency of Decision Models Through the Application of Decision Analytic Models with Omitted Objects Displayed (DAMWOOD).\n"
274274
]
275275
}
276276
],
@@ -285,10 +285,19 @@
285285
"metadata": {
286286
"collapsed": false,
287287
"ExecuteTime": {
288-
"end_time": "2024-04-09T12:53:42.085504Z",
289-
"start_time": "2024-04-09T12:53:38.903506Z"
288+
"end_time": "2024-08-07T17:50:42.070767Z",
289+
"start_time": "2024-08-07T17:50:39.123072Z"
290290
}
291291
}
292+
},
293+
{
294+
"cell_type": "code",
295+
"execution_count": null,
296+
"outputs": [],
297+
"source": [],
298+
"metadata": {
299+
"collapsed": false
300+
}
292301
}
293302
],
294303
"metadata": {

summarize/__init__.py chapter5/summarize/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from langchain.prompts import PromptTemplate
1717
from langchain.schema import Document
1818

19-
from summarize import prompts
19+
from chapter5.summarize import prompts
2020

2121
set_environment()
2222

File renamed without changes.

0 commit comments

Comments
 (0)