diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e8b503 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +chorma_db_LAB/ diff --git a/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/data_level0.bin b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/data_level0.bin new file mode 100644 index 0000000..af84098 Binary files /dev/null and b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/data_level0.bin differ diff --git a/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/header.bin b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/header.bin new file mode 100644 index 0000000..b04cf10 Binary files /dev/null and b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/header.bin differ diff --git a/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/index_metadata.pickle b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/index_metadata.pickle new file mode 100644 index 0000000..90f287f Binary files /dev/null and b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/index_metadata.pickle differ diff --git a/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/length.bin b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/length.bin new file mode 100644 index 0000000..5c3a960 Binary files /dev/null and b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/length.bin differ diff --git a/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/link_lists.bin b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/link_lists.bin new file mode 100644 index 0000000..9d62a42 Binary files /dev/null and b/your-code/chroma_db_LAB/8f188753-d258-486b-b654-d9605c92e92d/link_lists.bin differ diff --git a/your-code/chroma_db_LAB/chroma.sqlite3 b/your-code/chroma_db_LAB/chroma.sqlite3 new file mode 100644 index 0000000..f558423 Binary files /dev/null and b/your-code/chroma_db_LAB/chroma.sqlite3 differ diff --git a/your-code/main.ipynb b/your-code/main.ipynb index e3a225a..e052c34 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -61,25 +61,243 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.8)\n", + "Requirement already satisfied: langchain_community in c:\\users\\mites\\anaconda3\\lib\\site-packages (0.4.1)\n", + "Requirement already satisfied: pypdf in c:\\users\\mites\\anaconda3\\lib\\site-packages (6.3.0)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.0.6 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain) (1.0.7)\n", + "Requirement already satisfied: langgraph<1.1.0,>=1.0.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain) (1.0.3)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain) (2.10.3)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.6->langchain) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.6->langchain) (0.4.45)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.6->langchain) (24.2)\n", + "Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.6->langchain) (6.0.2)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.6->langchain) (9.0.0)\n", + "Requirement already satisfied: typing-extensions<5.0.0,>=4.7.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.6->langchain) (4.12.2)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2.0.0,>=1.0.6->langchain) (2.1)\n", + "Requirement already satisfied: langgraph-checkpoint<4.0.0,>=2.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (3.0.1)\n", + "Requirement already satisfied: langgraph-prebuilt<1.1.0,>=1.0.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (1.0.5)\n", + "Requirement already satisfied: langgraph-sdk<0.3.0,>=0.2.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (0.2.9)\n", + "Requirement already satisfied: xxhash>=3.5.0 in c:\\users\\mites\\anaconda3\\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\\mites\\anaconda3\\lib\\site-packages (from langgraph-checkpoint<4.0.0,>=2.1.0->langgraph<1.1.0,>=1.0.2->langchain) (1.12.0)\n", + "Requirement already satisfied: httpx>=0.25.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (0.28.1)\n", + "Requirement already satisfied: orjson>=3.10.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (3.11.4)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.6->langchain) (1.0.0)\n", + "Requirement already satisfied: requests>=2.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.6->langchain) (2.32.5)\n", + "Requirement already satisfied: zstandard>=0.23.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.6->langchain) (0.23.0)\n", + "Requirement already satisfied: anyio in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (4.7.0)\n", + "Requirement already satisfied: certifi in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (2025.4.26)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (1.0.9)\n", + "Requirement already satisfied: idna in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (3.7)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpcore==1.*->httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (0.16.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.27.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (2.27.1)\n", + "Requirement already satisfied: langchain-classic<2.0.0,>=1.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (1.0.0)\n", + "Requirement already satisfied: SQLAlchemy<3.0.0,>=1.4.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (2.0.39)\n", + "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (3.11.10)\n", + "Requirement already satisfied: dataclasses-json<0.7.0,>=0.6.7 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (0.6.7)\n", + "Requirement already satisfied: pydantic-settings<3.0.0,>=2.10.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (2.12.0)\n", + "Requirement already satisfied: httpx-sse<1.0.0,>=0.4.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (0.4.3)\n", + "Requirement already satisfied: numpy>=2.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_community) (2.1.3)\n", + "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (2.4.4)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.2.0)\n", + "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (24.3.0)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.5.0)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (6.1.0)\n", + "Requirement already satisfied: propcache>=0.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (0.3.1)\n", + "Requirement already satisfied: yarl<2.0,>=1.17.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.18.0)\n", + "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from dataclasses-json<0.7.0,>=0.6.7->langchain_community) (3.26.1)\n", + "Requirement already satisfied: typing-inspect<1,>=0.4.0 in c:\\users\\mites\\anaconda3\\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.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-classic<2.0.0,>=1.0.0->langchain_community) (1.0.0)\n", + "Requirement already satisfied: python-dotenv>=0.21.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic-settings<3.0.0,>=2.10.1->langchain_community) (1.1.0)\n", + "Requirement already satisfied: typing-inspection>=0.4.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic-settings<3.0.0,>=2.10.1->langchain_community) (0.4.2)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.6->langchain) (3.3.2)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.6->langchain) (2.3.0)\n", + "Requirement already satisfied: greenlet!=0.4.17 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from SQLAlchemy<3.0.0,>=1.4.0->langchain_community) (3.1.1)\n", + "Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7.0,>=0.6.7->langchain_community) (1.0.0)\n", + "Requirement already satisfied: sniffio>=1.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from anyio->httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (1.3.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n", + "Requirement already satisfied: termcolor in c:\\users\\mites\\anaconda3\\lib\\site-packages (3.2.0)\n", + "Requirement already satisfied: langchain_openai in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.3)\n", + "Requirement already satisfied: langchain-huggingface in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.1)\n", + "Requirement already satisfied: sentence-transformers in c:\\users\\mites\\anaconda3\\lib\\site-packages (5.1.2)\n", + "Requirement already satisfied: chromadb in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.3.5)\n", + "Requirement already satisfied: langchain_chroma in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.0)\n", + "Requirement already satisfied: tiktoken in c:\\users\\mites\\anaconda3\\lib\\site-packages (0.12.0)\n", + "Requirement already satisfied: openai in c:\\users\\mites\\anaconda3\\lib\\site-packages (2.8.1)\n", + "Requirement already satisfied: python-dotenv in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.1.0)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.0.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain_openai) (1.0.7)\n", + "Requirement already satisfied: regex>=2022.1.18 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from tiktoken) (2024.11.6)\n", + "Requirement already satisfied: requests>=2.26.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from tiktoken) (2.32.5)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (4.7.0)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (0.28.1)\n", + "Requirement already satisfied: jiter<1,>=0.10.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (0.12.0)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (2.10.3)\n", + "Requirement already satisfied: sniffio in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (1.3.0)\n", + "Requirement already satisfied: tqdm>4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (4.67.1)\n", + "Requirement already satisfied: typing-extensions<5,>=4.11 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from anyio<5,>=3.5.0->openai) (3.7)\n", + "Requirement already satisfied: certifi in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx<1,>=0.23.0->openai) (2025.4.26)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx<1,>=0.23.0->openai) (1.0.9)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\mites\\anaconda3\\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\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain_openai) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain_openai) (0.4.45)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain_openai) (24.2)\n", + "Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain_openai) (6.0.2)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain_openai) (9.0.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2.0.0,>=1.0.2->langchain_openai) (2.1)\n", + "Requirement already satisfied: orjson>=3.9.14 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain_openai) (3.11.4)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain_openai) (1.0.0)\n", + "Requirement already satisfied: zstandard>=0.23.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain_openai) (0.23.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.27.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (2.27.1)\n", + "Requirement already satisfied: huggingface-hub<1.0.0,>=0.33.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-huggingface) (0.36.0)\n", + "Requirement already satisfied: tokenizers<1.0.0,>=0.19.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-huggingface) (0.22.1)\n", + "Requirement already satisfied: filelock in c:\\users\\mites\\anaconda3\\lib\\site-packages (from huggingface-hub<1.0.0,>=0.33.4->langchain-huggingface) (3.17.0)\n", + "Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from huggingface-hub<1.0.0,>=0.33.4->langchain-huggingface) (2025.3.2)\n", + "Requirement already satisfied: transformers<5.0.0,>=4.41.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from sentence-transformers) (4.57.1)\n", + "Requirement already satisfied: torch>=1.11.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from sentence-transformers) (2.9.1)\n", + "Requirement already satisfied: scikit-learn in c:\\users\\mites\\anaconda3\\lib\\site-packages (from sentence-transformers) (1.6.1)\n", + "Requirement already satisfied: scipy in c:\\users\\mites\\anaconda3\\lib\\site-packages (from sentence-transformers) (1.15.3)\n", + "Requirement already satisfied: Pillow in c:\\users\\mites\\anaconda3\\lib\\site-packages (from sentence-transformers) (11.1.0)\n", + "Requirement already satisfied: numpy>=1.17 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from transformers<5.0.0,>=4.41.0->sentence-transformers) (2.1.3)\n", + "Requirement already satisfied: safetensors>=0.4.3 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from transformers<5.0.0,>=4.41.0->sentence-transformers) (0.7.0)\n", + "Requirement already satisfied: build>=1.0.3 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.3.0)\n", + "Requirement already satisfied: pybase64>=1.4.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.4.2)\n", + "Requirement already satisfied: uvicorn>=0.18.3 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.38.0)\n", + "Requirement already satisfied: posthog<6.0.0,>=2.4.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (5.4.0)\n", + "Requirement already satisfied: onnxruntime>=1.14.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.23.2)\n", + "Requirement already satisfied: opentelemetry-api>=1.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.38.0)\n", + "Requirement already satisfied: opentelemetry-exporter-otlp-proto-grpc>=1.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.38.0)\n", + "Requirement already satisfied: opentelemetry-sdk>=1.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.38.0)\n", + "Requirement already satisfied: pypika>=0.48.9 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (0.48.9)\n", + "Requirement already satisfied: overrides>=7.3.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (7.4.0)\n", + "Requirement already satisfied: importlib-resources in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (6.5.2)\n", + "Requirement already satisfied: grpcio>=1.58.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (1.76.0)\n", + "Requirement already satisfied: bcrypt>=4.0.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (4.3.0)\n", + "Requirement already satisfied: typer>=0.9.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (0.9.0)\n", + "Requirement already satisfied: kubernetes>=28.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (34.1.0)\n", + "Requirement already satisfied: mmh3>=4.0.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (5.2.0)\n", + "Requirement already satisfied: rich>=10.11.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (13.9.4)\n", + "Requirement already satisfied: jsonschema>=4.19.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from chromadb) (4.23.0)\n", + "Requirement already satisfied: six>=1.5 in c:\\users\\mites\\anaconda3\\lib\\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\\mites\\anaconda3\\lib\\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\\mites\\anaconda3\\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\\mites\\anaconda3\\lib\\site-packages (from requests>=2.26.0->tiktoken) (3.3.2)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.26.0->tiktoken) (2.3.0)\n", + "Requirement already satisfied: pyproject_hooks in c:\\users\\mites\\anaconda3\\lib\\site-packages (from build>=1.0.3->chromadb) (1.2.0)\n", + "Requirement already satisfied: colorama in c:\\users\\mites\\anaconda3\\lib\\site-packages (from build>=1.0.3->chromadb) (0.4.6)\n", + "Requirement already satisfied: attrs>=22.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (24.3.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (2023.7.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (0.30.2)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonschema>=4.19.0->chromadb) (0.22.3)\n", + "Requirement already satisfied: google-auth>=1.0.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from kubernetes>=28.1.0->chromadb) (2.43.0)\n", + "Requirement already satisfied: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from kubernetes>=28.1.0->chromadb) (1.8.0)\n", + "Requirement already satisfied: requests-oauthlib in c:\\users\\mites\\anaconda3\\lib\\site-packages (from kubernetes>=28.1.0->chromadb) (2.0.0)\n", + "Requirement already satisfied: durationpy>=0.7 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from kubernetes>=28.1.0->chromadb) (0.10)\n", + "Requirement already satisfied: cachetools<7.0,>=2.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from google-auth>=1.0.1->kubernetes>=28.1.0->chromadb) (5.5.1)\n", + "Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from google-auth>=1.0.1->kubernetes>=28.1.0->chromadb) (0.2.8)\n", + "Requirement already satisfied: rsa<5,>=3.1.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from google-auth>=1.0.1->kubernetes>=28.1.0->chromadb) (4.9.1)\n", + "Requirement already satisfied: pyasn1>=0.1.3 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from rsa<5,>=3.1.4->google-auth>=1.0.1->kubernetes>=28.1.0->chromadb) (0.4.8)\n", + "Requirement already satisfied: coloredlogs in c:\\users\\mites\\anaconda3\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (15.0.1)\n", + "Requirement already satisfied: flatbuffers in c:\\users\\mites\\anaconda3\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (25.9.23)\n", + "Requirement already satisfied: protobuf in c:\\users\\mites\\anaconda3\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (5.29.3)\n", + "Requirement already satisfied: sympy in c:\\users\\mites\\anaconda3\\lib\\site-packages (from onnxruntime>=1.14.1->chromadb) (1.13.3)\n", + "Requirement already satisfied: importlib-metadata<8.8.0,>=6.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from opentelemetry-api>=1.2.0->chromadb) (8.5.0)\n", + "Requirement already satisfied: zipp>=3.20 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from importlib-metadata<8.8.0,>=6.0->opentelemetry-api>=1.2.0->chromadb) (3.21.0)\n", + "Requirement already satisfied: googleapis-common-protos~=1.57 in c:\\users\\mites\\anaconda3\\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.38.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb) (1.38.0)\n", + "Requirement already satisfied: opentelemetry-proto==1.38.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb) (1.38.0)\n", + "Requirement already satisfied: opentelemetry-semantic-conventions==0.59b0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from opentelemetry-sdk>=1.2.0->chromadb) (0.59b0)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from rich>=10.11.0->chromadb) (2.2.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from rich>=10.11.0->chromadb) (2.19.1)\n", + "Requirement already satisfied: mdurl~=0.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->chromadb) (0.1.0)\n", + "Requirement already satisfied: networkx>=2.5.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from torch>=1.11.0->sentence-transformers) (3.4.2)\n", + "Requirement already satisfied: jinja2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from torch>=1.11.0->sentence-transformers) (3.1.6)\n", + "Requirement already satisfied: setuptools in c:\\users\\mites\\anaconda3\\lib\\site-packages (from torch>=1.11.0->sentence-transformers) (72.1.0)\n", + "Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from sympy->onnxruntime>=1.14.1->chromadb) (1.3.0)\n", + "Requirement already satisfied: click<9.0.0,>=7.1.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from typer>=0.9.0->chromadb) (8.1.8)\n", + "Requirement already satisfied: httptools>=0.6.3 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.7.1)\n", + "Requirement already satisfied: watchfiles>=0.13 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (1.1.1)\n", + "Requirement already satisfied: websockets>=10.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from uvicorn[standard]>=0.18.3->chromadb) (15.0.1)\n", + "Requirement already satisfied: humanfriendly>=9.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from coloredlogs->onnxruntime>=1.14.1->chromadb) (10.0)\n", + "Requirement already satisfied: pyreadline3 in c:\\users\\mites\\anaconda3\\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\\mites\\anaconda3\\lib\\site-packages (from jinja2->torch>=1.11.0->sentence-transformers) (3.0.2)\n", + "Requirement already satisfied: oauthlib>=3.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests-oauthlib->kubernetes>=28.1.0->chromadb) (3.3.1)\n", + "Requirement already satisfied: joblib>=1.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from scikit-learn->sentence-transformers) (1.4.2)\n", + "Requirement already satisfied: threadpoolctl>=3.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from scikit-learn->sentence-transformers) (3.5.0)\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" + "%pip install termcolor langchain_openai langchain-huggingface sentence-transformers chromadb langchain_chroma tiktoken openai python-dotenv\n", + "\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": { "id": "6heKZkQUxYZr" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.8)\n", + "Requirement already satisfied: langchain-core in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.7)\n", + "Requirement already satisfied: langgraph<1.1.0,>=1.0.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain) (1.0.3)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain) (2.10.3)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core) (0.4.45)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core) (24.2)\n", + "Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core) (6.0.2)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core) (9.0.0)\n", + "Requirement already satisfied: typing-extensions<5.0.0,>=4.7.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core) (4.12.2)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core) (2.1)\n", + "Requirement already satisfied: langgraph-checkpoint<4.0.0,>=2.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (3.0.1)\n", + "Requirement already satisfied: langgraph-prebuilt<1.1.0,>=1.0.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (1.0.5)\n", + "Requirement already satisfied: langgraph-sdk<0.3.0,>=0.2.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph<1.1.0,>=1.0.2->langchain) (0.2.9)\n", + "Requirement already satisfied: xxhash>=3.5.0 in c:\\users\\mites\\anaconda3\\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\\mites\\anaconda3\\lib\\site-packages (from langgraph-checkpoint<4.0.0,>=2.1.0->langgraph<1.1.0,>=1.0.2->langchain) (1.12.0)\n", + "Requirement already satisfied: httpx>=0.25.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (0.28.1)\n", + "Requirement already satisfied: orjson>=3.10.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (3.11.4)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core) (1.0.0)\n", + "Requirement already satisfied: requests>=2.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core) (2.32.5)\n", + "Requirement already satisfied: zstandard>=0.23.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core) (0.23.0)\n", + "Requirement already satisfied: anyio in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (4.7.0)\n", + "Requirement already satisfied: certifi in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (2025.4.26)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (1.0.9)\n", + "Requirement already satisfied: idna in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (3.7)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpcore==1.*->httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (0.16.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.27.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain) (2.27.1)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core) (3.3.2)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core) (2.3.0)\n", + "Requirement already satisfied: sniffio>=1.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from anyio->httpx>=0.25.2->langgraph-sdk<0.3.0,>=0.2.2->langgraph<1.1.0,>=1.0.2->langchain) (1.3.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "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", + "%pip install -U langchain langchain-core\n", + "\n", + "\n", + "from langchain_community.document_loaders import PyPDFLoader\n", + "from langchain_text_splitters import RecursiveCharacterTextSplitter\n", + "\n" ] }, { @@ -96,7 +314,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "id": "cuREtJRixYZt" }, @@ -104,7 +322,7 @@ "source": [ "# File path for the document\n", "\n", - "file_path = \"LAB/ai-for-everyone.pdf\"" + "file_path = r\"C:\\Users\\mites\\Desktop\\Ironhack\\Week7\\Day5\\lab-intro-rag\\ai-for-everyone.pdf\"" ] }, { @@ -122,12 +340,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "id": "_b5Z_45UxYZu", "outputId": "a600d69f-14fe-4492-f236-97261d6ff36c" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "297" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Load and split the document\n", "loader = PyPDFLoader(file_path)\n", @@ -168,9 +397,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1096" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "text_splitter = RecursiveCharacterTextSplitter(\n", " chunk_size=1000,\n", @@ -285,31 +525,92 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain-openai in c:\\users\\mites\\anaconda3\\lib\\site-packages (1.0.3)\n", + "Requirement already satisfied: langchain-core<2.0.0,>=1.0.2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-openai) (1.0.7)\n", + "Requirement already satisfied: openai<3.0.0,>=1.109.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-openai) (2.8.1)\n", + "Requirement already satisfied: tiktoken<1.0.0,>=0.7.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-openai) (0.12.0)\n", + "Requirement already satisfied: jsonpatch<2.0.0,>=1.33.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (1.33)\n", + "Requirement already satisfied: langsmith<1.0.0,>=0.3.45 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (0.4.45)\n", + "Requirement already satisfied: packaging<26.0.0,>=23.2.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (24.2)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (2.10.3)\n", + "Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (6.0.2)\n", + "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (9.0.0)\n", + "Requirement already satisfied: typing-extensions<5.0.0,>=4.7.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langchain-core<2.0.0,>=1.0.2->langchain-openai) (4.12.2)\n", + "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2.0.0,>=1.0.2->langchain-openai) (2.1)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (0.28.1)\n", + "Requirement already satisfied: orjson>=3.9.14 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (3.11.4)\n", + "Requirement already satisfied: requests-toolbelt>=1.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (1.0.0)\n", + "Requirement already satisfied: requests>=2.0.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (2.32.5)\n", + "Requirement already satisfied: zstandard>=0.23.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (0.23.0)\n", + "Requirement already satisfied: anyio in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx<1,>=0.23.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (4.7.0)\n", + "Requirement already satisfied: certifi in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx<1,>=0.23.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (2025.4.26)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx<1,>=0.23.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (1.0.9)\n", + "Requirement already satisfied: idna in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpx<1,>=0.23.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (3.7)\n", + "Requirement already satisfied: h11>=0.16 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from httpcore==1.*->httpx<1,>=0.23.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (0.16.0)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai<3.0.0,>=1.109.1->langchain-openai) (1.9.0)\n", + "Requirement already satisfied: jiter<1,>=0.10.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai<3.0.0,>=1.109.1->langchain-openai) (0.12.0)\n", + "Requirement already satisfied: sniffio in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai<3.0.0,>=1.109.1->langchain-openai) (1.3.0)\n", + "Requirement already satisfied: tqdm>4 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from openai<3.0.0,>=1.109.1->langchain-openai) (4.67.1)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain-core<2.0.0,>=1.0.2->langchain-openai) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.27.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from pydantic<3.0.0,>=2.7.4->langchain-core<2.0.0,>=1.0.2->langchain-openai) (2.27.1)\n", + "Requirement already satisfied: regex>=2022.1.18 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from tiktoken<1.0.0,>=0.7.0->langchain-openai) (2024.11.6)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (3.3.2)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\mites\\anaconda3\\lib\\site-packages (from requests>=2.0.0->langsmith<1.0.0,>=0.3.45->langchain-core<2.0.0,>=1.0.2->langchain-openai) (2.3.0)\n", + "Requirement already satisfied: colorama in c:\\users\\mites\\anaconda3\\lib\\site-packages (from tqdm>4->openai<3.0.0,>=1.109.1->langchain-openai) (0.4.6)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "%pip install langchain-openai" + ] + }, + { + "cell_type": "code", + "execution_count": 32, "metadata": { "id": "L0xDxElwxYZw" }, "outputs": [], "source": [ - "from langchain.embeddings import OpenAIEmbeddings\n", + "from langchain_openai import OpenAIEmbeddings\n", + "\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,23 +644,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": { "id": "brKe6wUgxYZ0" }, "outputs": [], "source": [ - "from langchain.vectorstores import Chroma" + "from langchain_community.vectorstores import Chroma" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "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 +692,89 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": { "id": "XiLv-TfrxYZ1" }, "outputs": [], "source": [ - "user_question = \"\" # User question\n", + "user_question = \"What are the main ideas about AI in this book?\" # 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": 53, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User Question: What are the main ideas about AI in this book?\n" + ] + } + ], + "source": [ + "print(\"User Question:\", user_question)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, "metadata": { "id": "qgWsh50JxYZ1", "outputId": "c8640c5d-5955-471f-fdd2-37096f5f68c7" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Document 1:\n", + ", are financially strong enough to hire the \n", + "brightest AI talent and have access to the gigantic datasets that are needed to \n", + "train machine learning and deep learning (AI) models. This context makes it \n", + "very clear why we need to ask critical questions about AI and power.\n", + "Conceptualising AI – What AI Are We Talking About?\n", + "Before understanding what type of AI we want, we need to understand what AI \n", + "we have. This is an area of significant debate, and the book opens by exploring \n", + "the varying approaches to how we define AI. \n", + "The Origins of AI\n", + "It is easy to forget that AI has been with us for more than 60 years. Despite \n", + "the flash of excitement and anxiety that feels so recent, AI itself is not a new \n", + "phenomenon. The name Artificial Intelligence (AI) was coined in the mid-\n", + "1950s at a series of academic workshops organised at Dartmouth College, New \n", + "Hampshire (USA). A group of scientists, led by mathematics professor John\n", + "Document 2:\n", + "rs. The discussion about how to define \n", + "AI cannot be settled in one definition, let alone one book. It is an important \n", + "starting point, however, and Part 1 and Part 2 of this book will unpack several \n", + "approaches to defining AI. \n", + "The Realities of AI for Some vs. the Ideals of AI for Everyone\n", + "Visions of AI in Policies and Ethics \n", + "Examining AI policies and ethics helps us to explore questions of what type of \n", + "AI we want/need, how its development should look like and how we deal with \n", + "its impact. Policy development happens at several levels and includes a number \n", + "of stakeholders: national governments, intergovernmental organisations, cor -\n", + "porations, professional associations and academics.\n", + "Document 3:\n", + "erspectives on AI 15\n", + "elaborates on how humans and machines have to coexist in the age of AI. \n", + "Wolfgang Hofkirchner ( Chapter 3 ) continues the discussion about humans \n", + "versus machines by analysing what Digital Humanism exactly entails. He pro-\n", + "poses dialectical models in order to overcome the human–machine dualism. \n", + "Jenna Ng (Chapter 4) adds to this discussion by elaborating on the rationalisa-\n", + "tion of AI and what this means for creativity. Dan McQuillan (Chapter 5) has \n", + "a different take on humanism and proposes how people’s councils for AI can \n", + "serve solidarity and mutual aid in times of crisis.\n", + "Part 2: Discourses and Myths About AI is comprised of five chapters. Rainer \n", + "Rehak (Chapter 6) stresses the importance but also limitations of metaphors \n", + "when talking about AI and intelligent systems. Angela Daly, S. Kate Devitt and \n", + "Monique Mann (Chapter 7) introduce and discuss their Good Data approach in\n" + ] + } + ], "source": [ "# Display top results\n", "for i, doc in enumerate(retrieved_docs[:3]): # Display top 3 results\n", @@ -418,7 +792,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 104, "metadata": { "id": "2iB3lZqHxYZ2" }, @@ -434,16 +808,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 105, "metadata": { "id": "2okzmuADxYZ2", "outputId": "0aa6cdca-188d-40e0-f5b4-8888d3549ea4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Context formatted for GPT model.\n", + "\n", + "\n", + "Content:\n", + "tational power to develop AI systems, are financially strong enough to hire the \n", + "brightest AI talent and have access to the gigantic datasets that are needed to \n", + "train machine learning and deep learning (AI) models. This context makes it \n", + "very clear why we need to ask critical questions about AI and power.\n", + "Conceptualising AI – What AI Are We Talking About?\n", + "Before understanding what type of AI we want, we need to understand what AI \n", + "we have. This is an area of significant debate, and the book opens by exploring \n", + "the varying approaches to how we define AI. \n", + "The Origins of AI\n", + "It is easy to forget that AI has been with us for more than 60 years. Despite \n", + "the flash of excitement and anxiety that feels so recent, AI itself is not a new \n", + "phenomenon. The name Artificial Intelligence (AI) was coined in the mid-\n", + "1950s at a series of academic workshops organised at Dartmouth College, New \n", + "Hampshire (USA). A group of scientists, led by mathematics professor John\n", + "\n", + "\n", + "Content:\n", + "mimicking \n" + ] + } + ], "source": [ "# Generate a formatted context from the retrieved documents\n", "formatted_context = _get_document_prompt(retrieved_docs)\n", - "print(\"Context formatted for GPT model.\")" + "print(\"Context formatted for GPT model.\")\n", + "print(formatted_context[:1000])" ] }, { @@ -464,22 +868,67 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "tqxVh9s3xYZ3", - "outputId": "97cca95d-4ab3-44d8-a76c-5713aad387d8" - }, - "outputs": [], + "execution_count": 106, + "metadata": {}, + "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**, specifically focusing on **critical perspective**.\n", + "Your answers must be based exclusively on provided content from technical books provided.\n", + "\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", + "'''{formatted_context}'''\n", + "\n", + "## GUIDELINES\n", + "1. **Accuracy**:\n", + "   - Only use the content in the `CONTEXT` section to answer.\n", + "   - If the answer cannot be found, explicitly state: \"The provided context does not contain this information.\"\n", + "   - Start explain cell morphology and then divide morphology in bulletpoints (nuclei, cytoplasm, background and other aspects to consider)\n", + "   - Follow by differential diagnosis\n", + "   - Lastly explain ancillary studies for malignant mesothelioma.\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", + "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", - "\"\"\"\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", + "\"\"\" # <-- This line was added to close the f-string\n", + "print(\"Prompt constructed.\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 107, "metadata": { "id": "0mjkQJ_ZxYZ3" }, @@ -497,7 +946,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 108, "metadata": { "id": "ylypRWRlxYZ4" }, @@ -507,11 +956,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': 500 , # Allow for longer responses\n", + " 'top_p': 1.0 , # Use nucleus sampling\n", + " 'frequency_penalty': 0.0 , # Reduce repetition\n", + " 'presence_penalty': 0.0 # Encourage new topics\n", "}" ] }, @@ -526,7 +975,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 109, "metadata": { "id": "4eXZO4pIxYZ4" }, @@ -538,12 +987,275 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "## SYSTEM ROLE\n", + "You are a knowledgeable and factual chatbot designed to assist with technical questions about **AI**, specifically focusing on **critical perspective**.\n", + "Your answers must be based exclusively on provided content from technical books provided.\n", + "\n", + "## USER QUESTION\n", + "The user has asked:\n", + "\"What are the main ideas about AI in this book?\"\n", + "\n", + "## CONTEXT\n", + "Here is the relevant content from the technical books:\n", + "'''\n", + "\n", + "Content:\n", + "tational power to develop AI systems, are financially strong enough to hire the \n", + "brightest AI talent and have access to the gigantic datasets that are needed to \n", + "train machine learning and deep learning (AI) models. This context makes it \n", + "very clear why we need to ask critical questions about AI and power.\n", + "Conceptualising AI – What AI Are We Talking About?\n", + "Before understanding what type of AI we want, we need to understand what AI \n", + "we have. This is an area of significant debate, and the book opens by exploring \n", + "the varying approaches to how we define AI. \n", + "The Origins of AI\n", + "It is easy to forget that AI has been with us for more than 60 years. Despite \n", + "the flash of excitement and anxiety that feels so recent, AI itself is not a new \n", + "phenomenon. The name Artificial Intelligence (AI) was coined in the mid-\n", + "1950s at a series of academic workshops organised at Dartmouth College, New \n", + "Hampshire (USA). A group of scientists, led by mathematics professor John\n", + "\n", + "\n", + "Content:\n", + "mimicking intelligent human behaviours. The discussion about how to define \n", + "AI cannot be settled in one definition, let alone one book. It is an important \n", + "starting point, however, and Part 1 and Part 2 of this book will unpack several \n", + "approaches to defining AI. \n", + "The Realities of AI for Some vs. the Ideals of AI for Everyone\n", + "Visions of AI in Policies and Ethics \n", + "Examining AI policies and ethics helps us to explore questions of what type of \n", + "AI we want/need, how its development should look like and how we deal with \n", + "its impact. Policy development happens at several levels and includes a number \n", + "of stakeholders: national governments, intergovernmental organisations, cor -\n", + "porations, professional associations and academics.\n", + "\n", + "\n", + "Content:\n", + "Introduction: Why We Need Critical Perspectives on AI 15\n", + "elaborates on how humans and machines have to coexist in the age of AI. \n", + "Wolfgang Hofkirchner ( Chapter 3 ) continues the discussion about humans \n", + "versus machines by analysing what Digital Humanism exactly entails. He pro-\n", + "poses dialectical models in order to overcome the human–machine dualism. \n", + "Jenna Ng (Chapter 4) adds to this discussion by elaborating on the rationalisa-\n", + "tion of AI and what this means for creativity. Dan McQuillan (Chapter 5) has \n", + "a different take on humanism and proposes how people’s councils for AI can \n", + "serve solidarity and mutual aid in times of crisis.\n", + "Part 2: Discourses and Myths About AI is comprised of five chapters. Rainer \n", + "Rehak (Chapter 6) stresses the importance but also limitations of metaphors \n", + "when talking about AI and intelligent systems. Angela Daly, S. Kate Devitt and \n", + "Monique Mann (Chapter 7) introduce and discuss their Good Data approach in\n", + "\n", + "\n", + "Content:\n", + "ing sure that the benefits of AI are accessible for everyone. Further in this intro-\n", + "duction, I elaborate on this and I make the case for a radical democratisation of \n", + "AI, and why we need to put power at the centre for achieving this.\n", + "The contributions in this book braid discussion of power and critique with \n", + "three strands: AI – Humans vs. Machines, Discourses and Myths About AI and \n", + "AI Power and Inequalities. \n", + "Part 1: AI – Humans vs. Machines – deals with the history and conceptualisa-\n", + "tion of AI and what is at stake in its development. This section looks at different \n", + "perspectives about what characterises machine intelligence and how it might \n", + "be important to further radical humanism in the era of automation and AI. \n", + "Part 2: Discourses and Myths About AI – analyses how AI is framed in popu-\n", + "lar and scholarly discussions and investigates the normative projections of what \n", + "AI should be and what it should do. This section poses critical questions about\n", + "\n", + "\n", + "Content:\n", + "4 AI for Everyone?\n", + "and what not. And it looks at issues about AI, power and inequalities, investi -\n", + "gating where the risks of exclusion are and how we should deal with this. \n", + "The book also brings diverse and critical voices to this debate. Whereas AI \n", + "as a discipline has been dominated by white, male, predominantly older scien-\n", + "tists from mathematical disciplines, this collection brings perspectives that are \n", + "characterised by a strong diversity in authorship and discipline. And threading \n", + "through all, the contributions offer a discussion of different tangents of power \n", + "and political economy in the field of AI and society.\n", + "The first task is to name our terms. For a concept that has been with us for so \n", + "long, there is little consensus on how to define it. The history of debating AI is \n", + "almost as old as AI itself. There is more debate than agreement about what AI \n", + "is and what it is not, and the only thing generally agreed is that there is no\n", + "\n", + "\n", + "Content:\n", + "lar and scholarly discussions and investigates the normative projections of what \n", + "AI should be and what it should do. This section poses critical questions about \n", + "how AI needs to debunk the myths surrounding it.\n", + "Part 3: AI Power and Inequalities – advances the debate around AI by criti -\n", + "cally examining what ‘ AI for Everyone?’ means. This is dealing with the root of \n", + "the problem: who will benefit from AI is ultimately down to who has the power \n", + "to decide. These contributions look at how AI capitalism is organised, what \n", + "(new) inequalities it might bring about and how we can fight back.\n", + "Why do we need a book on AI for Everyone? and why do we need it now? \n", + "The 2007–2008 financial crisis, and the resulting global economic crisis, has not \n", + "only brought about a decade of austerity in large parts of the Western world; \n", + "it has also been the context in which social media and digital platforms have \n", + "transformed into behemoths. Tech companies are now dominating the top 10\n", + "\n", + "\n", + "Content:\n", + "on human-machine dualism. Part 2, Discourses and Myths about AI, \n", + "excavates metaphors and policies to ask normative questions about what \n", + "is ‘desirable’ AI and what conditions make this possible. Part 3, AI Power \n", + "and Inequalities, discusses how the implementation of AI creates important \n", + "challenges that urgently need to be addressed.\n", + "Bringing together scholars from diverse disciplinary backgrounds and \n", + "regional contexts, this book offers a vital intervention on one of the most \n", + "hyped concepts of our times.\n", + "THE EDITOR\n", + "PIETER VERDEGEM is Senior Lecturer in Media Theory in the Wes-tminster School of \n", + "Media and Communication and a member of the Communication and Media Research \n", + "Institute (CAMRI), University of Westminster, UK. His research investigates the political \n", + "economy of digital media and the impact of digital technologies on society.\n", + "ARTIFICIAL INTELLIGENCE | DIGITAL MEDIA STUDIES | INTERNET STUDIES\n", + "CDSMS CRITICAL DIGITAL AND \n", + "SOCIAL MEDIA STUDIES\n", + "CDSMS\n", + "CRITICAL PERSPECTIVES\n", + "\n", + "\n", + "Content:\n", + "(Pasquale 2020). In one word, this is about power. If we are not talking about \n", + "power, we are not talking about AI for everyone . Critical perspectives require \n", + "us to talk about the human and society. By bringing together diverse critical \n", + "contributions to the debate, this book presents one thing they have in common: \n", + "the idea of putting society first.\n", + "Chapter Overview\n", + "Part 1 : AI – Humans vs . Machines consists of four contributions. Andreas \n", + "Kaplan ( Chapter 2 ) goes deeper into the history and definition of AI and\n", + "\n", + "\n", + "Content:\n", + "when talking about AI and intelligent systems. Angela Daly, S. Kate Devitt and \n", + "Monique Mann (Chapter 7) introduce and discuss their Good Data approach in \n", + "order to overcome the limitations of AI ethics and governance. James Steinhoff \n", + "(Chapter 8) critically analyses the social reconfiguration of AI and discusses \n", + "the central questions about utility and feasibility. Benedetta Brevini (Chapter 9) \n", + "analyses AI policies in Europe and unpacks some of the myths around AI \n", + "that legitimate capitalism. Alkim Almila Akdag Salah ( Chapter 10 ) reflects \n", + "on how the discourses of artistic computational production have changed and \n", + "how myths about AI need to be uncovered in this context.\n", + "Part 3: AI Power and Inequalities involves five contributions. Carrie O’Connell \n", + "and Chad Van de Wiele ( Chapter 11) revisit Wiener’s cybernetic prediction \n", + "as the theoretical foundation of AI and make a plea how we need to uncover \n", + "the black box of what is behind prediction and simulation. Jernej A. Prodnik\n", + "\n", + "\n", + "Content:\n", + "on human-machine dualism. Part 2, Discourses and Myths about AI, \n", + "excavates metaphors and policies to ask normative questions about what \n", + "is ‘desirable’ AI and what conditions make this possible. Part 3, AI Power \n", + "and Inequalities, discusses how the implementation of AI creates important \n", + "challenges that urgently need to be addressed.\n", + "Bringing together scholars from diverse disciplinary backgrounds and \n", + "regional contexts, this book offers a vital intervention on one of the most \n", + "hyped concepts of our times.\n", + "THE EDITOR\n", + "PIETER VERDEGEM is Senior Lecturer in Media Theory in the Westminster School of \n", + "Media and Communication and a member of the Communication and Media Research \n", + "Institute (CAMRI), University of Westminster, UK. His research investigates the political \n", + "economy of digital media and the impact of digital technologies on society.\n", + "ARTIFICIAL INTELLIGENCE | DIGITAL MEDIA STUDIES | INTERNET STUDIES\n", + "CDSMS CRITICAL DIGITAL AND \n", + "SOCIAL MEDIA STUDIES\n", + "CDSMS\n", + "CRITICAL PERSPECTIVES\n", + "\n", + "'''\n", + "\n", + "## GUIDELINES\n", + "1. **Accuracy**:\n", + "   - Only use the content in the `CONTEXT` section to answer.\n", + "   - If the answer cannot be found, explicitly state: \"The provided context does not contain this information.\"\n", + "   - Start explain cell morphology and then divide morphology in bulletpoints (nuclei, cytoplasm, background and other aspects to consider)\n", + "   - Follow by differential diagnosis\n", + "   - Lastly explain ancillary studies for malignant mesothelioma.\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", + "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" + ] + } + ], + "source": [ + "print(prompt)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, "metadata": { "id": "wLPAcchBxYZ5", "outputId": "976c7800-16ed-41fe-c4cf-58f60d3230d2" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\"\"\"\n", + "# Main Ideas About AI in the Book\n", + "\n", + "The book discusses the following main ideas about AI:\n", + "\n", + "1. **Critical Examination of AI and Power**:\n", + " - It emphasizes the need to ask critical questions about AI and power, particularly who benefits from AI development given the resources required to build AI systems.\n", + "\n", + "2. **Conceptualization and Definition of AI**:\n", + " - The book explores the varying approaches to defining AI, acknowledging that there is significant debate and no single definition.\n", + "\n", + "3. **Historical Context of AI**:\n", + " - AI's origins are traced back to the mid-1950s, highlighting its long-standing presence and the evolution of the term \"Artificial Intelligence.\"\n", + "\n", + "4. **AI for Everyone and Inequalities**:\n", + " - It examines the disparities in AI development and access, questioning who truly benefits from AI advancements and emphasizing the need for a more inclusive approach.\n", + "\n", + "5. **Humans vs. Machines**:\n", + " - The book discusses the coexistence of humans and machines, exploring concepts like Digital Humanism and the potential for AI to challenge the human-machine dualism.\n", + "\n", + "6. **Discourses and Myths About AI**:\n", + " - The book analyzes how AI is framed in popular and scholarly discussions, investigating the myths and normative projections about AI.\n", + "\n", + "7. **AI Policies and Ethics**:\n", + " - There is a focus on AI policies and ethics to explore what kind of AI society needs and how to handle its impacts.\n", + "\n", + "8. **Diverse Perspectives**:\n", + " - The book includes diverse and critical voices, challenging the traditionally homogeneous perspectives in AI discussions.\n", + "\n", + "**Source**:\n", + "• [No specific book title provided], Pages: Various\n", + "\"\"\"\n" + ] + } + ], "source": [ "answer = completion.choices[0].message.content\n", "print(answer)" @@ -595,7 +1307,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": { "id": "nCXL9Cz1xYaV" }, @@ -615,7 +1327,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": { "id": "9y3E0YWExYaV" }, @@ -636,14 +1348,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 111, "metadata": { "id": "i7SkWPpnxYaW", "outputId": "28e82563-edba-4b41-acad-ec27e5ba134f" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Snippet 1:\n", + "tational power to develop \u001b[1m\u001b[32mAI\u001b[0m systems, are financially strong enough to hire the \n", + "brightest \u001b[1m\u001b[32mAI\u001b[0m talent and have access to the gigantic datasets that are needed to \n", + "train \u001b[1m\u001b[32mmachine learning\u001b[0m and deep learni\n", + "--------------------------------------------------------------------------------\n" + ] + } + ], "source": [ - "query_keywords = [] # add your keywords\n", + "query_keywords = ['AI', 'machine learning', 'deep learning', 'Python' ] # 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", @@ -687,7 +1411,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "llm", + "display_name": "base", "language": "python", "name": "python3" }, @@ -701,7 +1425,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.10" + "version": "3.13.5" } }, "nbformat": 4,