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