Dingofrom langchain.document_loaders import TextLoaderfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/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()from dingodb import DingoDBindex_name = "langchain-demo"dingo_client = DingoDB(user="", password="", host=["127.0.0.1:13000"])# First, check if our index already exists. If it doesn't, we create itif index_name not in dingo_client.get_index():    # we create a new index, modify to your own    dingo_client.create_index(      index_name=index_name,      dimension=1536,      metric_type='cosine',      auto_id=False)# The OpenAI embedding model `text-embedding-ada-002 uses 1536 dimensions`docsearch = Dingo.from_documents(docs, embeddings, client=dingo_client, index_name=index_name)from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import Dingofrom langchain.document_loaders import TextLoaderquery = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query)print(docs[0].page_content)Adding More Text to an Existing Index‚ÄãMore text can embedded and upserted to an existing Dingo index using the add_texts functionvectorstore = Dingo(embeddings, "text", client=dingo_client, index_name=index_name)vectorstore.add_texts(["More text!"])Maximal Marginal Relevance Searches‚ÄãIn addition to using similarity search in the retriever object, you can also use mmr as retriever.retriever = docsearch.as_retriever(search_type="mmr")matched_docs = retriever.get_relevant_documents(query)for i, d in enumerate(matched_docs):    print(f"\n## Document {i}\n")    print(d.page_content)Or use max_marginal_relevance_search directly:found_docs = docsearch.max_marginal_relevance_search(query, k=2, fetch_k=10)for i, doc in
Dingo is a distributed multi-mode vector database, which combines the characteristics of data lakes and vector databases, and can store data of any type and size (Key-Value, PDF, audio, video, etc.). It has real-time low-latency processing capabilities to achieve rapid insight and response, and can efficiently conduct instant analysis and process multi-modal data.
Dingo is a distributed multi-mode vector database, which combines the characteristics of data lakes and vector databases, and can store data of any type and size (Key-Value, PDF, audio, video, etc.). It has real-time low-latency processing capabilities to achieve rapid insight and response, and can efficiently conduct instant analysis and process multi-modal data. ->: Dingofrom langchain.document_loaders import TextLoaderfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/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()from dingodb import DingoDBindex_name = "langchain-demo"dingo_client = DingoDB(user="", password="", host=["127.0.0.1:13000"])# First, check if our index already exists. If it doesn't, we create itif index_name not in dingo_client.get_index():    # we create a new index, modify to your own    dingo_client.create_index(      index_name=index_name,      dimension=1536,      metric_type='cosine',      auto_id=False)# The OpenAI embedding model `text-embedding-ada-002 uses 1536 dimensions`docsearch = Dingo.from_documents(docs, embeddings, client=dingo_client, index_name=index_name)from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import Dingofrom langchain.document_loaders import TextLoaderquery = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query)print(docs[0].page_content)Adding More Text to an Existing Index‚ÄãMore text can embedded and upserted to an existing Dingo index using the add_texts functionvectorstore = Dingo(embeddings, "text", client=dingo_client, index_name=index_name)vectorstore.add_texts(["More text!"])Maximal Marginal Relevance Searches‚ÄãIn addition to using similarity search in the retriever object, you can also use mmr as retriever.retriever = docsearch.as_retriever(search_type="mmr")matched_docs = retriever.get_relevant_documents(query)for i, d in enumerate(matched_docs):    print(f"\n## Document {i}\n")    print(d.page_content)Or use max_marginal_relevance_search directly:found_docs = docsearch.max_marginal_relevance_search(query, k=2, fetch_k=10)for i, doc in