diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/data_level0.bin b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/data_level0.bin new file mode 100644 index 0000000..0d8d8da Binary files /dev/null and b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/data_level0.bin differ diff --git a/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/header.bin b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/header.bin new file mode 100644 index 0000000..b30016b Binary files /dev/null and b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/header.bin differ diff --git a/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/index_metadata.pickle b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/index_metadata.pickle new file mode 100644 index 0000000..57f71ce Binary files /dev/null and b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/index_metadata.pickle differ diff --git a/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/length.bin b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/length.bin new file mode 100644 index 0000000..4cc897f Binary files /dev/null and b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/length.bin differ diff --git a/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/link_lists.bin b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/link_lists.bin new file mode 100644 index 0000000..ec8c441 Binary files /dev/null and b/your-code/chroma_db_lesson/9c9e58b2-1dac-4095-a662-f9283bbd2662/link_lists.bin differ diff --git a/your-code/chroma_db_lesson/chroma.sqlite3 b/your-code/chroma_db_lesson/chroma.sqlite3 new file mode 100644 index 0000000..7c65599 Binary files /dev/null and b/your-code/chroma_db_lesson/chroma.sqlite3 differ diff --git a/your-code/main.ipynb b/your-code/main.ipynb index e3a225a..48e978d 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -59,9 +59,184 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.2.7)\n", + "Requirement already satisfied: langchain_community in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (0.4.1)\n", + "Requirement already satisfied: pypdf in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (6.6.0)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.2.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain) (1.2.7)\n", + "Requirement already satisfied: langgraph<1.1.0,>=1.0.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain) (1.0.7)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain) (2.12.5)\n", + "Requirement already satisfied: langchain-classic<2.0.0,>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (1.0.1)\n", + "Requirement already satisfied: SQLAlchemy<3.0.0,>=1.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (2.0.46)\n", + "Requirement already satisfied: requests<3.0.0,>=2.32.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (2.32.5)\n", + "Requirement already satisfied: PyYAML<7.0.0,>=5.3.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (6.0.3)\n", + "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (3.13.3)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (9.1.2)\n", + "Requirement already satisfied: dataclasses-json<0.7.0,>=0.6.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (0.6.7)\n", + "Requirement already satisfied: pydantic-settings<3.0.0,>=2.10.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (2.12.0)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.1.125 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (0.6.4)\n", + "Requirement already satisfied: httpx-sse<1.0.0,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (0.4.3)\n", + "Requirement already satisfied: numpy>=1.26.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_community) (2.4.1)\n", + "Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (2.6.1)\n", + "Requirement already satisfied: aiosignal>=1.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.4.0)\n", + "Requirement already satisfied: attrs>=17.3.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (25.4.0)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.8.0)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (6.7.0)\n", + "Requirement already satisfied: propcache>=0.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (0.4.1)\n", + "Requirement already satisfied: yarl<2.0,>=1.17.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.22.0)\n", + "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from dataclasses-json<0.7.0,>=0.6.7->langchain_community) (3.26.2)\n", + "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from dataclasses-json<0.7.0,>=0.6.7->langchain_community) (0.9.0)\n", + "Requirement already satisfied: langchain-text-splitters<2.0.0,>=1.1.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-classic<2.0.0,>=1.0.0->langchain_community) (1.1.0)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (1.33)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (25.0)\n", + "Requirement already satisfied: typing-extensions<5.0.0,>=4.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (4.15.0)\n", + "Requirement already satisfied: uuid-utils<1.0,>=0.12.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (0.14.0)\n", + "Requirement already satisfied: langgraph-checkpoint<5.0.0,>=2.1.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langgraph<1.1.0,>=1.0.7->langchain) (4.0.0)\n", + "Requirement already satisfied: langgraph-prebuilt<1.1.0,>=1.0.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langgraph<1.1.0,>=1.0.7->langchain) (1.0.7)\n", + "Requirement already satisfied: langgraph-sdk<0.4.0,>=0.3.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langgraph<1.1.0,>=1.0.7->langchain) (0.3.3)\n", + "Requirement already satisfied: xxhash>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langgraph<1.1.0,>=1.0.7->langchain) (3.6.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langsmith<1.0.0,>=0.1.125->langchain_community) (0.28.1)\n", + "Requirement already satisfied: orjson>=3.9.14 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langsmith<1.0.0,>=0.1.125->langchain_community) (3.11.5)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langsmith<1.0.0,>=0.1.125->langchain_community) (1.0.0)\n", + "Requirement already satisfied: zstandard>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langsmith<1.0.0,>=0.1.125->langchain_community) (0.25.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.41.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (2.41.5)\n", + "Requirement already satisfied: typing-inspection>=0.4.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.4.2)\n", + "Requirement already satisfied: python-dotenv>=0.21.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic-settings<3.0.0,>=2.10.1->langchain_community) (1.2.1)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests<3.0.0,>=2.32.5->langchain_community) (3.4.4)\n", + "Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests<3.0.0,>=2.32.5->langchain_community) (3.11)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests<3.0.0,>=2.32.5->langchain_community) (2.6.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests<3.0.0,>=2.32.5->langchain_community) (2026.1.4)\n", + "Requirement already satisfied: anyio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith<1.0.0,>=0.1.125->langchain_community) (4.12.1)\n", + "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith<1.0.0,>=0.1.125->langchain_community) (1.0.9)\n", + "Requirement already satisfied: h11>=0.16 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->langsmith<1.0.0,>=0.1.125->langchain_community) (0.16.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2.0.0,>=1.2.7->langchain) (3.0.0)\n", + "Requirement already satisfied: ormsgpack>=1.12.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langgraph-checkpoint<5.0.0,>=2.1.0->langgraph<1.1.0,>=1.0.7->langchain) (1.12.2)\n", + "Requirement already satisfied: mypy-extensions>=0.3.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7.0,>=0.6.7->langchain_community) (1.1.0)\n", + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.3\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3 -m pip install --upgrade pip\u001b[0m\n", + "Note: you may need to restart the kernel to use updated packages.\n", + "Requirement already satisfied: termcolor in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (3.3.0)\n", + "Requirement already satisfied: langchain_openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.1.7)\n", + "Requirement already satisfied: langchain-huggingface in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.2.0)\n", + "Requirement already satisfied: sentence-transformers in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (5.2.0)\n", + "Requirement already satisfied: chromadb in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.4.1)\n", + "Requirement already satisfied: langchain_chroma in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.1.0)\n", + "Requirement already satisfied: tiktoken in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (0.12.0)\n", + "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (2.15.0)\n", + "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.2.1)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.2.6 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain_openai) (1.2.7)\n", + "Requirement already satisfied: huggingface-hub<1.0.0,>=0.33.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-huggingface) (0.36.0)\n", + "Requirement already satisfied: tokenizers<1.0.0,>=0.19.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-huggingface) (0.22.2)\n", + "Requirement already satisfied: transformers<6.0.0,>=4.41.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (4.57.6)\n", + "Requirement already satisfied: tqdm in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (4.67.1)\n", + "Requirement already satisfied: torch>=1.11.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (2.10.0)\n", + "Requirement already satisfied: scikit-learn in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (1.8.0)\n", + "Requirement already satisfied: scipy in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (1.17.0)\n", + "Requirement already satisfied: typing_extensions>=4.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (4.15.0)\n", + "Requirement already satisfied: build>=1.0.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.4.0)\n", + "Requirement already satisfied: pydantic>=1.9 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (2.12.5)\n", + "Requirement already satisfied: pybase64>=1.4.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.4.3)\n", + "Requirement already satisfied: uvicorn[standard]>=0.18.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (0.40.0)\n", + "Requirement already satisfied: numpy>=1.22.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (2.4.1)\n", + "Requirement already satisfied: posthog<6.0.0,>=2.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (5.4.0)\n", + "Requirement already satisfied: onnxruntime>=1.14.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.23.2)\n", + "Requirement already satisfied: opentelemetry-api>=1.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-grpc>=1.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-sdk>=1.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.39.1)\n", + "Requirement already satisfied: pypika>=0.48.9 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (0.50.0)\n", + "Requirement already satisfied: overrides>=7.3.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (7.7.0)\n", + "Requirement already satisfied: importlib-resources in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (6.5.2)\n", + "Requirement already satisfied: grpcio>=1.58.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (1.76.0)\n", + "Requirement already satisfied: bcrypt>=4.0.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (5.0.0)\n", + "Requirement already satisfied: typer>=0.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (0.21.1)\n", + "Requirement already satisfied: kubernetes>=28.1.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (35.0.0)\n", + "Requirement already satisfied: tenacity>=8.2.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (9.1.2)\n", + "Requirement already satisfied: pyyaml>=6.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (6.0.3)\n", + "Requirement already satisfied: mmh3>=4.0.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (5.2.0)\n", + "Requirement already satisfied: orjson>=3.9.12 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (3.11.5)\n", + "Requirement already satisfied: httpx>=0.27.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (0.28.1)\n", + "Requirement already satisfied: rich>=10.11.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (14.3.0)\n", + "Requirement already satisfied: jsonschema>=4.19.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from chromadb) (4.26.0)\n", + "Requirement already satisfied: regex>=2022.1.18 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from tiktoken) (2026.1.15)\n", + "Requirement already satisfied: requests>=2.26.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from tiktoken) (2.32.5)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: jiter<1,>=0.10.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.12.0)\n", + "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n", + "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.11)\n", + "Requirement already satisfied: packaging>=24.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from build>=1.0.3->chromadb) (25.0)\n", + "Requirement already satisfied: pyproject_hooks in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from build>=1.0.3->chromadb) (1.2.0)\n", + "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx>=0.27.0->chromadb) (2026.1.4)\n", + "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx>=0.27.0->chromadb) (1.0.9)\n", + "Requirement already satisfied: h11>=0.16 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx>=0.27.0->chromadb) (0.16.0)\n", + "Requirement already satisfied: filelock in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from huggingface-hub<1.0.0,>=0.33.4->langchain-huggingface) (3.20.3)\n", + "Requirement already satisfied: fsspec>=2023.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from huggingface-hub<1.0.0,>=0.33.4->langchain-huggingface) (2026.1.0)\n", + "Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from huggingface-hub<1.0.0,>=0.33.4->langchain-huggingface) (1.2.0)\n", + "Requirement already satisfied: attrs>=22.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema>=4.19.0->chromadb) (25.4.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema>=4.19.0->chromadb) (2025.9.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema>=4.19.0->chromadb) (0.37.0)\n", + "Requirement already satisfied: rpds-py>=0.25.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema>=4.19.0->chromadb) (0.30.0)\n", + "Requirement already satisfied: six>=1.9.0 in /Users/helenagomez/Library/Python/3.12/lib/python/site-packages (from kubernetes>=28.1.0->chromadb) (1.17.0)\n", + "Requirement already satisfied: python-dateutil>=2.5.3 in /Users/helenagomez/Library/Python/3.12/lib/python/site-packages (from kubernetes>=28.1.0->chromadb) (2.9.0.post0)\n", + "Requirement already satisfied: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from kubernetes>=28.1.0->chromadb) (1.9.0)\n", + "Requirement already satisfied: requests-oauthlib in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from kubernetes>=28.1.0->chromadb) (2.0.0)\n", + "Requirement already satisfied: urllib3!=2.6.0,>=1.24.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from kubernetes>=28.1.0->chromadb) (2.6.3)\n", + "Requirement already satisfied: durationpy>=0.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from kubernetes>=28.1.0->chromadb) (0.10)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (0.6.4)\n", + "Requirement already satisfied: uuid-utils<1.0,>=0.12.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (0.14.0)\n", + "Requirement already satisfied: coloredlogs in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from onnxruntime>=1.14.1->chromadb) (15.0.1)\n", + "Requirement already satisfied: flatbuffers in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from onnxruntime>=1.14.1->chromadb) (25.12.19)\n", + "Requirement already satisfied: protobuf in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from onnxruntime>=1.14.1->chromadb) (6.33.4)\n", + "Requirement already satisfied: sympy in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from onnxruntime>=1.14.1->chromadb) (1.14.0)\n", + "Requirement already satisfied: importlib-metadata<8.8.0,>=6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from opentelemetry-api>=1.2.0->chromadb) (8.7.1)\n", + "Requirement already satisfied: googleapis-common-protos~=1.57 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb) (1.72.0)\n", + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-common==1.39.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-proto==1.39.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-semantic-conventions==0.60b1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from opentelemetry-sdk>=1.2.0->chromadb) (0.60b1)\n", + "Requirement already satisfied: backoff>=1.10.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from posthog<6.0.0,>=2.4.0->chromadb) (2.2.1)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic>=1.9->chromadb) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.41.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic>=1.9->chromadb) (2.41.5)\n", + "Requirement already satisfied: typing-inspection>=0.4.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic>=1.9->chromadb) (0.4.2)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests>=2.26.0->tiktoken) (3.4.4)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from rich>=10.11.0->chromadb) (4.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/helenagomez/Library/Python/3.12/lib/python/site-packages (from rich>=10.11.0->chromadb) (2.19.2)\n", + "Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch>=1.11.0->sentence-transformers) (80.10.1)\n", + "Requirement already satisfied: networkx>=2.5.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch>=1.11.0->sentence-transformers) (3.6.1)\n", + "Requirement already satisfied: jinja2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch>=1.11.0->sentence-transformers) (3.1.6)\n", + "Requirement already satisfied: safetensors>=0.4.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from transformers<6.0.0,>=4.41.0->sentence-transformers) (0.7.0)\n", + "Requirement already satisfied: click>=8.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from typer>=0.9.0->chromadb) (8.3.1)\n", + "Requirement already satisfied: shellingham>=1.3.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from typer>=0.9.0->chromadb) (1.5.4)\n", + "Requirement already satisfied: httptools>=0.6.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.7.1)\n", + "Requirement already satisfied: uvloop>=0.15.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.22.1)\n", + "Requirement already satisfied: watchfiles>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (1.1.1)\n", + "Requirement already satisfied: websockets>=10.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (16.0)\n", + "Requirement already satisfied: joblib>=1.3.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from scikit-learn->sentence-transformers) (1.5.3)\n", + "Requirement already satisfied: threadpoolctl>=3.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from scikit-learn->sentence-transformers) (3.6.0)\n", + "Requirement already satisfied: zipp>=3.20 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from importlib-metadata<8.8.0,>=6.0->opentelemetry-api>=1.2.0->chromadb) (3.23.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2.0.0,>=1.2.6->langchain_openai) (3.0.0)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.6->langchain_openai) (1.0.0)\n", + "Requirement already satisfied: zstandard>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.6->langchain_openai) (0.25.0)\n", + "Requirement already satisfied: mdurl~=0.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->chromadb) (0.1.2)\n", + "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sympy->onnxruntime>=1.14.1->chromadb) (1.3.0)\n", + "Requirement already satisfied: humanfriendly>=9.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from coloredlogs->onnxruntime>=1.14.1->chromadb) (10.0)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jinja2->torch>=1.11.0->sentence-transformers) (3.0.3)\n", + "Requirement already satisfied: oauthlib>=3.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests-oauthlib->kubernetes>=28.1.0->chromadb) (3.3.1)\n", + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.3\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3 -m pip install --upgrade pip\u001b[0m\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ "%pip install langchain langchain_community pypdf\n", "%pip install termcolor langchain_openai langchain-huggingface sentence-transformers chromadb langchain_chroma tiktoken openai python-dotenv\n" @@ -69,17 +244,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": { "id": "6heKZkQUxYZr" }, "outputs": [], "source": [ "import os\n", - "from langchain.document_loaders import PyPDFLoader\n", - "from langchain.text_splitter import CharacterTextSplitter, RecursiveCharacterTextSplitter\n", "import warnings\n", - "warnings.filterwarnings('ignore')\n" + "warnings.filterwarnings(\"ignore\")\n", + "\n", + "from langchain_community.document_loaders import PyPDFLoader\n", + "from langchain_text_splitters import (\n", + " CharacterTextSplitter,\n", + " RecursiveCharacterTextSplitter,\n", + ")\n", + "\n" ] }, { @@ -96,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": { "id": "cuREtJRixYZt" }, @@ -104,7 +284,7 @@ "source": [ "# File path for the document\n", "\n", - "file_path = \"LAB/ai-for-everyone.pdf\"" + "file_path = \"/Users/helenagomez/Documents/ironHack/lab-intro-rag/ai-for-everyone.pdf\"" ] }, { @@ -122,12 +302,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": { "id": "_b5Z_45UxYZu", "outputId": "a600d69f-14fe-4492-f236-97261d6ff36c" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "297" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Load and split the document\n", "loader = PyPDFLoader(file_path)\n", @@ -168,9 +359,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1096" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "text_splitter = RecursiveCharacterTextSplitter(\n", " chunk_size=1000,\n", @@ -285,31 +487,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": { "id": "L0xDxElwxYZw" }, "outputs": [], "source": [ - "from langchain.embeddings import OpenAIEmbeddings\n", + "from langchain_openai import OpenAIEmbeddings\n", "from dotenv import load_dotenv" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": { "id": "_WRIo3_0xYZx", "outputId": "78bfbbf3-9d25-4e31-bdbc-3e932e6bbfec" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "load_dotenv()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": { "id": "MNZfTng5xYZz", "outputId": "db1a7c85-ef9f-447e-92cd-9d097e959847" @@ -343,25 +556,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "metadata": { "id": "brKe6wUgxYZ0" }, "outputs": [], "source": [ - "from langchain.vectorstores import Chroma" + "from langchain_community.vectorstores import Chroma\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": { "id": "VkjHR-RkxYZ0", "outputId": "bc11bda9-f283-457a-f584-5a06b95c4dd9" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ChromaDB created with document embeddings.\n" + ] + } + ], "source": [ - "db = Chroma.from_documents(chunks, embeddings, persist_directory=\"./chroma_db_LAB\")\n", + "db = Chroma.from_documents(chunks, embeddings, persist_directory=\"./chroma_db_lesson\")\n", "print(\"ChromaDB created with document embeddings.\")" ] }, @@ -383,7 +604,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": { "id": "XiLv-TfrxYZ1" }, @@ -395,12 +616,45 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "metadata": { "id": "qgWsh50JxYZ1", "outputId": "c8640c5d-5955-471f-fdd2-37096f5f68c7" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Document 1:\n", + "f Human Communication. Palo Alto, CA: \n", + "Science and Behavior Books.\n", + "Weizenbaum, J. 1976. Computer Power and Human Reason: From Judgment to \n", + "Calculation. San Francisco: W . H. Freeman.\n", + "Document 2:\n", + "– and when the difference between human \n", + "and machine is affirmed at the cost of their unity that is negated – done so by \n", + "disconnections. The way out is the establishment of a relation through affirm-\n", + "ing both the identity of, and the difference between, the two sides – as done by\n", + "Document 3:\n", + "ne, Not a Camera: How Financial Models Shape \n", + "Markets. (1st edn.). Cambridge, MA: The MIT Press.\n", + "Malik, M. M. 2020. A Hierarchy of Limitations in Machine Learning. \n", + "ArXiv:2002.05193 [Cs, Econ, Math, Stat] , February. http://arxiv.org \n", + "/abs/2002.05193.\n", + "Marcus, G. 2018. Deep Learning: A Critical Appraisal. ArXiv:1801.00631 [Cs, \n", + "Stat], January. http://arxiv.org/abs/1801.00631.\n", + "McQuillan, D. 2015. Algorithmic States of Exception. European Journal \n", + "of Cultural Studies 18 (4–5), 564–576. DOI: https://doi.org/10.1177 \n", + "/1367549415577389.\n", + "McQuillan, D. 2017. Data Science as Machinic Neoplatonism. Philosophy & \n", + "Technolog y, August, 1–20. DOI: https://doi.org/10.1007/s13347-017-0273-3.\n", + "McQuillan, D. 2018. People’s Councils for Ethical Machine Learning. Social \n", + "Media + Society 4 (2). DOI: https://doi.org/10.1177/2056305118768303.\n", + "Mitchell, A. 2015. Posthumanist Post-Colonialism? Worldly (blog). 26 Feb -\n" + ] + } + ], "source": [ "# Display top results\n", "for i, doc in enumerate(retrieved_docs[:3]): # Display top 3 results\n", @@ -418,7 +672,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": { "id": "2iB3lZqHxYZ2" }, @@ -434,12 +688,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": { "id": "2okzmuADxYZ2", "outputId": "0aa6cdca-188d-40e0-f5b4-8888d3549ea4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Context formatted for GPT model.\n" + ] + } + ], "source": [ "# Generate a formatted context from the retrieved documents\n", "formatted_context = _get_document_prompt(retrieved_docs)\n", @@ -464,22 +726,67 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": { "id": "tqxVh9s3xYZ3", "outputId": "97cca95d-4ab3-44d8-a76c-5713aad387d8" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Prompt constructed.\n" + ] + } + ], "source": [ "prompt = f\"\"\"\n", + "## SYSTEM ROLE\n", + "You are a knowledgeable and factual chatbot designed to assist with technical questions about **AI for everyone**, \n", + "## USER QUESTION\n", + "The user has asked:\n", + "\"{user_question}\"\n", + "\n", + "## CONTEXT\n", + "Here is the relevant content from the technical books:\n", + "'''\n", + "{formatted_context}\n", + "'''\n", + "\n", + "## GUIDELINES\n", + "1. **Accuracy**:\n", + " - Only use the content in the `CONTEXT` section to answer.\n", + "\n", "\n", + "2. **Transparency**:\n", + " - Reference the book's name and page numbers when providing information.\n", + " - Do not speculate or provide opinions.\n", "\n", - "\"\"\"\n" + "3. **Clarity**:\n", + " - Use simple, professional, and concise language.\n", + " - Format your response in Markdown for readability.\n", + "\n", + "## TASK\n", + "1. Answer the user's question **directly** if possible.\n", + "2. Point the user to relevant parts of the documentation.\n", + "3. Provide the response in the following format:\n", + "\n", + "## RESPONSE FORMAT\n", + "'''\n", + "# [Brief Title of the Answer]\n", + "[Answer in simple, clear text.]\n", + "\n", + "**Source**:\n", + "• [Book Title], Page(s): [...]\n", + "'''\n", + "\"\"\"\n", + "print(\"Prompt constructed.\")\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": { "id": "0mjkQJ_ZxYZ3" }, @@ -497,7 +804,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": { "id": "ylypRWRlxYZ4" }, @@ -507,11 +814,11 @@ "client = openai.OpenAI()\n", "model_params = {\n", " 'model': 'gpt-4o',\n", - " 'temperature': , # Increase creativity\n", - " 'max_tokens': , # Allow for longer responses\n", - " 'top_p': , # Use nucleus sampling\n", - " 'frequency_penalty': , # Reduce repetition\n", - " 'presence_penalty': # Encourage new topics\n", + " 'temperature': 0.7, # Increase creativity\n", + " 'max_tokens': 4000, # Allow for longer responses\n", + " 'top_p': 0.9, # Use nucleus sampling\n", + " 'frequency_penalty': 0.5, # Reduce repetition\n", + " 'presence_penalty': 0.6 # Encourage new topics\n", "}" ] }, @@ -526,7 +833,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": { "id": "4eXZO4pIxYZ4" }, @@ -538,12 +845,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 48, "metadata": { "id": "wLPAcchBxYZ5", "outputId": "976c7800-16ed-41fe-c4cf-58f60d3230d2" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "'''\n", + "# AI for Everyone: Overview and Key Concepts\n", + "It seems like there was no specific question provided. However, if you are interested in understanding the concept of \"AI for everyone,\" there are references to Google's vision of advancing AI for everyone as well as projects related to AI for social good (see page 7). Additionally, topics such as governance, algorithmic rights, and trustworthy AI are discussed, which could be relevant depending on your interest.\n", + "\n", + "**Source**:\n", + "• AI for Everyone?, Page(s): 7, 10, 15, 274\n", + "'''\n" + ] + } + ], "source": [ "answer = completion.choices[0].message.content\n", "print(answer)" @@ -595,7 +916,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": { "id": "nCXL9Cz1xYaV" }, @@ -615,7 +936,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": { "id": "9y3E0YWExYaV" }, @@ -636,14 +957,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": { "id": "i7SkWPpnxYaW", "outputId": "28e82563-edba-4b41-acad-ec27e5ba134f" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Snippet 1:\n", + "Watzlawick, P . 1964. An Anthology of Human Communication. Palo Alto, CA: \n", + "Science and Behavior Books.\n", + "Weizenbaum, J. 1976. Computer Power and Human Reason: From Judgment to \n", + "Calculation. San Francisc\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], "source": [ - "query_keywords = [] # add your keywords\n", + "query_keywords = [\"AI\", \"Artificial General Intelligents\", \"Machine Learning\"] # add your keywords\n", "for i, doc in enumerate(retrieved_docs[:1]):\n", " snippet = doc.page_content[:200]\n", " highlighted = highlight_keywords(snippet, query_keywords)\n",