community[patch], langchain[minor]: Enhance Tencent Cloud VectorDB, langchain: make Tencent Cloud VectorDB self query retrieve compatible (#19651)

- make Tencent Cloud VectorDB support metadata filtering.
- implement delete function for Tencent Cloud VectorDB.
- support both Langchain Embedding model and Tencent Cloud VDB embedding
model.
- Tencent Cloud VectorDB support filter search keyword, compatible with
langchain filtering syntax.
- add Tencent Cloud VectorDB TranslationVisitor, now work with self
query retriever.
- more documentations.

---------

Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
jeff kit
2024-04-10 00:50:48 +08:00
committed by GitHub
parent 1a34c65e01
commit ac42e96e4c
9 changed files with 1157 additions and 110 deletions

View File

@@ -82,6 +82,7 @@ def test_compatible_vectorstore_documentation() -> None:
"SurrealDBStore",
"TileDB",
"TimescaleVector",
"TencentVectorDB",
"EcloudESVectorStore",
"Vald",
"VDMS",

View File

@@ -0,0 +1,43 @@
import importlib.util
from langchain_community.vectorstores.tencentvectordb import translate_filter
def test_translate_filter() -> None:
raw_filter = (
'and(or(eq("artist", "Taylor Swift"), '
'eq("artist", "Katy Perry")), lt("length", 180))'
)
try:
importlib.util.find_spec("langchain.chains.query_constructor.base")
translate_filter(raw_filter)
except ModuleNotFoundError:
try:
translate_filter(raw_filter)
except ModuleNotFoundError:
pass
else:
assert False
else:
result = translate_filter(raw_filter)
expr = '(artist = "Taylor Swift" or artist = "Katy Perry") ' "and length < 180"
assert expr == result
def test_translate_filter_with_in_comparison() -> None:
raw_filter = 'in("artist", ["Taylor Swift", "Katy Perry"])'
try:
importlib.util.find_spec("langchain.chains.query_constructor.base")
translate_filter(raw_filter)
except ModuleNotFoundError:
try:
translate_filter(raw_filter)
except ModuleNotFoundError:
pass
else:
assert False
else:
result = translate_filter(raw_filter)
expr = 'artist in ("Taylor Swift", "Katy Perry")'
assert expr == result