File size: 8,606 Bytes
a80f6e6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | import inspect
import sys
from pathlib import Path
from langchain_astradb import AstraDBVectorStore
from langchain_chroma import Chroma
from langchain_community import vectorstores
from langchain_core.vectorstores import VectorStore
from langchain_couchbase import CouchbaseVectorStore
from langchain_milvus import Milvus
from langchain_mongodb import MongoDBAtlasVectorSearch
from langchain_pinecone import PineconeVectorStore
from langchain_qdrant import QdrantVectorStore
vectorstore_list = [
"FAISS",
"ElasticsearchStore",
"PGVector",
"Redis",
"Clickhouse",
"InMemoryVectorStore",
]
from_partners = [
("Chroma", Chroma),
("AstraDBVectorStore", AstraDBVectorStore),
("QdrantVectorStore", QdrantVectorStore),
("PineconeVectorStore", PineconeVectorStore),
("Milvus", Milvus),
("MongoDBAtlasVectorSearch", MongoDBAtlasVectorSearch),
("CouchbaseVectorStore", CouchbaseVectorStore),
]
VECTORSTORE_TEMPLATE = """\
---
sidebar_position: 1
sidebar_class_name: hidden
keywords: [compatibility]
custom_edit_url:
---
# Vectorstores
## Features
The table below lists the features for some of our most popular vector stores.
{table}
"""
def get_vectorstore_table():
vectorstore_feat_table = {
"FAISS": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"ElasticsearchStore": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"PGVector": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"Redis": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"Clickhouse": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"InMemoryVectorStore": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"Chroma": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"AstraDBVectorStore": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"QdrantVectorStore": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"PineconeVectorStore": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"Milvus": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"MongoDBAtlasVectorSearch": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
"CouchbaseVectorStore": {
"Delete by ID": True,
"Filtering": True,
"similarity_search_by_vector": True,
"similarity_search_with_score": True,
"asearch": True,
"Passes Standard Tests": False,
"Multi Tenancy": False,
"Local/Cloud": "Local",
"IDs in add Documents": True,
},
}
for vs in vectorstore_list + from_partners:
if isinstance(vs, tuple):
cls = vs[1]
vs_name = vs[0]
else:
cls = getattr(vectorstores, vs)
vs_name = vs
for feat in (
"similarity_search_with_score",
"similarity_search_by_vector",
"asearch",
):
feat, name = feat, feat
if getattr(cls, feat) != getattr(VectorStore, feat):
vectorstore_feat_table[vs_name][name] = True
else:
vectorstore_feat_table[vs_name][name] = False
if "filter" not in [
key
for key, _ in inspect.signature(
getattr(cls, "similarity_search")
).parameters.items()
]:
vectorstore_feat_table[vs_name]["Filtering"] = False
header = [
"Vectorstore",
"Delete by ID",
"Filtering",
"similarity_search_by_vector",
"similarity_search_with_score",
"asearch",
"Passes Standard Tests",
"Multi Tenancy",
"Local/Cloud",
"IDs in add Documents",
]
title = [
"Vectorstore",
"Delete by ID",
"Filtering",
"Search by Vector",
"Search with score",
"Async",
"Passes Standard Tests",
"Multi Tenancy",
"Local/Cloud",
"IDs in add Documents",
]
rows = [title, [":-"] + [":-:"] * (len(title) - 1)]
for vs, feats in sorted(vectorstore_feat_table.items()):
rows += [
[vs, "✅"]
+ [
("✅" if feats.get(h) else "❌") if h != "Local/Cloud" else feats.get(h)
for h in header[1:]
]
]
return "\n".join(["|".join(row) for row in rows])
if __name__ == "__main__":
output_dir = Path(sys.argv[1])
output_integrations_dir = output_dir / "integrations"
output_integrations_dir_vectorstore = output_integrations_dir / "vectorstores"
output_integrations_dir_vectorstore.mkdir(parents=True, exist_ok=True)
vectorstore_page = VECTORSTORE_TEMPLATE.format(table=get_vectorstore_table())
with open(output_integrations_dir / "vectorstores" / "index.mdx", "w") as f:
f.write(vectorstore_page)
|