From ea99612caaa26e4aa4e2977a31d9a4e86765216b Mon Sep 17 00:00:00 2001 From: Funkeke <153349156+Funkeke@users.noreply.github.com> Date: Thu, 14 Dec 2023 06:38:27 +0800 Subject: [PATCH] community[patch]: fix dashvector endpoint params error (#14484) Co-authored-by: fangkeke <3339698829@qq.com> Co-authored-by: Harrison Chase --- .../langchain_community/vectorstores/dashvector.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/dashvector.py b/libs/community/langchain_community/vectorstores/dashvector.py index 7e82b23c2d..6fb474eb3e 100644 --- a/libs/community/langchain_community/vectorstores/dashvector.py +++ b/libs/community/langchain_community/vectorstores/dashvector.py @@ -309,6 +309,7 @@ class DashVector(VectorStore): embedding: Embeddings, metadatas: Optional[List[dict]] = None, dashvector_api_key: Optional[str] = None, + dashvector_endpoint: Optional[str] = None, collection_name: str = "langchain", text_field: str = "text", batch_size: int = 25, @@ -345,7 +346,14 @@ class DashVector(VectorStore): "dashvector_api_key", "DASHVECTOR_API_KEY" ) - dashvector_client = dashvector.Client(api_key=dashvector_api_key) + dashvector_endpoint = dashvector_endpoint or get_from_env( + "dashvector_endpoint", + "DASHVECTOR_ENDPOINT", + default="dashvector.cn-hangzhou.aliyuncs.com", + ) + dashvector_client = dashvector.Client( + api_key=dashvector_api_key, endpoint=dashvector_endpoint + ) dashvector_client.delete(collection_name) collection = dashvector_client.get(collection_name) if not collection: