mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 04:07:54 +00:00
community: Add deprecation decorator to SingleStore community integrations (#30846)
SingleStore integration now has its package `langchain-singlestore', so the community implementation will no longer be maintained. Added `deprecated` decorator to `SingleStoreDBChatMessageHistory`, `SingleStoreDBSemanticCache`, and `SingleStoreDB` classes in the community package. **Dependencies:** https://github.com/langchain-ai/langchain/pull/30841 --------- Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
parent
34ddfba76b
commit
d0cd115356
@ -1,28 +0,0 @@
|
||||
# SingleStoreDB
|
||||
|
||||
>[SingleStoreDB](https://singlestore.com/) is a high-performance distributed SQL database that supports deployment both in the [cloud](https://www.singlestore.com/cloud/) and on-premises. It provides vector storage, and vector functions including [dot_product](https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/dot_product.html) and [euclidean_distance](https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/euclidean_distance.html), thereby supporting AI applications that require text similarity matching.
|
||||
|
||||
## Installation and Setup
|
||||
|
||||
There are several ways to establish a [connection](https://singlestoredb-python.labs.singlestore.com/generated/singlestoredb.connect.html) to the database. You can either set up environment variables or pass named parameters to the `SingleStoreDB constructor`.
|
||||
Alternatively, you may provide these parameters to the `from_documents` and `from_texts` methods.
|
||||
|
||||
```bash
|
||||
pip install singlestoredb
|
||||
```
|
||||
|
||||
## Vector Store
|
||||
|
||||
See a [usage example](/docs/integrations/vectorstores/singlestoredb).
|
||||
|
||||
```python
|
||||
from langchain_community.vectorstores import SingleStoreDB
|
||||
```
|
||||
|
||||
## Memory
|
||||
|
||||
See a [usage example](/docs/integrations/memory/singlestoredb_chat_message_history).
|
||||
|
||||
```python
|
||||
from langchain.memory import SingleStoreDBChatMessageHistory
|
||||
```
|
@ -1,121 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ab66dd43",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# SingleStoreDB\n",
|
||||
"\n",
|
||||
">[SingleStoreDB](https://singlestore.com/) is a high-performance distributed SQL database that supports deployment both in the [cloud](https://www.singlestore.com/cloud/) and on-premises. It provides vector storage, and vector functions including [dot_product](https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/dot_product.html) and [euclidean_distance](https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/euclidean_distance.html), thereby supporting AI applications that require text similarity matching. \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"This notebook shows how to use a retriever that uses `SingleStoreDB`.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "51b49135-a61a-49e8-869d-7c1d76794cd7",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Establishing a connection to the database is facilitated through the singlestoredb Python connector.\n",
|
||||
"# Please ensure that this connector is installed in your working environment.\n",
|
||||
"%pip install --upgrade --quiet singlestoredb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aaf80e7f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Create Retriever from vector store"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "bcb3c8c2",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.\n",
|
||||
"if \"OPENAI_API_KEY\" not in os.environ:\n",
|
||||
" os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n",
|
||||
"\n",
|
||||
"from langchain_community.document_loaders import TextLoader\n",
|
||||
"from langchain_community.vectorstores import SingleStoreDB\n",
|
||||
"from langchain_openai import OpenAIEmbeddings\n",
|
||||
"from langchain_text_splitters import CharacterTextSplitter\n",
|
||||
"\n",
|
||||
"loader = TextLoader(\"../../how_to/state_of_the_union.txt\")\n",
|
||||
"documents = loader.load()\n",
|
||||
"text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)\n",
|
||||
"docs = text_splitter.split_documents(documents)\n",
|
||||
"\n",
|
||||
"embeddings = OpenAIEmbeddings()\n",
|
||||
"\n",
|
||||
"# Setup connection url as environment variable\n",
|
||||
"os.environ[\"SINGLESTOREDB_URL\"] = \"root:pass@localhost:3306/db\"\n",
|
||||
"\n",
|
||||
"# Load documents to the store\n",
|
||||
"docsearch = SingleStoreDB.from_documents(\n",
|
||||
" docs,\n",
|
||||
" embeddings,\n",
|
||||
" table_name=\"notebook\", # use table with a custom name\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# create retriever from the vector store\n",
|
||||
"retriever = docsearch.as_retriever(search_kwargs={\"k\": 2})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fc0915db",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Search with retriever"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "b605284d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"result = retriever.invoke(\"What did the president say about Ketanji Brown Jackson\")\n",
|
||||
"print(docs[0].page_content)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@ -31,7 +31,14 @@
|
||||
"\n",
|
||||
"| Class | Package | JS support |\n",
|
||||
"| :--- | :--- | :---: |\n",
|
||||
"| SingleStoreVectorStore | langchain_singlestore | ✅ | "
|
||||
"| SingleStoreVectorStore | langchain_singlestore | ✅ | \n",
|
||||
"\n",
|
||||
":::note\n",
|
||||
"\n",
|
||||
"For the langchain-community version `SingleStoreDB` (deprecated), see\n",
|
||||
"the [v0.2 documentation](https://python.langchain.com/v0.2/docs/integrations/vectorstores/singlestoredb/).\n",
|
||||
"\n",
|
||||
":::"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1,326 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2b9582dc",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# SingleStoreDB\n",
|
||||
">[SingleStoreDB](https://singlestore.com/) is a robust, high-performance distributed SQL database solution designed to excel in both [cloud](https://www.singlestore.com/cloud/) and on-premises environments. Boasting a versatile feature set, it offers seamless deployment options while delivering unparalleled performance.\n",
|
||||
"\n",
|
||||
"A standout feature of SingleStoreDB is its advanced support for vector storage and operations, making it an ideal choice for applications requiring intricate AI capabilities such as text similarity matching. With built-in vector functions like [dot_product](https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/dot_product.html) and [euclidean_distance](https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/euclidean_distance.html), SingleStoreDB empowers developers to implement sophisticated algorithms efficiently.\n",
|
||||
"\n",
|
||||
"For developers keen on leveraging vector data within SingleStoreDB, a comprehensive tutorial is available, guiding them through the intricacies of [working with vector data](https://docs.singlestore.com/managed-service/en/developer-resources/functional-extensions/working-with-vector-data.html). This tutorial delves into the Vector Store within SingleStoreDB, showcasing its ability to facilitate searches based on vector similarity. Leveraging vector indexes, queries can be executed with remarkable speed, enabling swift retrieval of relevant data.\n",
|
||||
"\n",
|
||||
"Moreover, SingleStoreDB's Vector Store seamlessly integrates with [full-text indexing based on Lucene](https://docs.singlestore.com/cloud/developer-resources/functional-extensions/working-with-full-text-search/), enabling powerful text similarity searches. Users can filter search results based on selected fields of document metadata objects, enhancing query precision.\n",
|
||||
"\n",
|
||||
"What sets SingleStoreDB apart is its ability to combine vector and full-text searches in various ways, offering flexibility and versatility. Whether prefiltering by text or vector similarity and selecting the most relevant data, or employing a weighted sum approach to compute a final similarity score, developers have multiple options at their disposal.\n",
|
||||
"\n",
|
||||
"In essence, SingleStoreDB provides a comprehensive solution for managing and querying vector data, offering unparalleled performance and flexibility for AI-driven applications.\n",
|
||||
"\n",
|
||||
"You'll need to install `langchain-community` with `pip install -qU langchain-community` to use this integration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e4a61a4d",
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Establishing a connection to the database is facilitated through the singlestoredb Python connector.\n",
|
||||
"# Please ensure that this connector is installed in your working environment.\n",
|
||||
"%pip install --upgrade --quiet singlestoredb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "39a0132a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.\n",
|
||||
"if \"OPENAI_API_KEY\" not in os.environ:\n",
|
||||
" os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "6104fde8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_community.vectorstores import SingleStoreDB\n",
|
||||
"from langchain_community.vectorstores.utils import DistanceStrategy\n",
|
||||
"from langchain_core.documents import Document\n",
|
||||
"from langchain_openai import OpenAIEmbeddings"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7b45113c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# loading docs\n",
|
||||
"# we will use some artificial data for this example\n",
|
||||
"docs = [\n",
|
||||
" Document(\n",
|
||||
" page_content=\"\"\"In the parched desert, a sudden rainstorm brought relief,\n",
|
||||
" as the droplets danced upon the thirsty earth, rejuvenating the landscape\n",
|
||||
" with the sweet scent of petrichor.\"\"\",\n",
|
||||
" metadata={\"category\": \"rain\"},\n",
|
||||
" ),\n",
|
||||
" Document(\n",
|
||||
" page_content=\"\"\"Amidst the bustling cityscape, the rain fell relentlessly,\n",
|
||||
" creating a symphony of pitter-patter on the pavement, while umbrellas\n",
|
||||
" bloomed like colorful flowers in a sea of gray.\"\"\",\n",
|
||||
" metadata={\"category\": \"rain\"},\n",
|
||||
" ),\n",
|
||||
" Document(\n",
|
||||
" page_content=\"\"\"High in the mountains, the rain transformed into a delicate\n",
|
||||
" mist, enveloping the peaks in a mystical veil, where each droplet seemed to\n",
|
||||
" whisper secrets to the ancient rocks below.\"\"\",\n",
|
||||
" metadata={\"category\": \"rain\"},\n",
|
||||
" ),\n",
|
||||
" Document(\n",
|
||||
" page_content=\"\"\"Blanketing the countryside in a soft, pristine layer, the\n",
|
||||
" snowfall painted a serene tableau, muffling the world in a tranquil hush\n",
|
||||
" as delicate flakes settled upon the branches of trees like nature's own \n",
|
||||
" lacework.\"\"\",\n",
|
||||
" metadata={\"category\": \"snow\"},\n",
|
||||
" ),\n",
|
||||
" Document(\n",
|
||||
" page_content=\"\"\"In the urban landscape, snow descended, transforming\n",
|
||||
" bustling streets into a winter wonderland, where the laughter of\n",
|
||||
" children echoed amidst the flurry of snowballs and the twinkle of\n",
|
||||
" holiday lights.\"\"\",\n",
|
||||
" metadata={\"category\": \"snow\"},\n",
|
||||
" ),\n",
|
||||
" Document(\n",
|
||||
" page_content=\"\"\"Atop the rugged peaks, snow fell with an unyielding\n",
|
||||
" intensity, sculpting the landscape into a pristine alpine paradise,\n",
|
||||
" where the frozen crystals shimmered under the moonlight, casting a\n",
|
||||
" spell of enchantment over the wilderness below.\"\"\",\n",
|
||||
" metadata={\"category\": \"snow\"},\n",
|
||||
" ),\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"embeddings = OpenAIEmbeddings()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "535b2687",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"There are several ways to establish a [connection](https://singlestoredb-python.labs.singlestore.com/generated/singlestoredb.connect.html) to the database. You can either set up environment variables or pass named parameters to the `SingleStoreDB constructor`. Alternatively, you may provide these parameters to the `from_documents` and `from_texts` methods."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d0b316bf",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Setup connection url as environment variable\n",
|
||||
"os.environ[\"SINGLESTOREDB_URL\"] = \"root:pass@localhost:3306/db\"\n",
|
||||
"\n",
|
||||
"# Load documents to the store\n",
|
||||
"docsearch = SingleStoreDB.from_documents(\n",
|
||||
" docs,\n",
|
||||
" embeddings,\n",
|
||||
" table_name=\"notebook\", # use table with a custom name\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0eaa4297",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"query = \"trees in the snow\"\n",
|
||||
"docs = docsearch.similarity_search(query) # Find documents that correspond to the query\n",
|
||||
"print(docs[0].page_content)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "51b2b552",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SingleStoreDB elevates search capabilities by enabling users to enhance and refine search results through prefiltering based on metadata fields. This functionality empowers developers and data analysts to fine-tune queries, ensuring that search results are precisely tailored to their requirements. By filtering search results using specific metadata attributes, users can narrow down the scope of their queries, focusing only on relevant data subsets. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "389bf801",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"query = \"trees branches\"\n",
|
||||
"docs = docsearch.similarity_search(\n",
|
||||
" query, filter={\"category\": \"snow\"}\n",
|
||||
") # Find documents that correspond to the query and has category \"snow\"\n",
|
||||
"print(docs[0].page_content)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "035cba66",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Enhance your search efficiency with SingleStore DB version 8.5 or above by leveraging [ANN vector indexes](https://docs.singlestore.com/cloud/reference/sql-reference/vector-functions/vector-indexing/). By setting `use_vector_index=True` during vector store object creation, you can activate this feature. Additionally, if your vectors differ in dimensionality from the default OpenAI embedding size of 1536, ensure to specify the `vector_size` parameter accordingly. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5308afe5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SingleStoreDB presents a diverse range of search strategies, each meticulously crafted to cater to specific use cases and user preferences. The default `VECTOR_ONLY` strategy utilizes vector operations such as `dot_product` or `euclidean_distance` to calculate similarity scores directly between vectors, while `TEXT_ONLY` employs Lucene-based full-text search, particularly advantageous for text-centric applications. For users seeking a balanced approach, `FILTER_BY_TEXT` first refines results based on text similarity before conducting vector comparisons, whereas `FILTER_BY_VECTOR` prioritizes vector similarity, filtering results before assessing text similarity for optimal matches. Notably, both `FILTER_BY_TEXT` and `FILTER_BY_VECTOR` necessitate a full-text index for operation. Additionally, `WEIGHTED_SUM` emerges as a sophisticated strategy, calculating the final similarity score by weighing vector and text similarities, albeit exclusively utilizing dot_product distance calculations and also requiring a full-text index. These versatile strategies empower users to fine-tune searches according to their unique needs, facilitating efficient and precise data retrieval and analysis. Moreover, SingleStoreDB's hybrid approaches, exemplified by `FILTER_BY_TEXT`, `FILTER_BY_VECTOR`, and `WEIGHTED_SUM` strategies, seamlessly blend vector and text-based searches to maximize efficiency and accuracy, ensuring users can fully leverage the platform's capabilities for a wide range of applications."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "17db0116",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"docsearch = SingleStoreDB.from_documents(\n",
|
||||
" docs,\n",
|
||||
" embeddings,\n",
|
||||
" distance_strategy=DistanceStrategy.DOT_PRODUCT, # Use dot product for similarity search\n",
|
||||
" use_vector_index=True, # Use vector index for faster search\n",
|
||||
" use_full_text_search=True, # Use full text index\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"vectorResults = docsearch.similarity_search(\n",
|
||||
" \"rainstorm in parched desert, rain\",\n",
|
||||
" k=1,\n",
|
||||
" search_strategy=SingleStoreDB.SearchStrategy.VECTOR_ONLY,\n",
|
||||
" filter={\"category\": \"rain\"},\n",
|
||||
")\n",
|
||||
"print(vectorResults[0].page_content)\n",
|
||||
"\n",
|
||||
"textResults = docsearch.similarity_search(\n",
|
||||
" \"rainstorm in parched desert, rain\",\n",
|
||||
" k=1,\n",
|
||||
" search_strategy=SingleStoreDB.SearchStrategy.TEXT_ONLY,\n",
|
||||
")\n",
|
||||
"print(textResults[0].page_content)\n",
|
||||
"\n",
|
||||
"filteredByTextResults = docsearch.similarity_search(\n",
|
||||
" \"rainstorm in parched desert, rain\",\n",
|
||||
" k=1,\n",
|
||||
" search_strategy=SingleStoreDB.SearchStrategy.FILTER_BY_TEXT,\n",
|
||||
" filter_threshold=0.1,\n",
|
||||
")\n",
|
||||
"print(filteredByTextResults[0].page_content)\n",
|
||||
"\n",
|
||||
"filteredByVectorResults = docsearch.similarity_search(\n",
|
||||
" \"rainstorm in parched desert, rain\",\n",
|
||||
" k=1,\n",
|
||||
" search_strategy=SingleStoreDB.SearchStrategy.FILTER_BY_VECTOR,\n",
|
||||
" filter_threshold=0.1,\n",
|
||||
")\n",
|
||||
"print(filteredByVectorResults[0].page_content)\n",
|
||||
"\n",
|
||||
"weightedSumResults = docsearch.similarity_search(\n",
|
||||
" \"rainstorm in parched desert, rain\",\n",
|
||||
" k=1,\n",
|
||||
" search_strategy=SingleStoreDB.SearchStrategy.WEIGHTED_SUM,\n",
|
||||
" text_weight=0.2,\n",
|
||||
" vector_weight=0.8,\n",
|
||||
")\n",
|
||||
"print(weightedSumResults[0].page_content)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "86efff90",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Multi-modal Example: Leveraging CLIP and OpenClip Embeddings\n",
|
||||
"\n",
|
||||
"In the realm of multi-modal data analysis, the integration of diverse information types like images and text has become increasingly crucial. One powerful tool facilitating such integration is [CLIP](https://openai.com/research/clip), a cutting-edge model capable of embedding both images and text into a shared semantic space. By doing so, CLIP enables the retrieval of relevant content across different modalities through similarity search.\n",
|
||||
"\n",
|
||||
"To illustrate, let's consider an application scenario where we aim to effectively analyze multi-modal data. In this example, we harness the capabilities of [OpenClip multimodal embeddings](/docs/integrations/text_embedding/open_clip), which leverage CLIP's framework. With OpenClip, we can seamlessly embed textual descriptions alongside corresponding images, enabling comprehensive analysis and retrieval tasks. Whether it's identifying visually similar images based on textual queries or finding relevant text passages associated with specific visual content, OpenClip empowers users to explore and extract insights from multi-modal data with remarkable efficiency and accuracy."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "9c0bce88",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install -U langchain openai singlestoredb langchain-experimental # (newest versions required for multi-modal)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "21a8c25c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"from langchain_community.vectorstores import SingleStoreDB\n",
|
||||
"from langchain_experimental.open_clip import OpenCLIPEmbeddings\n",
|
||||
"\n",
|
||||
"os.environ[\"SINGLESTOREDB_URL\"] = \"root:pass@localhost:3306/db\"\n",
|
||||
"\n",
|
||||
"TEST_IMAGES_DIR = \"../../modules/images\"\n",
|
||||
"\n",
|
||||
"docsearch = SingleStoreDB(OpenCLIPEmbeddings())\n",
|
||||
"\n",
|
||||
"image_uris = sorted(\n",
|
||||
" [\n",
|
||||
" os.path.join(TEST_IMAGES_DIR, image_name)\n",
|
||||
" for image_name in os.listdir(TEST_IMAGES_DIR)\n",
|
||||
" if image_name.endswith(\".jpg\")\n",
|
||||
" ]\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# Add images\n",
|
||||
"docsearch.add_images(uris=image_uris)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@ -134,6 +134,18 @@
|
||||
"source": "/docs/integrations/retrievers/weaviate-hybrid(/?)",
|
||||
"destination": "/docs/integrations/vectorstores/weaviate/#search-mechanism"
|
||||
},
|
||||
{
|
||||
"source": "/docs/integrations/vectorstores/singlestoredb(/?)",
|
||||
"destination": "https://python.langchain.com/v0.2/docs/integrations/vectorstores/singlestoredb/"
|
||||
},
|
||||
{
|
||||
"source": "/docs/integrations/providers/singlestoredb(/?)",
|
||||
"destination": "/docs/integrations/providers/singlestore/"
|
||||
},
|
||||
{
|
||||
"source": "/docs/integrations/retrievers/singlestoredb(/?)",
|
||||
"destination": "https://python.langchain.com/v0.2/docs/integrations/retrievers/singlestoredb/"
|
||||
},
|
||||
{
|
||||
"source": "/api_reference/mongodb/:path(.*/?)*",
|
||||
"destination": "https://langchain-mongodb.readthedocs.io/en/latest/langchain_mongodb/api_docs.html"
|
||||
|
@ -2489,6 +2489,18 @@ class OpenSearchSemanticCache(BaseCache):
|
||||
del self._cache_dict[index_name]
|
||||
|
||||
|
||||
@deprecated(
|
||||
since="0.3.22",
|
||||
message=(
|
||||
"This class is pending deprecation and may be removed in a future version. "
|
||||
"You can swap to using the `SingleStoreSemanticCache` "
|
||||
"implementation in `langchain_singlestore`. "
|
||||
"See <https://github.com/singlestore-labs/langchain-singlestore> for details "
|
||||
" about the new implementation."
|
||||
),
|
||||
alternative="from langchain_singlestore import SingleStoreSemanticCache",
|
||||
pending=True,
|
||||
)
|
||||
class SingleStoreDBSemanticCache(BaseCache):
|
||||
"""Cache that uses SingleStore DB as a backend"""
|
||||
|
||||
|
@ -6,6 +6,7 @@ from typing import (
|
||||
List,
|
||||
)
|
||||
|
||||
from langchain_core._api import deprecated
|
||||
from langchain_core.chat_history import BaseChatMessageHistory
|
||||
from langchain_core.messages import (
|
||||
BaseMessage,
|
||||
@ -16,6 +17,18 @@ from langchain_core.messages import (
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@deprecated(
|
||||
since="0.3.22",
|
||||
message=(
|
||||
"This class is pending deprecation and may be removed in a future version. "
|
||||
"You can swap to using the `SingleStoreChatMessageHistory` "
|
||||
"implementation in `langchain_singlestore`. "
|
||||
"See <https://github.com/singlestore-labs/langchain-singlestore> for details "
|
||||
" about the new implementation."
|
||||
),
|
||||
alternative="from langchain_singlestore import SingleStoreChatMessageHistory",
|
||||
pending=True,
|
||||
)
|
||||
class SingleStoreDBChatMessageHistory(BaseChatMessageHistory):
|
||||
"""Chat message history stored in a SingleStoreDB database."""
|
||||
|
||||
|
@ -13,6 +13,7 @@ from typing import (
|
||||
Type,
|
||||
)
|
||||
|
||||
from langchain_core._api import deprecated
|
||||
from langchain_core.documents import Document
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.vectorstores import VectorStore, VectorStoreRetriever
|
||||
@ -28,6 +29,18 @@ ORDERING_DIRECTIVE: dict = {
|
||||
}
|
||||
|
||||
|
||||
@deprecated(
|
||||
since="0.3.22",
|
||||
message=(
|
||||
"This class is pending deprecation and may be removed in a future version. "
|
||||
"You can swap to using the `SingleStoreVectorStore` "
|
||||
"implementation in `langchain_singlestore`. "
|
||||
"See <https://github.com/singlestore-labs/langchain-singlestore> for details "
|
||||
"about the new implementation."
|
||||
),
|
||||
alternative="from langchain_singlestore import SingleStoreVectorStore",
|
||||
pending=True,
|
||||
)
|
||||
class SingleStoreDB(VectorStore):
|
||||
"""`SingleStore DB` vector store.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user