mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: wangxiaolei <fatelei@gmail.com>
32 lines
1008 B
Python
32 lines
1008 B
Python
from dify_vdb_baidu.baidu_vector import BaiduConfig, BaiduVector
|
|
|
|
from core.rag.datasource.vdb.vector_integration_test_support import AbstractVectorTest, get_example_text
|
|
|
|
|
|
class BaiduVectorTest(AbstractVectorTest):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.vector = BaiduVector(
|
|
"dify",
|
|
BaiduConfig(
|
|
endpoint="http://127.0.0.1:5287",
|
|
account="root",
|
|
api_key="dify",
|
|
database="dify",
|
|
shard=1,
|
|
replicas=3,
|
|
),
|
|
)
|
|
|
|
def search_by_vector(self):
|
|
hits_by_vector = self.vector.search_by_vector(query_vector=self.example_embedding)
|
|
assert len(hits_by_vector) == 1
|
|
|
|
def search_by_full_text(self):
|
|
hits_by_full_text = self.vector.search_by_full_text(query=get_example_text())
|
|
assert len(hits_by_full_text) == 0
|
|
|
|
|
|
def test_baidu_vector(setup_mock_redis, setup_baiduvectordb_mock):
|
|
BaiduVectorTest().run_all_tests()
|