itsayushpandey commented on code in PR #32018:
URL: https://github.com/apache/beam/pull/32018#discussion_r1724290190
##########
examples/notebooks/beam-ml/rag_usecase/opensearch_rag_pipeline.ipynb:
##########
@@ -0,0 +1,1779 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "aab0b3c8-f952-4db8-8026-74d4d0d18f2c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# @title ###### Licensed to the Apache Software Foundation (ASF), Version
2.0 (the \"License\")\n",
+ "\n",
+ "# Licensed to the Apache Software Foundation (ASF) under one\n",
+ "# or more contributor license agreements. See the NOTICE file\n",
+ "# distributed with this work for additional information\n",
+ "# regarding copyright ownership. The ASF licenses this file\n",
+ "# to you under the Apache License, Version 2.0 (the\n",
+ "# \"License\"); you may not use this file except in compliance\n",
+ "# with the License. You may obtain a copy of the License at\n",
+ "#\n",
+ "# http://www.apache.org/licenses/LICENSE-2.0\n",
+ "#\n",
+ "# Unless required by applicable law or agreed to in writing,\n",
+ "# software distributed under the License is distributed on an\n",
+ "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n",
+ "# KIND, either express or implied. See the License for the\n",
+ "# specific language governing permissions and limitations\n",
+ "# under the License"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "62a8c341-3092-48f7-a4b6-c586414d2c83",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: pandas==1.4.4 in
/usr/local/lib/python3.10/site-packages (1.4.4)\n",
+ "Requirement already satisfied: python-dateutil>=2.8.1 in
/usr/local/lib/python3.10/site-packages (from pandas==1.4.4) (2.8.2)\n",
+ "Requirement already satisfied: pytz>=2020.1 in
/usr/local/lib/python3.10/site-packages (from pandas==1.4.4) (2022.2.1)\n",
+ "Requirement already satisfied: numpy>=1.21.0 in
/usr/local/lib/python3.10/site-packages (from pandas==1.4.4) (1.24.4)\n",
+ "Requirement already satisfied: six>=1.5 in
/usr/local/lib/python3.10/site-packages (from
python-dateutil>=2.8.1->pandas==1.4.4) (1.16.0)\n",
+ "Requirement already satisfied: numpy==1.24.4 in
/usr/local/lib/python3.10/site-packages (1.24.4)\n",
+ "Requirement already satisfied: apache_beam==2.56.0 in
/usr/local/lib/python3.10/site-packages (2.56.0)\n",
+ "Requirement already satisfied: crcmod<2.0,>=1.7 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (1.7)\n",
+ "Requirement already satisfied: orjson<4,>=3.9.7 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (3.10.0)\n",
+ "Requirement already satisfied: dill<0.3.2,>=0.3.1.1 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.3.1.1)\n",
+ "Requirement already satisfied: cloudpickle~=2.2.1 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (2.2.1)\n",
+ "Requirement already satisfied: fastavro<2,>=0.23.6 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (1.9.4)\n",
+ "Requirement already satisfied: fasteners<1.0,>=0.3 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.19)\n",
+ "Requirement already satisfied:
grpcio!=1.48.0,!=1.59.*,!=1.60.*,!=1.61.*,!=1.62.0,!=1.62.1,<2,>=1.33.1 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (1.53.0)\n",
+ "Requirement already satisfied: hdfs<3.0.0,>=2.1.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (2.7.3)\n",
+ "Requirement already satisfied: httplib2<0.23.0,>=0.8 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.22.0)\n",
+ "Requirement already satisfied: jsonschema<5.0.0,>=4.0.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (4.19.0)\n",
+ "Requirement already satisfied: jsonpickle<4.0.0,>=3.0.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (3.0.2)\n",
+ "Requirement already satisfied: numpy<1.27.0,>=1.14.3 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (1.24.4)\n",
+ "Requirement already satisfied: objsize<0.8.0,>=0.6.1 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.7.0)\n",
+ "Requirement already satisfied: packaging>=22.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (23.2)\n",
+ "Requirement already satisfied: pymongo<5.0.0,>=3.8.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (4.7.2)\n",
+ "Requirement already satisfied: proto-plus<2,>=1.7.1 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (1.23.0)\n",
+ "Requirement already satisfied:
protobuf!=4.0.*,!=4.21.*,!=4.22.0,!=4.23.*,!=4.24.*,<4.26.0,>=3.20.3 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (3.20.3)\n",
+ "Requirement already satisfied: pydot<2,>=1.2.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (1.4.2)\n",
+ "Requirement already satisfied: python-dateutil<3,>=2.8.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (2.8.2)\n",
+ "Requirement already satisfied: pytz>=2018.3 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0)
(2022.2.1)\n",
+ "Requirement already satisfied: redis<6,>=5.0.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (5.0.1)\n",
+ "Requirement already satisfied: regex>=2020.6.8 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0)
(2023.3.23)\n",
+ "Requirement already satisfied: requests<3.0.0,>=2.24.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (2.31.0)\n",
+ "Requirement already satisfied: typing-extensions>=3.7.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (4.10.0)\n",
+ "Requirement already satisfied: zstandard<1,>=0.18.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.22.0)\n",
+ "Requirement already satisfied: pyarrow<15.0.0,>=3.0.0 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (10.0.1)\n",
+ "Requirement already satisfied: pyarrow-hotfix<1 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.5)\n",
+ "Requirement already satisfied: js2py<1,>=0.74 in
/usr/local/lib/python3.10/site-packages (from apache_beam==2.56.0) (0.74)\n",
+ "Requirement already satisfied: docopt in
/usr/local/lib/python3.10/site-packages (from
hdfs<3.0.0,>=2.1.0->apache_beam==2.56.0) (0.6.2)\n",
+ "Requirement already satisfied: six>=1.9.0 in
/usr/local/lib/python3.10/site-packages (from
hdfs<3.0.0,>=2.1.0->apache_beam==2.56.0) (1.16.0)\n",
+ "Requirement already satisfied:
pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in
/usr/local/lib/python3.10/site-packages (from
httplib2<0.23.0,>=0.8->apache_beam==2.56.0) (3.0.9)\n",
+ "Requirement already satisfied: tzlocal>=1.2 in
/usr/local/lib/python3.10/site-packages (from
js2py<1,>=0.74->apache_beam==2.56.0) (5.2)\n",
+ "Requirement already satisfied: pyjsparser>=2.5.1 in
/usr/local/lib/python3.10/site-packages (from
js2py<1,>=0.74->apache_beam==2.56.0) (2.7.1)\n",
+ "Requirement already satisfied: attrs>=22.2.0 in
/usr/local/lib/python3.10/site-packages (from
jsonschema<5.0.0,>=4.0.0->apache_beam==2.56.0) (23.1.0)\n",
+ "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in
/usr/local/lib/python3.10/site-packages (from
jsonschema<5.0.0,>=4.0.0->apache_beam==2.56.0) (2023.7.1)\n",
+ "Requirement already satisfied: referencing>=0.28.4 in
/usr/local/lib/python3.10/site-packages (from
jsonschema<5.0.0,>=4.0.0->apache_beam==2.56.0) (0.30.2)\n",
+ "Requirement already satisfied: rpds-py>=0.7.1 in
/usr/local/lib/python3.10/site-packages (from
jsonschema<5.0.0,>=4.0.0->apache_beam==2.56.0) (0.10.0)\n",
+ "Requirement already satisfied: dnspython<3.0.0,>=1.16.0 in
/usr/local/lib/python3.10/site-packages (from
pymongo<5.0.0,>=3.8.0->apache_beam==2.56.0) (2.6.1)\n",
+ "Requirement already satisfied: async-timeout>=4.0.2 in
/usr/local/lib/python3.10/site-packages (from
redis<6,>=5.0.0->apache_beam==2.56.0) (4.0.3)\n",
+ "Requirement already satisfied: charset-normalizer<4,>=2 in
/usr/local/lib/python3.10/site-packages (from
requests<3.0.0,>=2.24.0->apache_beam==2.56.0) (3.2.0)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in
/usr/local/lib/python3.10/site-packages (from
requests<3.0.0,>=2.24.0->apache_beam==2.56.0) (3.4)\n",
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in
/usr/local/lib/python3.10/site-packages (from
requests<3.0.0,>=2.24.0->apache_beam==2.56.0) (2.0.4)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in
/usr/local/lib/python3.10/site-packages (from
requests<3.0.0,>=2.24.0->apache_beam==2.56.0) (2023.7.22)\n",
+ "\u001b[31mERROR: Could not find a version that satisfies the
requirement opensearch==2.1.0 (from versions: 0.5, 0.6, 0.7, 0.8, 0.9, 0.9.1,
0.9.2)\u001b[0m\u001b[31m\n",
+ "\u001b[0m\u001b[31mERROR: No matching distribution found for
opensearch==2.1.0\u001b[0m\u001b[31m\n",
+ "\u001b[0mRequirement already satisfied: langchain==0.1.14 in
/usr/local/lib/python3.10/site-packages (0.1.14)\n",
+ "Requirement already satisfied: PyYAML>=5.3 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (6.0)\n",
+ "Requirement already satisfied: SQLAlchemy<3,>=1.4 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (2.0.29)\n",
+ "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (3.8.6)\n",
+ "Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (4.0.3)\n",
+ "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (0.6.4)\n",
+ "Requirement already satisfied: jsonpatch<2.0,>=1.33 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (1.33)\n",
+ "Requirement already satisfied: langchain-community<0.1,>=0.0.30 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (0.0.31)\n",
+ "Requirement already satisfied: langchain-core<0.2.0,>=0.1.37 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (0.1.52)\n",
+ "Requirement already satisfied: langchain-text-splitters<0.1,>=0.0.1 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (0.0.1)\n",
+ "Requirement already satisfied: langsmith<0.2.0,>=0.1.17 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (0.1.40)\n",
+ "Requirement already satisfied: numpy<2,>=1 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (1.24.4)\n",
+ "Requirement already satisfied: pydantic<3,>=1 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (1.10.12)\n",
+ "Requirement already satisfied: requests<3,>=2 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (2.31.0)\n",
+ "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in
/usr/local/lib/python3.10/site-packages (from langchain==0.1.14) (8.2.3)\n",
+ "Requirement already satisfied: attrs>=17.3.0 in
/usr/local/lib/python3.10/site-packages (from
aiohttp<4.0.0,>=3.8.3->langchain==0.1.14) (23.1.0)\n",
+ "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in
/usr/local/lib/python3.10/site-packages (from
aiohttp<4.0.0,>=3.8.3->langchain==0.1.14) (3.2.0)\n",
+ "Requirement already satisfied: multidict<7.0,>=4.5 in
/usr/local/lib/python3.10/site-packages (from
aiohttp<4.0.0,>=3.8.3->langchain==0.1.14) (6.0.4)\n",
+ "Requirement already satisfied: yarl<2.0,>=1.0 in
/usr/local/lib/python3.10/site-packages (from
aiohttp<4.0.0,>=3.8.3->langchain==0.1.14) (1.9.2)\n",
+ "Requirement already satisfied: frozenlist>=1.1.1 in
/usr/local/lib/python3.10/site-packages (from
aiohttp<4.0.0,>=3.8.3->langchain==0.1.14) (1.4.0)\n",
+ "Requirement already satisfied: aiosignal>=1.1.2 in
/usr/local/lib/python3.10/site-packages (from
aiohttp<4.0.0,>=3.8.3->langchain==0.1.14) (1.3.1)\n",
+ "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in
/usr/local/lib/python3.10/site-packages (from
dataclasses-json<0.7,>=0.5.7->langchain==0.1.14) (3.21.1)\n",
+ "Requirement already satisfied: typing-inspect<1,>=0.4.0 in
/usr/local/lib/python3.10/site-packages (from
dataclasses-json<0.7,>=0.5.7->langchain==0.1.14) (0.9.0)\n",
+ "Requirement already satisfied: jsonpointer>=1.9 in
/usr/local/lib/python3.10/site-packages (from
jsonpatch<2.0,>=1.33->langchain==0.1.14) (2.4)\n",
+ "Requirement already satisfied: packaging<24.0,>=23.2 in
/usr/local/lib/python3.10/site-packages (from
langchain-core<0.2.0,>=0.1.37->langchain==0.1.14) (23.2)\n",
+ "Requirement already satisfied: orjson<4.0.0,>=3.9.14 in
/usr/local/lib/python3.10/site-packages (from
langsmith<0.2.0,>=0.1.17->langchain==0.1.14) (3.10.0)\n",
+ "Requirement already satisfied: typing-extensions>=4.2.0 in
/usr/local/lib/python3.10/site-packages (from
pydantic<3,>=1->langchain==0.1.14) (4.10.0)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in
/usr/local/lib/python3.10/site-packages (from
requests<3,>=2->langchain==0.1.14) (3.4)\n",
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in
/usr/local/lib/python3.10/site-packages (from
requests<3,>=2->langchain==0.1.14) (2.0.4)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in
/usr/local/lib/python3.10/site-packages (from
requests<3,>=2->langchain==0.1.14) (2023.7.22)\n",
+ "Requirement already satisfied: greenlet!=0.4.17 in
/usr/local/lib/python3.10/site-packages (from
SQLAlchemy<3,>=1.4->langchain==0.1.14) (3.0.3)\n",
+ "Requirement already satisfied: mypy-extensions>=0.3.0 in
/usr/local/lib/python3.10/site-packages (from
typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain==0.1.14)
(1.0.0)\n"
+ ]
+ }
+ ],
+ "source": [
+ "#installing dependencies\n",
+ "!pip install pandas==1.4.4\n",
+ "!pip install numpy==1.24.4\n",
+ "!pip install apache_beam==2.56.0\n",
+ "!pip install opensearch==2.1.0\n",
+ "!pip install langchain==0.1.14 #used for chunking"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "697ad0fa-7625-4a27-b1b7-72eda94748a2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import apache_beam as beam\n",
+ "import pandas as pd\n",
+ "from apache_beam.ml.transforms.base import MLTransform\n",
+ "from apache_beam.transforms.enrichment import Enrichment\n",
+ "from apache_beam.ml.transforms.embeddings.huggingface import
SentenceTransformerEmbeddings\n",
+ "import tempfile\n",
+ "import json\n",
+ "\n",
+ "from opensearchpy import OpenSearch\n",
+ "from opensearch_connector import *\n",
+ "from opensearch_enrichment import *\n",
+ "from chunks_generation import *"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "3d274890-4e6b-4a3d-b682-9fc6e21e5cca",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'2.56.0'"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "#To check beam version installed \n",
+ "beam.__version__"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "84d2e424-2747-421b-8ab0-8416992536b6",
+ "metadata": {},
+ "source": [
+ "Next we load the Opensearch credentials that will be needed in access
during following steps. It reads credentials from environment. Please replace
the values in the file before running this."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "5948f80b-65fa-4416-b7be-803c56477b72",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "from dotenv import load_dotenv\n",
+ "\n",
+ "load_dotenv('credentials.env')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "394e2ebf-9553-4464-b6a3-1386ef57f24b",
+ "metadata": {},
+ "source": [
+ "# Reading json data"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "006fdc19-e16a-4142-9653-b0c0a7e63b8e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "with open('hf_small_wikipedia.json', 'r') as j:\n",
+ " contents = json.loads(j.read())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "213fb96c-a641-4688-b083-96fd762608aa",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "list"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "type(contents)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "bdc5047c-8539-4381-84fd-5660f9829a10",
+ "metadata": {},
+ "source": [
+ "# Creating a Search Index¶\n",
+ "### Next few cells will show how to specify and create a search index in
OpenSearch vector DB. \n",
+ "\n",
+ "Set some constants for defining our index like the distance metric and
the index name.\n",
+ "\n",
+ "Define the index schema with OpenSearchSearch fields.\n",
+ "\n",
+ "Create the index.\n",
+ "\n",
+ "Index creation is neeeded only once."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "c32bad0c-c976-46a7-b43c-3887fc964b51",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:PUT https://localhost:9200/embeddings-index [status:200
request:0.351s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "http_auth = [os.environ['OPENSEARCH_USERNAME'],
os.environ['OPENSEARCH_PASSWORD']]\n",
+ "client = OpenSearch(hosts = ['https://localhost:9200'],\n",
+ " http_auth = http_auth,\n",
+ " verify_certs = False\n",
+ " )\n",
+ "\n",
+ "index_name = 'embeddings-index'\n",
+ "\n",
+ "index_body = {\n",
+ " \"settings\": {\n",
+ " \"index.knn\": True\n",
+ " },\n",
+ " \"mappings\": {\n",
+ " \"properties\": {\n",
+ " \"title_vector\": {\n",
+ " \"type\": \"knn_vector\",\n",
+ " \"dimension\": 384,\n",
+ " \"method\": {\n",
+ " \"engine\": \"faiss\",\n",
+ " \"name\": \"hnsw\"\n",
+ " }\n",
+ " },\n",
+ " \"text_vector\": {\n",
+ " \"type\": \"knn_vector\",\n",
+ " \"dimension\": 384,\n",
+ " \"method\": {\n",
+ " \"engine\": \"faiss\",\n",
+ " \"name\": \"hnsw\"\n",
+ " }\n",
+ " },\n",
+ " \"id\": {\n",
+ " \"type\": \"long\"\n",
+ " },\n",
+ " \"url\": {\n",
+ " \"type\": \"text\"\n",
+ " },\n",
+ " \"title\": {\n",
+ " \"type\": \"text\"\n",
+ " },\n",
+ " \"text\": {\n",
+ " \"type\": \"text\"\n",
+ " },\n",
+ " \"section_id\": {\n",
+ " \"type\": \"long\"\n",
+ " }\n",
+ " }\n",
+ "}}\n",
+ "\n",
+ "response = client.indices.create(index_name, body=index_body)\n",
+ "\n",
+ "# Command for deleting an index\n",
+ "# response = client.indices.delete(index = index_name)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5ebc23b0-f3e6-484e-bf64-a07c97489ccf",
+ "metadata": {},
+ "source": [
+ "# Creating Knowledge Base in OpenSearch Vector Database¶\n",
+ "After creating a search index, we can load documents into it. We will use
the same documents we used in the previous cell. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "e4a9d492-e826-4101-a21b-49b88933dce1",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:root:Missing pipeline option (runner). Executing pipeline using
the default runner: DirectRunner.\n",
+
"WARNING:apache_beam.runners.interactive.interactive_environment:Dependencies
required for Interactive Beam PCollection visualization are not available,
please use: `pip install apache-beam[interactive]` to install necessary
dependencies to enable all data visualization features.\n"
+ ]
+ },
+ {
+ "data": {
+ "application/javascript": [
+ "\n",
+ " if (typeof window.interactive_beam_jquery == 'undefined') {\n",
+ " var jqueryScript = document.createElement('script');\n",
+ " jqueryScript.src =
'https://code.jquery.com/jquery-3.4.1.slim.min.js';\n",
+ " jqueryScript.type = 'text/javascript';\n",
+ " jqueryScript.onload = function() {\n",
+ " var datatableScript = document.createElement('script');\n",
+ " datatableScript.src =
'https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js';\n",
+ " datatableScript.type = 'text/javascript';\n",
+ " datatableScript.onload = function() {\n",
+ " window.interactive_beam_jquery =
jQuery.noConflict(true);\n",
+ "
window.interactive_beam_jquery(document).ready(function($){\n",
+ " \n",
+ " });\n",
+ " }\n",
+ " document.head.appendChild(datatableScript);\n",
+ " };\n",
+ " document.head.appendChild(jqueryScript);\n",
+ " } else {\n",
+ "
window.interactive_beam_jquery(document).ready(function($){\n",
+ " \n",
+ " });\n",
+ " }"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "INFO:apache_beam.runners.worker.statecache:Creating state cache with
size 104857600\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "2024-08-17 12:28:49.961311: I
tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is
optimized to use available CPU instructions in performance-critical
operations.\n",
+ "To enable the following instructions: AVX2 FMA, in other operations,
rebuild TensorFlow with the appropriate compiler flags.\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "071b8c60203342958f3807c3f5a1b6b8",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "63104f55e0c94720a5c5485601dbff16",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "9b4a4e31c51142babe8d3bbf2c230abf",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "f5cea3eba89c44988808d98e4e729c7d",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "fb9a2d6f213644968a15da340a34c4ef",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6315ad37d3974517bebca0935cf6e99c",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7e4c37bbb6754614903fa78160f1c475",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5eda5bfc904b4463889211a7af6273cc",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "43c4f83cbb3045d59db55800af517673",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "e3147202ddbc48ba910a9efd52668eb0",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "41b8cf27a55648cb8b99b9325d3ea904",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "3554e99fceb1490caf785ecd641c3a2b",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+
"/usr/local/lib/python3.10/site-packages/opensearchpy/connection/http_urllib3.py:208:
UserWarning: Connecting to https://localhost:9200 using SSL with
verify_certs=False is insecure.\n",
+ " warnings.warn(\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:1.352s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "4f1ef21e4566483a9795b73de3cb8954",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "712a6cdbb623459a954288b18f6cc21c",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7c78041898154af4a2ade47439b78b72",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "1a67fac2e04648198f05ea6462394ae5",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "c731d48bad8348e785ce9ff2c39a90fb",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "2e55dabb036449df8210eb8fae908eb7",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "45dc25d5f33c4aff9a56773f88d7a872",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "3620aaefbfcc477ba95301ab9c9f2cc6",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.071s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ff6243888e4b429cb33f197935287e55",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7beaef6725934e3fb735d42ab027325e",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.070s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6ad77843d0ee41f79d96a1a7b1fd50d5",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "96a5145812714e0aa007a1ba9b5454df",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.065s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "8d33894cc025455b89b0ac550c937aa9",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "28af11f6588d413f922f13d0f4a7922b",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.073s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5934ed15f3214ff1ad3604006ad8dcfd",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "67fe0f006fb740feb2b310e9a1b7e8c2",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.059s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ffd44e5ad2dc4a18a74a7e91ed10f2a0",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "fba1f0d355454ffcbb106cca28b2c7db",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.088s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.091s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "62bbea2e1a934ccba6cd2257db413db0",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "b5bf6d8012314844b3949f575055cf25",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.098s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.078s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6f19a4a15ba044bfb9e00fbc78bc4fcc",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "2966d8a3c63a466a8de4d8e7d8b9b338",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.103s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.079s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.084s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0357acea5ca74775ad179d53a59f924d",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "4df896cbf002406a9522ca2b47a52677",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.093s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.075s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "d77111294efa4617a644f606dc878394",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "14f1b3d760f94ba6b6c1cd675a4858e0",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.076s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.079s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "117aeddb17854fe98feb0bcafa07a4fa",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "4ae68c8860a440ac81c653e6f2d99ad2",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.165s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.089s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.088s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "103621eecd2740f4b93b059294ed4149",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "2842a864985b4122ac3efe874508b41f",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.077s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.060s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.067s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "3b64dffdbc7f4a5eac1f59294757b42e",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "270a52af4b2049289e37a35c959cffdd",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.067s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.082s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.054s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "b3e7e77046ee47779a3d13bf4eb4ce95",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6fd5f7a817a946c3984d2654f4b3890a",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.063s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.057s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "32caa99b303445fba750bdeb74a7f7ef",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "67513ca1ee544b009b4b4a6dabcaca90",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.066s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.057s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.070s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.086s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "38e6a79e798c4a5f853f1c1e305890fa",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "f7a816ff0a374558aabac8b005cd90d0",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.064s]\n",
+ "INFO:opensearch_connector:Adding Docs in DB: 10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.083s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "da1a46a3cb6b4543aad1597240194ad6",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6218c7f94a104641846dcef9b01a6075",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:opensearch_connector:Adding Docs in DB: 9\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk?refresh=true
[status:200 request:0.066s]\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "b531195780c441f286906eb685437811",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0f97a99954354e9eb19c340a85508d1c",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:root:BatchElements statistics: element_count=349 batch_count=27
next_batch_size=4 timings=[(1, 0.18766427040100098), (2, 0.5434770584106445),
(1, 0.18743109703063965), (2, 0.28671717643737793), (1, 0.180436372756958), (2,
0.2946739196777344), (1, 0.23954296112060547), (2, 0.2287900447845459), (4,
0.6388511657714844), (6, 0.7156858444213867), (7, 0.8332958221435547), (13,
1.1533119678497314), (12, 1.2309019565582275), (14, 1.1411330699920654), (19,
1.4424619674682617), (19, 1.1780219078063965), (24, 1.7884211540222168), (19,
1.191762924194336), (26, 1.8830091953277588), (32, 2.3361740112304688), (29,
1.9658150672912598), (26, 1.5100517272949219), (26, 1.811798095703125), (32,
2.051542043685913), (26, 1.5136959552764893), (2, 0.44672513008117676)]\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.075s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.087s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.084s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.083s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.076s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.071s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.067s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.074s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.082s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.085s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.071s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.082s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.071s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.067s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.068s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.065s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.068s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.076s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.069s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.062s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.079s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.071s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.065s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.089s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.088s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.072s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.083s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.074s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.066s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.087s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.091s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.096s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.111s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=10\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.149s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n",
+ "INFO:opensearch_connector:Insert Embeddings in opensearch DB,
count=9\n",
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/_bulk [status:200
request:0.155s]\n",
+ "INFO:opensearch_connector:Insert Embeddings done\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Insertion Pipeline\n",
+ "import os\n",
+ "\n",
+ "artifact_location = tempfile.mkdtemp()\n",
+ "generate_embedding_fn =
SentenceTransformerEmbeddings(model_name='all-MiniLM-L6-v2',\n",
+ "
columns=['title','text'])\n",
+ "with beam.Pipeline() as p:\n",
+ " embeddings = (\n",
+ " p \n",
+ " | \"Read data\" >> beam.Create(contents)\n",
+ " | \"Generate text chunks\" >> ChunksGeneration(chunk_size = 500,
chunk_overlap = 0, chunking_strategy = ChunkingStrategy.SPLIT_BY_TOKENS)\n",
+ " | \"Insert document in openSearch\" >>
InsertDocInOpenSearch(host='https://localhost',
username=os.environ['OPENSEARCH_USERNAME'],
password=os.environ['OPENSEARCH_PASSWORD'], port=9200, batch_size = 10)\n",
+ " | \"Generate Embeddings\" >>
MLTransform(write_artifact_location=artifact_location).with_transform(generate_embedding_fn)
\n",
+ " | \"Insert Embedding in openSearch\" >>
InsertEmbeddingInOpenSearch(host='https://localhost',
username=os.environ['OPENSEARCH_USERNAME'],
password=os.environ['OPENSEARCH_PASSWORD'], port=9200, batch_size = 10,
embedded_columns=['title','text'])\n",
+ " )\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "c75493ee-e17f-447d-aaac-0c4b0f20d977",
+ "metadata": {},
+ "source": [
+ "### Pipeline Steps:\n",
+ "Now that we have ingested the documents in OpenSearch, we will create a
embeddings transform, which is used for storing the text and its embedding in
openSearch vector db"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "f546c5fe-44c7-4900-8e36-4dba3784fe2e",
+ "metadata": {},
+ "source": [
+ "# Running Search Queries/ Perform Enrichment"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "bcb0d1e2-0f46-47d3-9e08-e3ac15a589ed",
+ "metadata": {},
+ "source": [
+ "### Pipeline Steps:\n",
+ "Create a search transform, which emits the document Id, vector score
along with the matching text from knowledge base"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "021c77ad-9df7-438a-9fe1-3599fa8c02a2",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:root:Missing pipeline option (runner). Executing pipeline using
the default runner: DirectRunner.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "WARNING:root:This output type hint will be ignored and not used for
type-checking purposes. Typically, output type hints for a PTransform are
single (or nested) types wrapped by a PCollection, PDone, or None. Got:
Union[Tuple[apache_beam.pvalue.PCollection[~MLTransformOutputT],
apache_beam.pvalue.PCollection[apache_beam.pvalue.Row]],
apache_beam.pvalue.PCollection[~MLTransformOutputT]] instead.\n",
+ "INFO:apache_beam.runners.worker.statecache:Creating state cache with
size 104857600\n",
+ "INFO:sentence_transformers.SentenceTransformer:Load pretrained
SentenceTransformer: all-MiniLM-L6-v2\n",
+ "INFO:sentence_transformers.SentenceTransformer:Use pytorch device_name:
mps\n"
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "17eda44920fd403394c94fbc90598b6a",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Batches: 0%| | 0/1 [00:00<?, ?it/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1095:
InsecureRequestWarning: Unverified HTTPS request is being made to host
'localhost'. Adding certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
+ " warnings.warn(\n",
+ "INFO:opensearch:POST https://localhost:9200/embeddings-index/_search
[status:200 request:0.315s]\n",
+ "INFO:opensearch_enrichment:Enrichment_results\n",
+ "INFO:root:BatchElements statistics: element_count=1 batch_count=1
next_batch_size=1 timings=[]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Row(text=[0.005681279115378857, 0.09814242273569107,
0.012122008018195629, 0.0887078046798706, -0.032298486679792404,
0.010596378706395626, 0.01474417932331562, -0.04602375999093056,
-0.012696374207735062, 0.028775634244084358, -0.012717711739242077,
-0.16198472678661346, -0.003693335922434926, -0.015376407653093338,
-0.004146557301282883, -0.07635108381509781, -0.06286586076021194,
-0.036414001137018204, -0.021039914339780807, -0.062046296894550323,
-0.041434209793806076, 0.08710915595293045, -0.046050168573856354,
0.056758005172014236, -0.009660243056714535, -0.0029580420814454556,
-0.04717544838786125, 0.09012085944414139, -0.05081005021929741,
0.09703554213047028, -0.011215518228709698, 0.12284161895513535,
0.030584124848246574, 0.007557293400168419, -0.06626550853252411,
0.0706571638584137, 0.021545734256505966, -0.0142928846180439,
-0.06792338937520981, 0.033220842480659485, -0.0486346036195755,
-0.04314371198415756, 0.031225889921188354, -0.014775502495467663, 0.018826
227635145187, 0.054227981716394424, -0.0013915246818214655,
-0.00039128726348280907, -0.01888270489871502, -0.010042160749435425,
0.007374724373221397, 0.007213344797492027, -0.054922740906476974,
0.016170397400856018, -0.024535836651921272, 0.004130900371819735,
0.041324831545352936, -0.04924580454826355, -0.00425533065572381,
-0.021164026111364365, 0.058188874274492264, -0.011739853769540787,
-0.13507752120494843, 0.0721437856554985, 0.1771843284368515,
0.031882915645837784, -0.025050528347492218, 0.08608776330947876,
0.020403580740094185, -0.09845225512981415, -0.03746901825070381,
0.02342236042022705, -0.027697738260030746, 0.006044411566108465,
0.03889996558427811, -0.050257254391908646, -0.07993979752063751,
0.020754830911755562, 0.07185225933790207, 0.02081255428493023,
0.1313427835702896, 0.017618637531995773, 0.036315109580755234,
0.039130616933107376, 0.002599377417936921, -0.023098891600966454,
0.06570731848478317, 0.00942362379282713, 0.007448234595358372, -0.02594039030
3730965, -0.05076005309820175, -0.061320703476667404, 0.04196416586637497,
0.05426991730928421, -0.11683181673288345, 0.08997763693332672,
0.06656055897474289, -0.09679737687110901, 0.01438830140978098,
0.021942436695098877, 0.04176042973995209, -0.06397026777267456,
-0.014789748005568981, 0.04221726953983307, -0.01574830338358879,
-0.03686991706490517, -0.023309599608182907, -0.011977536603808403,
-0.0754874050617218, -0.040941011160612106, -0.11142314970493317,
-0.005921780131757259, -0.04780223220586777, -0.035676512867212296,
0.09115241467952728, -0.012657727114856243, -0.028934262692928314,
0.044572412967681885, 0.03891172260046005, -0.0014245702186599374,
-0.06251176446676254, 0.011252881027758121, 0.038343433290719986,
0.04719527065753937, 0.030142992734909058, -0.027092648670077324,
0.013735907152295113, -9.064392692192143e-33, 0.09711182862520218,
-0.08810975402593613, 0.0085729556158185, 0.061779558658599854,
0.06063861772418022, 0.05414735898375511, -0.06763742864131927,
-0.07622424513101578, -0.021068567410111427, -0.050364408642053604,
0.059802569448947906, 0.035146355628967285, -0.04217776283621788,
0.07488639652729034, 0.11884374171495438, 0.03298746049404144,
-0.09908874332904816, 0.11026792973279953, 0.03360074758529663,
0.06072094291448593, -0.07121853530406952, 0.11786828935146332,
0.021288855001330376, 0.0012666217517107725, 0.02136039361357689,
-0.028575904667377472, 0.01738251931965351, -0.002056707628071308,
-0.0225173719227314, 0.004767354112118483, 0.07275322824716568,
0.0008361118379980326, -0.035339657217264175, -0.012265999801456928,
0.06551198661327362, -0.028552060946822166, 0.01624898798763752,
0.030827082693576813, -0.0064664846286177635, 0.03804320842027664,
0.015972306951880455, -0.025012552738189697, 0.01537755224853754,
-0.019223276525735855, 0.051481299102306366, -0.03774404525756836,
0.031233150511980057, 0.010792077518999577, -0.07368049025535583,
0.03440165892243385, -0.08243195712566376, 0.027226915583014488, 0.03015479
0729284286, -0.06739982217550278, -0.023462530225515366, 0.004426364786922932,
0.049566030502319336, -0.0007644200813956559, -0.07741454243659973,
-0.048042215406894684, -0.00716590927913785, 0.047427188605070114,
0.007761705666780472, -0.052016228437423706, 0.06328984349966049,
0.016297178342938423, -0.02110602706670761, 0.06899832934141159,
0.017079640179872513, -0.0145488316193223, 0.0011159252608194947,
-0.01930522546172142, 0.04926059767603874, 0.0349489189684391,
-0.006899220868945122, 0.03899229317903519, 0.06309819221496582,
-0.0066454242914915085, -0.07372670620679855, 0.04072729870676994,
-0.14556884765625, 0.0006914717960171402, -0.062361959367990494,
-0.04005748778581619, -0.09577677398920059, -0.05768291652202606,
0.006099699530750513, 0.038168635219335556, 0.0875629261136055,
-0.019114116206765175, -0.07491258531808853, -0.04830453172326088,
0.044991254806518555, 0.02855900302529335, -0.006236312445253134,
4.431518928367989e-33, 0.016468225046992302, -0.041366953402757
645, -0.05195080116391182, 0.07035417854785919, -0.030740821734070778,
-0.023082340136170387, -0.01651252619922161, 0.09331605583429337,
-0.008752620778977871, 0.012143152765929699, -0.06566326320171356,
0.024135638028383255, 0.030180517584085464, -0.03348318487405777,
0.05472077801823616, -0.03931943327188492, 0.010327818803489208,
0.03856675699353218, -0.04030061513185501, 0.012255776673555374,
-0.03463425859808922, -0.07747091352939606, -0.05572936683893204,
-0.03225038945674896, -0.10840722918510437, -0.013168987818062305,
-0.005702188704162836, -0.07412929087877274, -0.059015996754169464,
0.05437948927283287, -0.01857663318514824, 0.009033560752868652,
-0.060668718069791794, 0.043119028210639954, -0.058562010526657104,
0.07000275701284409, 0.03340320289134979, -0.08098223060369492,
-0.0023121866397559643, -0.018825992941856384, 0.022753942757844925,
-0.07594940811395645, 0.05349994823336601, -0.02341049164533615,
0.04927574470639229, -0.004003552254289389, -0.010530486702919006
, 0.017115367576479912, 0.01464780978858471, -0.041996438056230545,
0.07430877536535263, 0.003752655116841197, -0.033113669604063034,
0.007742159999907017, 0.030825065448880196, -0.06152007728815079,
-0.05503644794225693, 0.03923992067575455, -0.01525651104748249,
0.028150508180260658, 0.03372741490602493, -0.04238812252879143,
0.024809187278151512, 0.03484528884291649, -0.003689933568239212,
-0.027012472972273827, -0.10401604324579239, -0.011824632994830608,
0.05680903419852257, 0.014070725068449974, 0.059544213116168976,
-0.012584686279296875, -0.053039971739053726, -0.04964359477162361,
0.026148391887545586, -0.019395308569073677, 0.010759079828858376,
0.006110578775405884, -0.028808584436774254, 0.05174006149172783,
-0.11077475547790527, -0.01716303825378418, 0.0326368547976017,
-0.009568588808178902, 0.007690761238336563, -0.038692720234394073,
0.012096617370843887, -0.04417848959565163, 0.03717269375920296,
0.03239520266652107, -0.01718258112668991, -0.022670328617095947, -0.1
1932598799467087, 0.061879467219114304, -0.06490951031446457,
-1.6962180993118636e-08, 0.03727492317557335, -0.019305847585201263,
0.07617775350809097, 0.02464691922068596, -0.015920404344797134,
0.017603004351258278, 0.08891281485557556, -0.0357368141412735,
0.0724138393998146, 0.06772797554731369, 0.041177406907081604,
0.06650552898645401, 0.03731708973646164, 0.06186262518167496,
-0.010852903127670288, -0.07151525467634201, 0.02877056784927845,
0.016495751217007637, -0.03198529779911041, 0.015418753027915955,
0.022311268374323845, -0.027661170810461044, -0.0050356448628008366,
0.003294565947726369, 0.08959522843360901, -0.0035225984174758196,
0.01716471277177334, 0.1193658709526062, 0.014731936156749725,
0.02266616001725197, -0.006523279007524252, -0.0370447151362896,
0.012390590272843838, -0.06600089371204376, -0.08307910710573196,
0.0005763241788372397, 0.033871740102767944, 0.04716432839632034,
-0.04934931918978691, -0.10628699511289597, 0.014108057133853436,
0.120253942906856
54, -0.047137390822172165, 0.03903830051422119, 0.05448715388774872,
-0.05407202988862991, -0.0023585218004882336, 0.12397951632738113,
-0.0767904594540596, 0.0384405180811882, -0.06004812940955162,
0.013117415830492973, 0.028648486360907555, 0.04754413291811943,
-0.027484044432640076, -0.026353582739830017, -0.02025582268834114,
-0.032462604343891144, 0.015371875837445259, 0.04709600284695625,
0.003952603787183762, -0.011315188370645046, -0.03685474023222923,
0.00038126850267872214], docs={'took': 268, 'timed_out': False, '_shards':
{'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total':
{'value': 1, 'relation': 'eq'}, 'max_score': 0.49309593, 'hits': [{'_index':
'embeddings-index', '_id': '39', '_score': 0.49309593, '_source': {'url':
'https://en.wikipedia.org/wiki/Albedo', 'title': 'Albedo', 'text': 'climate
forcing climatology electromagnetic radiation meteorological quantities
radiometry scattering, absorption and radiative transfer ( optics ) radiation
1760
s neologisms', 'section_id': 21, 'text_vector': [0.05804199352860451,
0.019180934876203537, 0.09386835247278214, 0.033248722553253174,
0.07321974635124207, -0.06583535671234131, -0.02710530534386635,
-0.01813305728137493, -0.03650573641061783, 0.01482625212520361,
0.006794636603444815, -0.13602526485919952, 0.06769848614931107,
-0.033854756504297256, 0.05042634904384613, -0.004122156649827957,
-0.06743299216032028, -0.0570233017206192, -0.010083557106554508,
0.06531564891338348, -0.08385802060365677, 0.05435376614332199,
-0.12301676720380783, -0.04512578994035721, 0.07984061539173126,
-0.032914698123931885, -0.06116824969649315, 0.004940391983836889,
-0.02287699654698372, 0.07553019374608994, -0.03370917588472366,
0.08948028832674026, -0.039525799453258514, 0.04850710928440094,
0.015310029499232769, 0.025836292654275894, 0.06660918891429901,
-0.04138422757387161, -0.07654143869876862, 0.09660261869430542,
-0.002820968860760331, -0.06370793282985687, 0.026600921526551247, -0.00925880
0186216831, -0.06274925917387009, 0.029181070625782013, 0.008946373127400875,
-0.0010660203406587243, -0.02307073585689068, 0.0005594529793597758,
0.026646152138710022, -0.011643539182841778, -0.10360316932201385,
0.052122052758932114, 0.014761701226234436, -0.016778497025370598,
-0.006691457238048315, -0.025380102917551994, -0.018139487132430077,
0.02875414490699768, -0.03719620034098625, 0.017045706510543823,
-0.15674161911010742, 0.0006721448735333979, 0.1240653544664383,
0.007082130294293165, -0.01567394658923149, 0.06011847406625748,
0.02267984300851822, -0.03894032910466194, -0.002440924756228924,
0.03705919533967972, -0.05879739671945572, -0.07367047667503357,
-0.00963670201599598, 0.029749274253845215, -0.013559574261307716,
0.07305314391851425, 0.02973465994000435, -0.05845826491713524,
0.05252765119075775, -0.013243412598967552, -0.02982352487742901,
0.01506885513663292, 0.02961100824177265, 0.04031624644994736,
-0.01480705477297306, 0.056202057749032974, 0.048843096941709
52, -0.0019400937017053366, -0.05448821932077408, -0.08753833174705505,
-0.024709131568670273, 0.02624904178082943, -0.0929911881685257,
0.07247067987918854, 0.03994099795818329, -0.038704387843608856,
0.0364781878888607, 0.01864197850227356, 0.02348715253174305,
-0.06507222354412079, -0.011644909158349037, 0.08411170542240143,
-0.09156891703605652, -0.07163530588150024, 0.01077653095126152,
0.0012725696433335543, -0.0830242931842804, -0.03570006415247917,
-0.03272044658660889, 0.008162498474121094, -0.04583418369293213,
-0.05320226773619652, 0.08912798762321472, 0.025588545948266983,
-0.038817159831523895, 0.03483380749821663, 0.004065918270498514,
-0.09861799329519272, -0.06974266469478607, 0.06915479153394699,
0.03233233094215393, 0.12934881448745728, 0.04110410436987877,
0.01895003393292427, 0.04632483050227165, 1.9490846117045425e-33,
0.04642464593052864, 0.09227989614009857, 0.01089081447571516,
0.018505625426769257, 0.023978224024176598, 0.033948201686143875,
0.00608262885361
9099, -0.009351077489554882, -0.00469066621735692, -0.016683686524629593,
-0.00024298056086990982, 0.15513195097446442, -0.0042563253082334995,
0.002793639898300171, 0.04522101208567619, 0.010473635047674179,
-0.007585475686937571, 0.04404710978269577, -0.07431968301534653,
0.03812774270772934, -0.10481490194797516, 0.05955547094345093,
0.005027147475630045, -0.019220538437366486, -0.028199534863233566,
-0.007959562353789806, -0.004215007647871971, 0.02377588115632534,
0.017516866326332092, 0.03316710889339447, 0.07169432938098907,
0.04769729822874069, 0.0010682286228984594, 0.052743420004844666,
0.023693431168794632, -0.06710502505302429, -0.028020508587360382,
-0.004339328035712242, 0.04562166705727577, 0.05578581243753433,
0.08749880641698837, 0.05230626091361046, 0.008993973955512047,
0.036007463932037354, 0.0972859188914299, -0.051642291247844696,
0.004628113936632872, -0.013482089154422283, 0.027206838130950928,
0.030033249408006668, -0.0746486634016037, 0.01114337332546711, 0
.0012453565141186118, -0.07753480225801468, 0.02053624950349331,
-0.01870746538043022, 0.03381838649511337, 0.03585747256875038,
-0.08973295986652374, -0.030302995815873146, 0.0024447792675346136,
-0.04943104460835457, 0.1045609563589096, -0.08301200717687607,
0.06991124153137207, 0.037200678139925, -0.06195773929357529,
0.023068783804774284, -0.06633616238832474, -0.01620880514383316,
-0.03590766340494156, 0.03218387812376022, -0.023437628522515297,
0.018856758251786232, 0.1020791158080101, -0.036745648831129074,
0.049397483468055725, 0.0430767796933651, -0.020289452746510506,
0.09302733838558197, -0.12508714199066162, 0.01679845154285431,
-0.04822757467627525, -0.08409176021814346, -0.03320956975221634,
-0.013366620987653732, 0.000212898914469406, -0.014611979015171528,
0.007254236843436956, -0.004831068217754364, -0.023121751844882965,
0.04325709491968155, -0.027649452909827232, -0.025940170511603355,
-0.04890282452106476, -2.739116365134955e-33, -0.0015312455361708999, 0.0214371
9419836998, -0.04023793712258339, 0.015745926648378372, -0.04509530961513519,
-0.007700340356677771, -0.011140515096485615, 0.03782216086983681,
-0.05042675510048866, -0.005663947202265263, 0.03497037664055824,
0.07029367238283157, -0.06521521508693695, -0.05485863983631134,
-0.06450261175632477, -0.07108244299888611, 0.088548943400383,
0.02204764448106289, -0.058771099895238876, -0.05222069099545479,
-0.02005583420395851, -0.013264605775475502, 0.051731158047914505,
-0.025393567979335785, -0.06818576157093048, -0.02799888141453266,
0.15002550184726715, -0.048350393772125244, -0.01078059896826744,
0.006916997954249382, -0.0820278525352478, 0.03466201573610306,
0.003472321666777134, 0.047827284783124924, -0.0029683574102818966,
0.049498625099658966, 0.12073739618062973, 0.018451353535056114,
-0.07764303684234619, -0.05074506625533104, -0.03487763553857803,
-0.021204574033617973, 0.07984967529773712, -0.04147111251950264,
-0.013316069729626179, -0.03082849644124508, -0.042857371270656
586, 0.0654129609465599, -0.017997432500123978, -0.02896551974117756,
0.0774027407169342, -0.052063118666410446, 0.0019760732538998127,
0.047902911901474, -0.027103612199425697, 0.02023342438042164,
0.015308177098631859, 0.04383513703942299, -0.0024700332432985306,
-0.04272732511162758, -0.0071661826223134995, 0.014355546794831753,
-0.016396569088101387, -0.10066907852888107, 0.010225103236734867,
-0.0019878142047673464, -0.026217082515358925, 0.051486607640981674,
-0.06625217199325562, 0.04823102429509163, -0.011498776264488697,
-0.07307113707065582, -0.04205445572733879, 0.006961566861718893,
0.016726691275835037, 0.05119403079152107, 0.021941224113106728,
-0.027263469994068146, -0.061235904693603516, 0.07649876177310944,
-0.09249082207679749, 0.018923336640000343, -0.03572014719247818,
0.042984046041965485, 0.06908431649208069, -0.056479182094335556,
0.02348567359149456, -0.10372753441333771, -0.0234976913779974,
-0.021976150572299957, 0.013660279102623463, 0.018236475065350533,
0.0259736105799675, 0.03510850667953491, 0.007861043326556683,
-2.5516687429671947e-08, 0.03811834007501602, 0.01664789393544197,
0.001784705906175077, 0.045456141233444214, 0.0007396372966468334,
0.07324232906103134, -0.012037951499223709, -0.055410344153642654,
-0.003944666590541601, 0.0226755291223526, -0.0478028878569603,
0.06722766160964966, 0.1107492446899414, 0.04581346735358238,
0.024947471916675568, -0.09989751875400543, 0.056000784039497375,
-0.11560197174549103, -0.04150085896253586, -0.03551061078906059,
-0.004503386560827494, -0.006662018597126007, 0.017425045371055603,
0.020292893052101135, 0.0695989578962326, 0.07105210423469543,
0.03749624639749527, 0.036694109439849854, 0.05183475837111473,
0.005564447026699781, 0.016880596056580544, -0.05458332598209381,
0.012904755771160126, -0.0631595030426979, -0.12805376946926117,
0.038382697850465775, -0.048901237547397614, 0.037066832184791565,
-0.073575958609581, -0.029148872941732407, 0.028412597253918648,
0.069802917540073
4, -0.009894277900457382, 0.04922999069094658, 0.03697966784238815,
0.03569600358605385, 0.019079145044088364, 0.02015037089586258,
-0.018478017300367355, 0.07887936383485794, -0.005431294906884432,
-0.020281381905078888, 0.026848675683140755, -0.010159590281546116,
-0.0680966004729271, -0.08367855846881866, -0.009673567488789558,
-0.07237613201141357, 0.021852456033229828, 0.011179106310009956,
0.046719297766685486, -0.02577531524002552, -0.06697163730859756,
0.05171067267656326], 'title_vector': [0.013871673494577408,
0.08505004644393921, 0.06745029985904694, 0.07190897315740585,
0.0717221200466156, -0.0813683420419693, 0.07795434445142746,
-0.013351780362427235, -0.0323372408747673, 0.033296190202236176,
0.06557994335889816, -0.11560765653848648, 0.07021912187337875,
0.0034852621611207724, -0.0036208005622029305, 0.046930860728025436,
0.058591220527887344, -0.002149759093299508, -0.10680060088634491,
0.05791370943188667, 0.048783037811517715, 0.0437125638127327, -0.01862856373190
8798, -0.002488004509359598, 0.05101776868104935, -0.006392291281372309,
-0.034481339156627655, 0.033687859773635864, -0.012814278714358807,
-0.04080303758382797, 0.032355617731809616, 0.027568073943257332,
-0.012328441254794598, -0.010766926221549511, 0.021852534264326096,
-0.013756212778389454, -0.06071024760603905, -0.06361404061317444,
-0.075678750872612, 0.039502888917922974, -0.024492893368005753,
-0.04402804747223854, 0.005714223254472017, 0.03754258528351784,
-0.019903628155589104, -0.033278223127126694, 0.013432477600872517,
0.06467465311288834, 0.024031758308410645, 0.02782731130719185,
0.10572017729282379, -0.027800127863883972, -0.08924444764852524,
0.011174924671649933, -0.000989794498309493, -0.037875428795814514,
-0.05314259231090546, 0.049672339111566544, -0.013368085026741028,
-0.04712530970573425, 0.0394635833799839, -0.0016417341539636254,
-0.05948677286505699, 0.02296137623488903, 0.10468285530805588,
-0.012734255753457546, -0.05988132953643799, -0.07033392786979
675, -0.08780375868082047, -0.027665268629789352, 0.019438255578279495,
-0.005465452093631029, -0.04404197260737419, -0.06469105929136276,
0.05034284293651581, 0.019024968147277832, -0.041422564536333084,
-0.028322789818048477, -0.048727553337812424, -0.03588132560253143,
0.050338611006736755, 0.010361555963754654, -0.02756672352552414,
0.07597655057907104, 0.051102377474308014, -0.03364323079586029,
0.0056414310820400715, 0.01578383706510067, -0.0005366085679270327,
-0.005252146627753973, 0.001267138635739684, -0.0022668209858238697,
-0.1423100233078003, -0.01621747948229313, -0.15988744795322418,
0.00838597770780325, 0.019600020721554756, -0.017082588747143745,
-0.02059156633913517, 0.10465475171804428, -0.02530570700764656,
-0.025743642821907997, -0.11063812673091888, 0.0015572374686598778,
-0.024665316566824913, 0.00795584637671709, 0.10474486649036407,
0.03240552917122841, -0.03940945118665695, 0.0009841503342613578,
-0.010407809168100357, -0.05619907006621361, -0.0863342136144
638, -0.01605527475476265, 0.034691888839006424, -0.04493538290262222,
0.06363692134618759, -0.00309903547167778, -0.04296952486038208,
-0.06596419960260391, 0.014694305136799812, 0.02235587127506733,
0.08640886843204498, 0.12842385470867157, -0.008202667348086834,
-0.1029563769698143, 0.035974740982055664, -2.7466452227809794e-33,
-0.019207432866096497, 0.04974474757909775, 0.011923236772418022,
-0.012429367750883102, 0.042110953480005264, -0.08688521385192871,
0.003660398768261075, 0.014049333520233631, -0.0527566522359848,
-0.06247904896736145, 0.029624704271554947, 0.04720746725797653,
0.04221683740615845, 0.017664257436990738, 0.09799699485301971,
0.059284161776304245, 0.010577351786196232, 0.0038441787473857403,
0.04062353074550629, 0.02895088866353035, -0.06448862701654434,
0.07502465695142746, 0.023084327578544617, 0.06647097319364548,
-0.029812434688210487, 0.014314568601548672, 0.0396641381084919,
-0.05885646864771843, -0.14109651744365692, 0.014322447590529919, 0.05117564
2758607864, 0.0030856768134981394, -0.03952622041106224,
-0.020461637526750565, -0.04967942833900452, 0.09467776864767075,
-0.012616656720638275, 0.04060185328125954, 0.0554870069026947,
-0.004325194284319878, -0.04711341857910156, 0.00591842457652092,
0.08127032965421677, 0.03242846205830574, 0.06234855204820633,
0.050466086715459824, 0.04058535769581795, 0.009674785658717155,
0.0068300641141831875, 0.0642416849732399, 0.004475779831409454,
-0.0010642283596098423, -0.029470669105648994, -0.02928251586854458,
-0.049615852534770966, 0.030298462137579918, -0.011685963720083237,
-0.008160766214132309, -0.03713754191994667, -0.0019368557259440422,
-0.025327827781438828, -0.0012221481883898377, 0.007771190721541643,
-0.013025721535086632, -0.0580441989004612, 0.029063884168863297,
-0.0013216000515967607, 0.007832043804228306, -0.0480717271566391,
-0.034898631274700165, -0.1256249099969864, 0.004148976877331734,
0.10679567605257034, 0.0177405197173357, -0.05163440480828285, 0.036371085792
77992, 0.054222188889980316, -0.05042252689599991, 0.012214320711791515,
0.05719371512532234, -0.1300114244222641, 0.05899804085493088,
-0.00369597808457911, -0.17539913952350616, -0.11795870214700699,
-0.05081646516919136, 0.002162967110052705, 0.04295330122113228,
-0.008931492455303669, -0.012073107063770294, 0.06710132211446762,
0.05208844318985939, 0.024892348796129227, -0.0626751109957695,
-0.04800526797771454, 1.2274306299774932e-33, 0.044484205543994904,
-0.03720114752650261, 0.052586108446121216, 0.024951860308647156,
0.00917955581098795, -0.01875164918601513, -0.04975622147321701,
0.05612529069185257, -0.05679228901863098, 0.018653172999620438,
0.021326258778572083, 0.06542685627937317, 0.028135403990745544,
-0.0848727747797966, 0.011612195521593094, -0.008994381874799728,
0.03309926763176918, 0.022644203156232834, 0.0003658912028186023,
-0.01731560006737709, -0.054763149470090866, 0.06617787480354309,
0.09764867275953293, -0.03965075686573982, -0.1150868684053421, 0.017569
545656442642, 0.02591414377093315, -0.025876250118017197, 0.0380278117954731,
-0.005403239745646715, -0.03834784775972366, 0.036729805171489716,
-0.013243885710835457, -0.009292075410485268, -0.029130056500434875,
0.10292569547891617, 0.04479241743683815, 0.015336520969867706,
-0.15163619816303253, 0.03041689097881317, 0.04951431229710579,
-0.06061789020895958, 0.06082547456026077, -0.043235305696725845,
0.025013500824570656, 0.021550936624407768, 0.03503071144223213,
0.04791894182562828, 0.01649720035493374, 0.020053740590810776,
0.14445678889751434, -0.025187302380800247, -0.020110158249735832,
0.05985400825738907, 0.004412578418850899, 0.020647289231419563,
-0.049116771668195724, 0.06811757385730743, 0.00762582290917635,
0.009756582789123058, 0.05438239127397537, 0.008561545051634312,
0.04419432953000069, -0.012601385824382305, -0.05435527116060257,
0.011487817391753197, -0.03566557914018631, 0.07810325920581818,
-0.012478441931307316, 0.07364337146282196, 0.015212902799248695, -
0.003787972265854478, -0.10727659612894058, -0.03103616088628769,
0.004969234578311443, -0.03861144557595253, 0.053296491503715515,
-0.05650511011481285, -0.12793289124965668, 0.027744235470891,
-0.11922869086265564, 0.004261502996087074, -0.026993146166205406,
0.02278282307088375, 0.12168323248624802, -0.04543069377541542,
-0.057791080325841904, -0.08187830448150635, -0.04295971244573593,
0.01920100301504135, -0.07544126361608505, 0.011067227460443974,
-0.03378983587026596, 0.019486458972096443, -0.03936194255948067,
-1.2017616235482365e-08, -0.009733341634273529, 0.06930302828550339,
0.053493428975343704, -0.0017172248335555196, -0.005070843733847141,
0.0003074264095630497, 0.06679464131593704, 0.006521554663777351,
0.009403458796441555, -0.0010474337032064795, -0.0075946166180074215,
0.02225925587117672, 0.07693614810705185, 0.0654897391796112,
0.0004406787920743227, 0.01532474160194397, -0.014464792795479298,
-0.029232194647192955, 0.0035958753433078527, -0.025999752804636955, -
3.379421104909852e-05, -0.014475241303443909, -0.018970970064401627,
-0.06003565341234207, 0.017660539597272873, 0.07505448907613754,
-0.011004934087395668, 0.04363846406340599, 0.018838267773389816,
0.03321292623877525, 0.006528213154524565, -0.02431287243962288,
0.04418541118502617, -0.0792684480547905, 0.05507836118340492,
-0.003553958609700203, 0.005769619718194008, 0.034745652228593826,
-0.029339710250496864, 0.03410865738987923, -0.058698661625385284,
0.0014589643105864525, 0.06204773485660553, 0.03347153589129448,
0.0021305792033672333, -0.019758161157369614, 0.029250087216496468,
-0.02641558274626732, 0.03072372078895569, 0.017234161496162415,
0.041027482599020004, -0.11647339165210724, -0.04050833731889725,
0.016313651576638222, -0.061410967260599136, -0.04537799209356308,
0.032567236572504044, -0.014318760484457016, 0.018752068281173706,
0.044621992856264114, 0.09515165537595749, -0.03454163298010826,
-0.041815146803855896, 0.05678379163146019]}}]}})\n"
Review Comment:
Done
##########
examples/notebooks/beam-ml/rag_usecase/opensearch_enrichment.py:
##########
@@ -0,0 +1,130 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""This module implements enrichment classes to implement semantic search on
opensearch Vector DB.
+
+
+opensearch :Enrichment Handler
+-----------------
+:class:`opensearchEnrichmentHandler` is a ``EnrichmentSourceHandler`` that
performs enrichment/search
+by fetching the similar text to the user query/prompt from the knowledge base
(opensearch vector DB) and returns
+the similar text along with its embeddings as Beam.Row Object.
+
+Example usage::
+ opensearch_handler =
opensearchEnrichmentHandler(opensearch_host='127.0.0.1', opensearch_port=6379)
+
+ pipeline | Enrichment(opensearch_handler)
+
+No backward compatibility guarantees. Everything in this module is
experimental.
+"""
+
+import logging
+
+
+from opensearchpy import OpenSearch
+from typing import Optional
+import os
+
+import apache_beam as beam
+from apache_beam.transforms.enrichment import EnrichmentSourceHandler
+from apache_beam.transforms.enrichment_handlers.utils import ExceptionLevel
+
+__all__ = [
+ 'OpenSearchEnrichmentHandler',
+]
+
+# Set the logging level to reduce verbose information
+import logging
+
+logging.root.setLevel(logging.INFO)
+logger = logging.getLogger(__name__)
+
+
+class OpenSearchEnrichmentHandler(EnrichmentSourceHandler[beam.Row, beam.Row]):
+ """A handler for :class:`apache_beam.transforms.enrichment.Enrichment`
+ transform to interact with opensearch vector DB.
+ """
+ def __init__(
+ self,
+ opensearch_host: str,
+ opensearch_port: int,
+ username: Optional[str] = os.getenv("OPENSEARCH_USERNAME"),
+ password: Optional[str] = os.getenv("OPENSEARCH_PASSWORD"),
+ index_name: str = "embeddings-index",
+ vector_field: str = "text_vector",
+ k: int = 1,
+ ):
+
+ """Args:
+ opensearch_host (str): opensearch Host to connect to opensearch DB
+ opensearch_port (int): opensearch Port to connect to opensearch DB
+ index_name (str): Index Name created for searching in opensearch DB
+ vector_field (str): vector field to compute similarity score in
vector DB
+ k (int): Value of K in KNN algorithm for searching in opensearch
+ """
+ self.opensearch_host = opensearch_host
+ self.opensearch_port = opensearch_port
+ self.username = username
+ self.password = password
+ self.index_name = index_name
+ self.vector_field = vector_field
+ self.k = k
+ self.client = None
+
+ def __enter__(self):
+ """connect to the opensearch DB using opensearch client.
+ """
+
+ if self.client is None:
+ http_auth = [self.username, self.password]
+ self.client =
OpenSearch(hosts=[f'{self.opensearch_host}:{self.opensearch_port}'],
+ http_auth=http_auth,
+ verify_certs=False)
+
+ def __call__(self, request: beam.Row, *args, **kwargs):
+ """
+ Reads a row from the opensearch Vector DB and returns
+ a `Tuple` of request and response.
+
+ Args:
+ request: the input `beam.Row` to enrich.
+ """
+
+ # read embedding vector for user query
+
+ embedded_query = request['text']
+
+ # Prepare the Query
+ query = {
+ 'size': 5,
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]