mirror of
https://mirror.skon.top/github.com/langgenius/dify.git
synced 2026-04-23 10:39:34 +08:00
Merge branch 'feat/tidb-endpoint' of github.com:langgenius/dify into feat/tidb-endpoint
This commit is contained in:
@@ -24,9 +24,7 @@ _tidb_http_client: httpx.Client = get_pooled_http_client(
|
||||
|
||||
class TidbService:
|
||||
@staticmethod
|
||||
def fetch_qdrant_endpoint(
|
||||
api_url: str, public_key: str, private_key: str, cluster_id: str
|
||||
) -> str | None:
|
||||
def fetch_qdrant_endpoint(api_url: str, public_key: str, private_key: str, cluster_id: str) -> str | None:
|
||||
"""Fetch the qdrant endpoint for a cluster by calling the Get Cluster API.
|
||||
|
||||
The Get Cluster response contains ``status.connection_strings.standard.host``
|
||||
@@ -34,9 +32,7 @@ class TidbService:
|
||||
as an ``https://`` URL.
|
||||
"""
|
||||
try:
|
||||
cluster_response = TidbService.get_tidb_serverless_cluster(
|
||||
api_url, public_key, private_key, cluster_id
|
||||
)
|
||||
cluster_response = TidbService.get_tidb_serverless_cluster(api_url, public_key, private_key, cluster_id)
|
||||
if not cluster_response:
|
||||
return None
|
||||
# v1beta: status.connection_strings.standard.host
|
||||
@@ -100,9 +96,7 @@ class TidbService:
|
||||
cluster_response = TidbService.get_tidb_serverless_cluster(api_url, public_key, private_key, cluster_id)
|
||||
if cluster_response["state"] == "ACTIVE":
|
||||
user_prefix = cluster_response["userPrefix"]
|
||||
qdrant_endpoint = TidbService.fetch_qdrant_endpoint(
|
||||
api_url, public_key, private_key, cluster_id
|
||||
)
|
||||
qdrant_endpoint = TidbService.fetch_qdrant_endpoint(api_url, public_key, private_key, cluster_id)
|
||||
return {
|
||||
"cluster_id": cluster_id,
|
||||
"cluster_name": display_name,
|
||||
|
||||
@@ -468,7 +468,9 @@ class TidbOnQdrantVectorFactory(AbstractVectorFactory):
|
||||
else:
|
||||
TIDB_ON_QDRANT_API_KEY = f"{tidb_auth_binding.account}:{tidb_auth_binding.password}"
|
||||
|
||||
qdrant_url = (tidb_auth_binding.qdrant_endpoint if tidb_auth_binding else None) or dify_config.TIDB_ON_QDRANT_URL or ""
|
||||
qdrant_url = (
|
||||
(tidb_auth_binding.qdrant_endpoint if tidb_auth_binding else None) or dify_config.TIDB_ON_QDRANT_URL or ""
|
||||
)
|
||||
|
||||
if dataset.index_struct_dict:
|
||||
class_prefix: str = dataset.index_struct_dict["vector_store"]["class_prefix"]
|
||||
|
||||
@@ -24,9 +24,7 @@ _tidb_http_client: httpx.Client = get_pooled_http_client(
|
||||
|
||||
class TidbService:
|
||||
@staticmethod
|
||||
def fetch_qdrant_endpoint(
|
||||
api_url: str, public_key: str, private_key: str, cluster_id: str
|
||||
) -> str | None:
|
||||
def fetch_qdrant_endpoint(api_url: str, public_key: str, private_key: str, cluster_id: str) -> str | None:
|
||||
"""Fetch the qdrant endpoint for a cluster by calling the Get Cluster API.
|
||||
|
||||
The Get Cluster response contains ``status.connection_strings.standard.host``
|
||||
@@ -34,9 +32,7 @@ class TidbService:
|
||||
as an ``https://`` URL.
|
||||
"""
|
||||
try:
|
||||
cluster_response = TidbService.get_tidb_serverless_cluster(
|
||||
api_url, public_key, private_key, cluster_id
|
||||
)
|
||||
cluster_response = TidbService.get_tidb_serverless_cluster(api_url, public_key, private_key, cluster_id)
|
||||
if not cluster_response:
|
||||
return None
|
||||
# v1beta: status.connection_strings.standard.host
|
||||
@@ -100,9 +96,7 @@ class TidbService:
|
||||
cluster_response = TidbService.get_tidb_serverless_cluster(api_url, public_key, private_key, cluster_id)
|
||||
if cluster_response["state"] == "ACTIVE":
|
||||
user_prefix = cluster_response["userPrefix"]
|
||||
qdrant_endpoint = TidbService.fetch_qdrant_endpoint(
|
||||
api_url, public_key, private_key, cluster_id
|
||||
)
|
||||
qdrant_endpoint = TidbService.fetch_qdrant_endpoint(api_url, public_key, private_key, cluster_id)
|
||||
return {
|
||||
"cluster_id": cluster_id,
|
||||
"cluster_name": display_name,
|
||||
|
||||
Reference in New Issue
Block a user