mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
b035c02f78
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Co-authored-by: -LAN- <laipz8200@outlook.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from unittest.mock import MagicMock
|
|
|
|
from core.rag.datasource.vdb.tencent.tencent_vector import TencentConfig, TencentVector
|
|
from tests.integration_tests.vdb.__mock.tcvectordb import setup_tcvectordb_mock
|
|
from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
|
|
|
|
mock_client = MagicMock()
|
|
mock_client.list_databases.return_value = [{"name": "test"}]
|
|
|
|
|
|
class TencentVectorTest(AbstractVectorTest):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.vector = TencentVector(
|
|
"dify",
|
|
TencentConfig(
|
|
url="http://127.0.0.1",
|
|
api_key="dify",
|
|
timeout=30,
|
|
username="dify",
|
|
database="dify",
|
|
shard=1,
|
|
replicas=2,
|
|
),
|
|
)
|
|
|
|
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_tencent_vector(setup_mock_redis, setup_tcvectordb_mock):
|
|
TencentVectorTest().run_all_tests()
|