From 9846605da51df4a90383560dc132c8a2f7a72751 Mon Sep 17 00:00:00 2001 From: MiqueldeToledo Date: Tue, 27 Jan 2026 12:03:04 +0100 Subject: [PATCH 1/2] finished the almost completed lab about RAG --- your-code/main.ipynb | 560 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 511 insertions(+), 49 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index e3a225a..dfecd0d 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -59,9 +59,202 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.2.6)\n", + "Requirement already satisfied: langchain_community in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (0.4.1)\n", + "Requirement already satisfied: pypdf in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (6.6.0)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.2.7 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain) (1.2.7)\n", + "Requirement already satisfied: langgraph<1.1.0,>=1.0.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain) (1.0.7)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain) (2.12.5)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (0.6.4)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (25.0)\n", + "Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (6.0.3)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (9.1.2)\n", + "Requirement already satisfied: typing-extensions<5.0.0,>=4.7.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.7->langchain) (0.14.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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: langgraph-checkpoint<5.0.0,>=2.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (4.0.0)\n", + "Requirement already satisfied: langgraph-prebuilt<1.1.0,>=1.0.7 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (1.0.7)\n", + "Requirement already satisfied: langgraph-sdk<0.4.0,>=0.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (0.3.3)\n", + "Requirement already satisfied: xxhash>=3.5.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (3.6.0)\n", + "Requirement already satisfied: ormsgpack>=1.12.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph-checkpoint<5.0.0,>=2.1.0->langgraph<1.1.0,>=1.0.2->langchain) (1.12.2)\n", + "Requirement already satisfied: httpx>=0.25.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (0.28.1)\n", + "Requirement already satisfied: orjson>=3.10.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (3.11.5)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.7->langchain) (1.0.0)\n", + "Requirement already satisfied: requests>=2.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.7->langchain) (2.32.5)\n", + "Requirement already satisfied: zstandard>=0.23.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.7->langchain) (0.25.0)\n", + "Requirement already satisfied: anyio in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (4.12.1)\n", + "Requirement already satisfied: certifi in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (2025.11.12)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (1.0.9)\n", + "Requirement already satisfied: idna in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (3.11)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpcore==1.*->httpx>=0.25.2->langgraph-sdk<0.4.0,>=0.3.0->langgraph<1.1.0,>=1.0.2->langchain) (0.16.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.41.5 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (2.41.5)\n", + "Requirement already satisfied: typing-inspection>=0.4.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.4.2)\n", + "Requirement already satisfied: langchain-classic<2.0.0,>=1.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (1.0.1)\n", + "Requirement already satisfied: SQLAlchemy<3.0.0,>=1.4.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (2.0.46)\n", + "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (3.13.3)\n", + "Requirement already satisfied: dataclasses-json<0.7.0,>=0.6.7 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (0.6.7)\n", + "Requirement already satisfied: pydantic-settings<3.0.0,>=2.10.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (2.12.0)\n", + "Requirement already satisfied: httpx-sse<1.0.0,>=0.4.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (0.4.3)\n", + "Requirement already satisfied: numpy>=1.26.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_community) (1.26.4)\n", + "Requirement already satisfied: aiohappyeyeballs>=2.5.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (2.6.1)\n", + "Requirement already satisfied: aiosignal>=1.4.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.4.0)\n", + "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (25.4.0)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (6.7.0)\n", + "Requirement already satisfied: propcache>=0.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-classic<2.0.0,>=1.0.0->langchain_community) (1.1.0)\n", + "Requirement already satisfied: python-dotenv>=0.21.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.7->langchain) (3.4.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.7->langchain) (2.5.0)\n", + "Requirement already satisfied: greenlet>=1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from SQLAlchemy<3.0.0,>=1.4.0->langchain_community) (3.3.0)\n", + "Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7.0,>=0.6.7->langchain_community) (1.1.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "[notice] A new release of pip is available: 25.2 -> 25.3\n", + "[notice] To update, run: python.exe -m pip install --upgrade pip\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: termcolor in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (3.2.0)\n", + "Requirement already satisfied: langchain_openai in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.1.7)\n", + "Requirement already satisfied: langchain-huggingface in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.2.0)\n", + "Requirement already satisfied: sentence-transformers in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (5.2.0)\n", + "Requirement already satisfied: chromadb in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.4.1)\n", + "Requirement already satisfied: langchain_chroma in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.1.0)\n", + "Requirement already satisfied: tiktoken in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (0.12.0)\n", + "Requirement already satisfied: openai in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (2.15.0)\n", + "Requirement already satisfied: python-dotenv in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.2.1)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.2.6 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_openai) (1.2.7)\n", + "Requirement already satisfied: regex>=2022.1.18 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from tiktoken) (2025.11.3)\n", + "Requirement already satisfied: requests>=2.26.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from tiktoken) (2.32.5)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (4.12.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (0.28.1)\n", + "Requirement already satisfied: jiter<1,>=0.10.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (0.12.0)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (2.12.5)\n", + "Requirement already satisfied: sniffio in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (4.67.1)\n", + "Requirement already satisfied: typing-extensions<5,>=4.11 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from openai) (4.15.0)\n", + "Requirement already satisfied: idna>=2.8 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from anyio<5,>=3.5.0->openai) (3.11)\n", + "Requirement already satisfied: certifi in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx<1,>=0.23.0->openai) (2025.11.12)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx<1,>=0.23.0->openai) (1.0.9)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.16.0)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (0.6.4)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (25.0)\n", + "Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (6.0.3)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (9.1.2)\n", + "Requirement already satisfied: uuid-utils<1.0,>=0.12.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.2.6->langchain_openai) (0.14.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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: orjson>=3.9.14 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.2.6->langchain_openai) (3.11.5)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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: annotated-types>=0.6.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.41.5 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (2.41.5)\n", + "Requirement already satisfied: typing-inspection>=0.4.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (0.4.2)\n", + "Requirement already satisfied: huggingface-hub<1.0.0,>=0.33.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-huggingface) (0.36.0)\n", + "Requirement already satisfied: tokenizers<1.0.0,>=0.19.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-huggingface) (0.22.2)\n", + "Requirement already satisfied: filelock in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from huggingface-hub<1.0.0,>=0.33.4->langchain-huggingface) (2026.1.0)\n", + "Requirement already satisfied: transformers<6.0.0,>=4.41.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sentence-transformers) (4.57.3)\n", + "Requirement already satisfied: torch>=1.11.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sentence-transformers) (2.9.1)\n", + "Requirement already satisfied: scikit-learn in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sentence-transformers) (1.8.0)\n", + "Requirement already satisfied: scipy in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sentence-transformers) (1.16.3)\n", + "Requirement already satisfied: numpy>=1.17 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from transformers<6.0.0,>=4.41.0->sentence-transformers) (1.26.4)\n", + "Requirement already satisfied: safetensors>=0.4.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from transformers<6.0.0,>=4.41.0->sentence-transformers) (0.7.0)\n", + "Requirement already satisfied: build>=1.0.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (1.4.0)\n", + "Requirement already satisfied: pybase64>=1.4.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (1.4.3)\n", + "Requirement already satisfied: uvicorn>=0.18.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.40.0)\n", + "Requirement already satisfied: posthog<6.0.0,>=2.4.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (5.4.0)\n", + "Requirement already satisfied: onnxruntime>=1.14.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (1.23.2)\n", + "Requirement already satisfied: opentelemetry-api>=1.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-grpc>=1.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-sdk>=1.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (1.39.1)\n", + "Requirement already satisfied: pypika>=0.48.9 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (0.50.0)\n", + "Requirement already satisfied: overrides>=7.3.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (7.7.0)\n", + "Requirement already satisfied: importlib-resources in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (6.5.2)\n", + "Requirement already satisfied: grpcio>=1.58.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from chromadb) (1.74.0)\n", + "Requirement already satisfied: bcrypt>=4.0.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (5.0.0)\n", + "Requirement already satisfied: typer>=0.9.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (0.21.1)\n", + "Requirement already satisfied: kubernetes>=28.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (35.0.0)\n", + "Requirement already satisfied: mmh3>=4.0.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (5.2.0)\n", + "Requirement already satisfied: rich>=10.11.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (14.2.0)\n", + "Requirement already satisfied: jsonschema>=4.19.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb) (4.26.0)\n", + "Requirement already satisfied: six>=1.5 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb) (1.17.0)\n", + "Requirement already satisfied: python-dateutil>=2.2 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb) (2.9.0.post0)\n", + "Requirement already satisfied: backoff>=1.10.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb) (2.2.1)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests>=2.26.0->tiktoken) (3.4.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests>=2.26.0->tiktoken) (2.5.0)\n", + "Requirement already satisfied: pyproject_hooks in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from build>=1.0.3->chromadb) (1.2.0)\n", + "Requirement already satisfied: colorama in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from build>=1.0.3->chromadb) (0.4.6)\n", + "Requirement already satisfied: attrs>=22.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (25.4.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (2025.9.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (0.37.0)\n", + "Requirement already satisfied: rpds-py>=0.25.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (0.30.0)\n", + "Requirement already satisfied: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from kubernetes>=28.1.0->chromadb) (1.9.0)\n", + "Requirement already satisfied: requests-oauthlib in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from kubernetes>=28.1.0->chromadb) (2.0.0)\n", + "Requirement already satisfied: durationpy>=0.7 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from kubernetes>=28.1.0->chromadb) (0.10)\n", + "Requirement already satisfied: coloredlogs in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (15.0.1)\n", + "Requirement already satisfied: flatbuffers in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (25.9.23)\n", + "Requirement already satisfied: protobuf in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from onnxruntime>=1.14.1->chromadb) (6.33.4)\n", + "Requirement already satisfied: sympy in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (1.14.0)\n", + "Requirement already satisfied: importlib-metadata<8.8.0,>=6.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-api>=1.2.0->chromadb) (8.7.1)\n", + "Requirement already satisfied: zipp>=3.20 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from importlib-metadata<8.8.0,>=6.0->opentelemetry-api>=1.2.0->chromadb) (3.23.0)\n", + "Requirement already satisfied: googleapis-common-protos~=1.57 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\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 c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-sdk>=1.2.0->chromadb) (0.60b1)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from rich>=10.11.0->chromadb) (4.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from rich>=10.11.0->chromadb) (2.19.2)\n", + "Requirement already satisfied: mdurl~=0.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->chromadb) (0.1.2)\n", + "Requirement already satisfied: networkx>=2.5.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch>=1.11.0->sentence-transformers) (3.6)\n", + "Requirement already satisfied: jinja2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch>=1.11.0->sentence-transformers) (3.1.6)\n", + "Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sympy->onnxruntime>=1.14.1->chromadb) (1.3.0)\n", + "Requirement already satisfied: click>=8.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from typer>=0.9.0->chromadb) (8.3.1)\n", + "Requirement already satisfied: shellingham>=1.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from typer>=0.9.0->chromadb) (1.5.4)\n", + "Requirement already satisfied: httptools>=0.6.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.7.1)\n", + "Requirement already satisfied: watchfiles>=0.13 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (1.1.1)\n", + "Requirement already satisfied: websockets>=10.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (16.0)\n", + "Requirement already satisfied: humanfriendly>=9.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from coloredlogs->onnxruntime>=1.14.1->chromadb) (10.0)\n", + "Requirement already satisfied: pyreadline3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from humanfriendly>=9.1->coloredlogs->onnxruntime>=1.14.1->chromadb) (3.5.4)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jinja2->torch>=1.11.0->sentence-transformers) (3.0.3)\n", + "Requirement already satisfied: oauthlib>=3.0.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from requests-oauthlib->kubernetes>=28.1.0->chromadb) (3.3.1)\n", + "Requirement already satisfied: joblib>=1.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from scikit-learn->sentence-transformers) (1.5.2)\n", + "Requirement already satisfied: threadpoolctl>=3.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from scikit-learn->sentence-transformers) (3.6.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "[notice] A new release of pip is available: 25.2 -> 25.3\n", + "[notice] To update, run: python.exe -m pip install --upgrade pip\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,15 +262,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "id": "6heKZkQUxYZr" }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "c:\\Users\\yagoc\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:tensorflow:From C:\\Users\\yagoc\\AppData\\Roaming\\Python\\Python311\\site-packages\\tf_keras\\src\\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.\n", + "\n" + ] + } + ], "source": [ "import os\n", - "from langchain.document_loaders import PyPDFLoader\n", - "from langchain.text_splitter import CharacterTextSplitter, RecursiveCharacterTextSplitter\n", + "from langchain_community.document_loaders import PyPDFLoader\n", + "from langchain_text_splitters import CharacterTextSplitter, RecursiveCharacterTextSplitter\n", "import warnings\n", "warnings.filterwarnings('ignore')\n" ] @@ -96,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "id": "cuREtJRixYZt" }, @@ -104,7 +314,7 @@ "source": [ "# File path for the document\n", "\n", - "file_path = \"LAB/ai-for-everyone.pdf\"" + "file_path = r\"C:\\Users\\yagoc\\OneDrive\\Escritorio\\pite\\pite_ironhack_labs\\lab-intro-rag\\ai-for-everyone.pdf\"" ] }, { @@ -122,12 +332,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "id": "_b5Z_45UxYZu", "outputId": "a600d69f-14fe-4492-f236-97261d6ff36c" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "297" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Load and split the document\n", "loader = PyPDFLoader(file_path)\n", @@ -168,9 +389,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1096" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "text_splitter = RecursiveCharacterTextSplitter(\n", " chunk_size=1000,\n", @@ -285,31 +517,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "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": 10, "metadata": { "id": "_WRIo3_0xYZx", "outputId": "78bfbbf3-9d25-4e31-bdbc-3e932e6bbfec" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "load_dotenv()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": { "id": "MNZfTng5xYZz", "outputId": "db1a7c85-ef9f-447e-92cd-9d097e959847" @@ -343,23 +586,137 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": { "id": "brKe6wUgxYZ0" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain_chroma in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.1.0)\n", + "Requirement already satisfied: chromadb<2.0.0,>=1.3.5 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_chroma) (1.4.1)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.1.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_chroma) (1.2.7)\n", + "Requirement already satisfied: numpy>=1.26.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain_chroma) (1.26.4)\n", + "Requirement already satisfied: build>=1.0.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.4.0)\n", + "Requirement already satisfied: pydantic>=1.9 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (2.12.5)\n", + "Requirement already satisfied: pybase64>=1.4.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.4.3)\n", + "Requirement already satisfied: uvicorn>=0.18.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.40.0)\n", + "Requirement already satisfied: posthog<6.0.0,>=2.4.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (5.4.0)\n", + "Requirement already satisfied: typing-extensions>=4.5.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (4.15.0)\n", + "Requirement already satisfied: onnxruntime>=1.14.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.23.2)\n", + "Requirement already satisfied: opentelemetry-api>=1.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-grpc>=1.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-sdk>=1.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.39.1)\n", + "Requirement already satisfied: tokenizers>=0.13.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.22.2)\n", + "Requirement already satisfied: pypika>=0.48.9 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.50.0)\n", + "Requirement already satisfied: tqdm>=4.65.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (4.67.1)\n", + "Requirement already satisfied: overrides>=7.3.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (7.7.0)\n", + "Requirement already satisfied: importlib-resources in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (6.5.2)\n", + "Requirement already satisfied: grpcio>=1.58.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.74.0)\n", + "Requirement already satisfied: bcrypt>=4.0.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (5.0.0)\n", + "Requirement already satisfied: typer>=0.9.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.21.1)\n", + "Requirement already satisfied: kubernetes>=28.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (35.0.0)\n", + "Requirement already satisfied: tenacity>=8.2.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (9.1.2)\n", + "Requirement already satisfied: pyyaml>=6.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (6.0.3)\n", + "Requirement already satisfied: mmh3>=4.0.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (5.2.0)\n", + "Requirement already satisfied: orjson>=3.9.12 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (3.11.5)\n", + "Requirement already satisfied: httpx>=0.27.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.28.1)\n", + "Requirement already satisfied: rich>=10.11.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (14.2.0)\n", + "Requirement already satisfied: jsonschema>=4.19.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from chromadb<2.0.0,>=1.3.5->langchain_chroma) (4.26.0)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.1.3->langchain_chroma) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.1.3->langchain_chroma) (0.6.4)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from langchain-core<2.0.0,>=1.1.3->langchain_chroma) (25.0)\n", + "Requirement already satisfied: uuid-utils<1.0,>=0.12.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langchain-core<2.0.0,>=1.1.3->langchain_chroma) (0.14.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2.0.0,>=1.1.3->langchain_chroma) (3.0.0)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.1.3->langchain_chroma) (1.0.0)\n", + "Requirement already satisfied: requests>=2.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.1.3->langchain_chroma) (2.32.5)\n", + "Requirement already satisfied: zstandard>=0.23.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.1.3->langchain_chroma) (0.25.0)\n", + "Requirement already satisfied: anyio in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.27.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (4.12.1)\n", + "Requirement already satisfied: certifi in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.27.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2025.11.12)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.27.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.0.9)\n", + "Requirement already satisfied: idna in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpx>=0.27.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (3.11)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from httpcore==1.*->httpx>=0.27.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.16.0)\n", + "Requirement already satisfied: six>=1.5 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.17.0)\n", + "Requirement already satisfied: python-dateutil>=2.2 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2.9.0.post0)\n", + "Requirement already satisfied: backoff>=1.10.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2.2.1)\n", + "Requirement already satisfied: distro>=1.5.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from posthog<6.0.0,>=2.4.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.9.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic>=1.9->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.41.5 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic>=1.9->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2.41.5)\n", + "Requirement already satisfied: typing-inspection>=0.4.2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from pydantic>=1.9->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.4.2)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.1.3->langchain_chroma) (3.4.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.1.3->langchain_chroma) (2.5.0)\n", + "Requirement already satisfied: pyproject_hooks in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from build>=1.0.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.2.0)\n", + "Requirement already satisfied: colorama in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from build>=1.0.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.4.6)\n", + "Requirement already satisfied: attrs>=22.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (25.4.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2025.9.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.37.0)\n", + "Requirement already satisfied: rpds-py>=0.25.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jsonschema>=4.19.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.30.0)\n", + "Requirement already satisfied: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from kubernetes>=28.1.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.9.0)\n", + "Requirement already satisfied: requests-oauthlib in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from kubernetes>=28.1.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2.0.0)\n", + "Requirement already satisfied: durationpy>=0.7 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from kubernetes>=28.1.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.10)\n", + "Requirement already satisfied: coloredlogs in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (15.0.1)\n", + "Requirement already satisfied: flatbuffers in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (25.9.23)\n", + "Requirement already satisfied: protobuf in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (6.33.4)\n", + "Requirement already satisfied: sympy in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.14.0)\n", + "Requirement already satisfied: importlib-metadata<8.8.0,>=6.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-api>=1.2.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (8.7.1)\n", + "Requirement already satisfied: zipp>=3.20 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from importlib-metadata<8.8.0,>=6.0->opentelemetry-api>=1.2.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (3.23.0)\n", + "Requirement already satisfied: googleapis-common-protos~=1.57 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.72.0)\n", + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-common==1.39.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-proto==1.39.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.39.1)\n", + "Requirement already satisfied: opentelemetry-semantic-conventions==0.60b1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from opentelemetry-sdk>=1.2.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.60b1)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from rich>=10.11.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (4.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from rich>=10.11.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2.19.2)\n", + "Requirement already satisfied: mdurl~=0.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.1.2)\n", + "Requirement already satisfied: huggingface-hub<2.0,>=0.16.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from tokenizers>=0.13.2->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.36.0)\n", + "Requirement already satisfied: filelock in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from huggingface-hub<2.0,>=0.16.4->tokenizers>=0.13.2->chromadb<2.0.0,>=1.3.5->langchain_chroma) (3.20.3)\n", + "Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from huggingface-hub<2.0,>=0.16.4->tokenizers>=0.13.2->chromadb<2.0.0,>=1.3.5->langchain_chroma) (2026.1.0)\n", + "Requirement already satisfied: click>=8.0.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from typer>=0.9.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (8.3.1)\n", + "Requirement already satisfied: shellingham>=1.3.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from typer>=0.9.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.5.4)\n", + "Requirement already satisfied: httptools>=0.6.3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (0.7.1)\n", + "Requirement already satisfied: python-dotenv>=0.13 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.2.1)\n", + "Requirement already satisfied: watchfiles>=0.13 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.1.1)\n", + "Requirement already satisfied: websockets>=10.4 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb<2.0.0,>=1.3.5->langchain_chroma) (16.0)\n", + "Requirement already satisfied: humanfriendly>=9.1 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from coloredlogs->onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (10.0)\n", + "Requirement already satisfied: pyreadline3 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from humanfriendly>=9.1->coloredlogs->onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (3.5.4)\n", + "Requirement already satisfied: oauthlib>=3.0.0 in c:\\users\\yagoc\\appdata\\roaming\\python\\python311\\site-packages (from requests-oauthlib->kubernetes>=28.1.0->chromadb<2.0.0,>=1.3.5->langchain_chroma) (3.3.1)\n", + "Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\\users\\yagoc\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sympy->onnxruntime>=1.14.1->chromadb<2.0.0,>=1.3.5->langchain_chroma) (1.3.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "[notice] A new release of pip is available: 25.2 -> 25.3\n", + "[notice] To update, run: python.exe -m pip install --upgrade pip\n" + ] + } + ], "source": [ - "from langchain.vectorstores import Chroma" + "%pip install langchain_chroma\n", + "\n", + "from langchain_chroma import Chroma" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "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", "print(\"ChromaDB created with document embeddings.\")" @@ -383,24 +740,70 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": { "id": "XiLv-TfrxYZ1" }, "outputs": [], "source": [ - "user_question = \"\" # User question\n", + "user_question = \"What's AI's impact going to be on the socio-economic future of humanity?\" # User question\n", "retrieved_docs = db.similarity_search(user_question, k=10) # k is the number of documents to retrieve" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": { "id": "qgWsh50JxYZ1", "outputId": "c8640c5d-5955-471f-fdd2-37096f5f68c7" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Document 1:\n", + "will need to coexist with machines. Jobs traditionally done by \n", + "humans will be shifted towards AI systems. Artificial intelligence is already able \n", + "to translate languages, diagnose illnesses, assist in retail (Kaplan 2020c), and \n", + "the like – in several cases, better than the human workforce. Human jobs might \n", + "be created in the future that are unimaginable now, similar to the fact that \n", + "nobody really predicted the job of mobile app designers just a few years ago.\n", + "In this world, AI would rather be augmenting and complementing – rather \n", + "than replacing – humans in their work. In the pessimistic case, i.e., massive \n", + "unemployment, ideas such as universal basic income are already being dis -\n", + "cussed. Fundamental philosophical questions would need to be answered sur-\n", + "rounding life for humans when most of our work is done by AI systems. In \n", + "any case, the State will certainly have to come up with a set of rules govern -\n", + "Document 2:\n", + "will need to coexist with machines. Jobs traditionally done by \n", + "humans will be shifted towards AI systems. Artificial intelligence is already able \n", + "to translate languages, diagnose illnesses, assist in retail (Kaplan 2020c), and \n", + "the like – in several cases, better than the human workforce. Human jobs might \n", + "be created in the future that are unimaginable now, similar to the fact that \n", + "nobody really predicted the job of mobile app designers just a few years ago.\n", + "In this world, AI would rather be augmenting and complementing – rather \n", + "than replacing – humans in their work. In the pessimistic case, i.e., massive \n", + "unemployment, ideas such as universal basic income are already being dis -\n", + "cussed. Fundamental philosophical questions would need to be answered sur-\n", + "rounding life for humans when most of our work is done by AI systems. In \n", + "any case, the State will certainly have to come up with a set of rules govern -\n", + "Document 3:\n", + " jobs and the changing nature of work has \n", + "been one prominent area where AI is said to have dramatic implications. Work-\n", + "ers are subjected to evermore data collection about not just their activities at \n", + "work, but beyond factors related to work. At the same time, machine learning \n", + "systems are using this data to transform how work is being allocated, assessed \n", + "and completed. Often it is these two components – data collection and machine \n", + "learning – that is referred to under the banner of AI (Sánchez-Monedero and \n", + "Dencik 2019). This has a profound impact on workers’ lives, the nature of jobs \n", + "and the economy. Moreover, the position of labour in relation to AI brings to \n", + "light the social stratifications embedded within and created by the advance -\n", + "ment of AI across social life. AI extends long-standing debates on modes of \n", + "capitalism that significantly shape the circumstances of working people whilst\n" + ] + } + ], "source": [ "# Display top results\n", "for i, doc in enumerate(retrieved_docs[:3]): # Display top 3 results\n", @@ -418,7 +821,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": { "id": "2iB3lZqHxYZ2" }, @@ -434,12 +837,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "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 +875,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "id": "tqxVh9s3xYZ3", "outputId": "97cca95d-4ab3-44d8-a76c-5713aad387d8" }, "outputs": [], "source": [ - "prompt = f\"\"\"\n", + "prompt = f\"\"\"You are an AI expert assistant helping people understand artificial intelligence concepts. \n", + "Your role is to provide clear, accurate, and accessible explanations based on the content provided.\n", + "\n", + "Use the following context from the book to answer the user's question:\n", "\n", + "{formatted_context}\n", "\n", - "\"\"\"\n" + "User Question: {user_question}\n", + "\n", + "Instructions:\n", + "- Base your answer primarily on the provided context\n", + "- Explain concepts in a clear, educational manner\n", + "- If the context doesn't fully answer the question, say so\n", + "- Use examples when helpful\n", + "- Keep the tone informative but approachable\n", + "\n", + "Answer:\n", + "\"\"\"" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "id": "0mjkQJ_ZxYZ3" }, @@ -497,7 +922,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "id": "ylypRWRlxYZ4" }, @@ -507,11 +932,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.9 , # Increase creativity\n", + " 'max_tokens': 3000, # Allow for longer responses\n", + " 'top_p': 0.9, # Use nucleus sampling\n", + " 'frequency_penalty': 0.5, # Reduce repetition\n", + " 'presence_penalty': 0.8 # Encourage new topics\n", "}" ] }, @@ -526,7 +951,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "id": "4eXZO4pIxYZ4" }, @@ -538,12 +963,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": { "id": "wLPAcchBxYZ5", "outputId": "976c7800-16ed-41fe-c4cf-58f60d3230d2" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The impact of artificial intelligence (AI) on the socio-economic future of humanity is expected to be profound, influencing various aspects of society and the economy. Based on the provided context, here's a breakdown:\n", + "\n", + "1. **Coexistence with Machines**: Humans will need to coexist with AI systems that are increasingly capable of performing tasks traditionally done by people. This includes translating languages, diagnosing illnesses, and assisting in retail—all areas where AI can sometimes outperform human workers.\n", + "\n", + "2. **Transformation of Jobs**: The nature of work is likely to change significantly due to AI's capabilities. While some jobs may be displaced by automation, new job opportunities could emerge that we cannot yet imagine—similar to how the role of mobile app designers was unpredicted before smartphones became ubiquitous.\n", + "\n", + "3. **Augmentation and Complementation**: Ideally, AI will augment and complement human efforts rather than replace them entirely. However, there is a potential risk of massive unemployment if this transition isn't managed carefully.\n", + "\n", + "4. **Universal Basic Income (UBI)**: In scenarios where AI leads to significant job displacement, concepts like universal basic income are being discussed as potential solutions to support those affected.\n", + "\n", + "5. **Philosophical and Ethical Challenges**: The integration of AI into daily life raises fundamental questions about purpose and fulfillment when traditional work might no longer be necessary for everyone. Ethics and education will play crucial roles in addressing these societal challenges.\n", + "\n", + "6. **Data Collection and Privacy**: As work becomes more data-driven through machine learning systems that assess and allocate tasks, issues around data privacy and workers' rights become prominent concerns.\n", + "\n", + "7. **Democracy and Freedom Risks**: There are concerns about AI's potential threat to democracy through increased surveillance and manipulation, highlighting the importance of governance in ensuring peaceful coexistence between humans and machines.\n", + "\n", + "Overall, while AI offers opportunities for enhancement and efficiency across many sectors, it also presents challenges related to employment, ethical considerations, privacy, democracy, and economic inequality that societies must navigate carefully.\n" + ] + } + ], "source": [ "answer = completion.choices[0].message.content\n", "print(answer)" @@ -595,7 +1044,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": { "id": "nCXL9Cz1xYaV" }, @@ -615,7 +1064,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": { "id": "9y3E0YWExYaV" }, @@ -636,14 +1085,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": { "id": "i7SkWPpnxYaW", "outputId": "28e82563-edba-4b41-acad-ec27e5ba134f" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Snippet 1:\n", + "22 AI for Everyone?\n", + "Clearly, humans will need to coexist with machines. Jobs traditionally done by \n", + "humans will be shifted towards AI systems. Artificial intelligence is already able \n", + "to translate lan\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], "source": [ - "query_keywords = [] # add your keywords\n", + "query_keywords = [\"IA\", \"model\", \"artificial intelligence\"]\n", "for i, doc in enumerate(retrieved_docs[:1]):\n", " snippet = doc.page_content[:200]\n", " highlighted = highlight_keywords(snippet, query_keywords)\n", @@ -687,7 +1149,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "llm", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -701,7 +1163,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.10" + "version": "3.11.0" } }, "nbformat": 4, From 0428c4ae6cdbae3997bb5fa741f1a4c63a48b62f Mon Sep 17 00:00:00 2001 From: MiqueldeToledo Date: Tue, 27 Jan 2026 12:06:13 +0100 Subject: [PATCH 2/2] Add .gitignore and remove ChromaDB from tracking --- .gitignore | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de73d97 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# ChromaDB database files +your-code/chroma_db_LAB/ + +# Python cache +__pycache__/ +*.py[cod] +*$py.class +*.so + +# Virtual environments +venv/ +env/ +ENV/ + +# Jupyter Notebook checkpoints +.ipynb_checkpoints/ + +# Environment variables +.env