To run, you should have an OpenSearch Vector Search Edition instance up and running:Read the help document to quickly familiarize and configure OpenSearch Vector Search Edition instance.After the instance is up and running, follow these steps to split documents, get embeddings, connect to the alibaba cloud opensearch instance, index documents, and perform vector retrieval.We need to install the following Python packages first.#!pip install alibabacloud_ha3engine_vectorWe want to use OpenAIEmbeddings so we have to get the OpenAI API Key.import osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import (    AlibabaCloudOpenSearch,    AlibabaCloudOpenSearchSettings,)Split documents and get embeddings.from langchain.document_loaders import TextLoaderloader = TextLoader("../../../state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()Create opensearch settings.settings = AlibabaCloudOpenSearchSettings(    endpoint=" The endpoint of opensearch instance, You can find it from the console of Alibaba Cloud OpenSearch.",    instance_id="The identify of opensearch instance, You can find it from the console of Alibaba Cloud OpenSearch.",    protocol="Communication Protocol between SDK and Server, default is http.",    username="The username specified when purchasing the instance.",    password="The password specified when purchasing the instance.",    namespace="The instance data will be partitioned based on the namespace field. If the namespace is enabled, you need to specify the namespace field name during initialization. Otherwise, the queries cannot be executed correctly.",    tablename="The table name specified during instance configuration.",
Alibaba Cloud Opensearch is a one-stop platform to develop intelligent search services. OpenSearch was built on the large-scale distributed search engine developed by Alibaba. OpenSearch serves more than 500 business cases in Alibaba Group and thousands of Alibaba Cloud customers. OpenSearch helps develop search services in different search scenarios, including e-commerce, O2O, multimedia, the content industry, communities and forums, and big data query in enterprises.
Alibaba Cloud Opensearch is a one-stop platform to develop intelligent search services. OpenSearch was built on the large-scale distributed search engine developed by Alibaba. OpenSearch serves more than 500 business cases in Alibaba Group and thousands of Alibaba Cloud customers. OpenSearch helps develop search services in different search scenarios, including e-commerce, O2O, multimedia, the content industry, communities and forums, and big data query in enterprises. ->: To run, you should have an OpenSearch Vector Search Edition instance up and running:Read the help document to quickly familiarize and configure OpenSearch Vector Search Edition instance.After the instance is up and running, follow these steps to split documents, get embeddings, connect to the alibaba cloud opensearch instance, index documents, and perform vector retrieval.We need to install the following Python packages first.#!pip install alibabacloud_ha3engine_vectorWe want to use OpenAIEmbeddings so we have to get the OpenAI API Key.import osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import (    AlibabaCloudOpenSearch,    AlibabaCloudOpenSearchSettings,)Split documents and get embeddings.from langchain.document_loaders import TextLoaderloader = TextLoader("../../../state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()Create opensearch settings.settings = AlibabaCloudOpenSearchSettings(    endpoint=" The endpoint of opensearch instance, You can find it from the console of Alibaba Cloud OpenSearch.",    instance_id="The identify of opensearch instance, You can find it from the console of Alibaba Cloud OpenSearch.",    protocol="Communication Protocol between SDK and Server, default is http.",    username="The username specified when purchasing the instance.",    password="The password specified when purchasing the instance.",    namespace="The instance data will be partitioned based on the namespace field. If the namespace is enabled, you need to specify the namespace field name during initialization. Otherwise, the queries cannot be executed correctly.",    tablename="The table name specified during instance configuration.",