mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 20:39:01 +08:00
feat(qdrant):add replication_factor when create collection in qdrant (#20133)
Co-authored-by: 刘敏 <min.liu@tongdun.net>
This commit is contained in:
parent
0ebaba98f0
commit
4c4887c5fc
@ -152,6 +152,7 @@ QDRANT_API_KEY=difyai123456
|
|||||||
QDRANT_CLIENT_TIMEOUT=20
|
QDRANT_CLIENT_TIMEOUT=20
|
||||||
QDRANT_GRPC_ENABLED=false
|
QDRANT_GRPC_ENABLED=false
|
||||||
QDRANT_GRPC_PORT=6334
|
QDRANT_GRPC_PORT=6334
|
||||||
|
QDRANT_REPLICATION_FACTOR=1
|
||||||
|
|
||||||
#Couchbase configuration
|
#Couchbase configuration
|
||||||
COUCHBASE_CONNECTION_STRING=127.0.0.1
|
COUCHBASE_CONNECTION_STRING=127.0.0.1
|
||||||
|
@ -33,3 +33,8 @@ class QdrantConfig(BaseSettings):
|
|||||||
description="Port number for gRPC connection to Qdrant server (default is 6334)",
|
description="Port number for gRPC connection to Qdrant server (default is 6334)",
|
||||||
default=6334,
|
default=6334,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
QDRANT_REPLICATION_FACTOR: PositiveInt = Field(
|
||||||
|
description="Replication factor for Qdrant collections (default is 1)",
|
||||||
|
default=1,
|
||||||
|
)
|
||||||
|
@ -46,6 +46,7 @@ class QdrantConfig(BaseModel):
|
|||||||
root_path: Optional[str] = None
|
root_path: Optional[str] = None
|
||||||
grpc_port: int = 6334
|
grpc_port: int = 6334
|
||||||
prefer_grpc: bool = False
|
prefer_grpc: bool = False
|
||||||
|
replication_factor: int = 1
|
||||||
|
|
||||||
def to_qdrant_params(self):
|
def to_qdrant_params(self):
|
||||||
if self.endpoint and self.endpoint.startswith("path:"):
|
if self.endpoint and self.endpoint.startswith("path:"):
|
||||||
@ -119,11 +120,13 @@ class QdrantVector(BaseVector):
|
|||||||
max_indexing_threads=0,
|
max_indexing_threads=0,
|
||||||
on_disk=False,
|
on_disk=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._client.create_collection(
|
self._client.create_collection(
|
||||||
collection_name=collection_name,
|
collection_name=collection_name,
|
||||||
vectors_config=vectors_config,
|
vectors_config=vectors_config,
|
||||||
hnsw_config=hnsw_config,
|
hnsw_config=hnsw_config,
|
||||||
timeout=int(self._client_config.timeout),
|
timeout=int(self._client_config.timeout),
|
||||||
|
replication_factor=self._client_config.replication_factor,
|
||||||
)
|
)
|
||||||
|
|
||||||
# create group_id payload index
|
# create group_id payload index
|
||||||
@ -466,5 +469,6 @@ class QdrantVectorFactory(AbstractVectorFactory):
|
|||||||
timeout=dify_config.QDRANT_CLIENT_TIMEOUT,
|
timeout=dify_config.QDRANT_CLIENT_TIMEOUT,
|
||||||
grpc_port=dify_config.QDRANT_GRPC_PORT,
|
grpc_port=dify_config.QDRANT_GRPC_PORT,
|
||||||
prefer_grpc=dify_config.QDRANT_GRPC_ENABLED,
|
prefer_grpc=dify_config.QDRANT_GRPC_ENABLED,
|
||||||
|
replication_factor=dify_config.QDRANT_REPLICATION_FACTOR,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -49,6 +49,7 @@ class TidbOnQdrantConfig(BaseModel):
|
|||||||
root_path: Optional[str] = None
|
root_path: Optional[str] = None
|
||||||
grpc_port: int = 6334
|
grpc_port: int = 6334
|
||||||
prefer_grpc: bool = False
|
prefer_grpc: bool = False
|
||||||
|
replication_factor: int = 1
|
||||||
|
|
||||||
def to_qdrant_params(self):
|
def to_qdrant_params(self):
|
||||||
if self.endpoint and self.endpoint.startswith("path:"):
|
if self.endpoint and self.endpoint.startswith("path:"):
|
||||||
@ -134,6 +135,7 @@ class TidbOnQdrantVector(BaseVector):
|
|||||||
vectors_config=vectors_config,
|
vectors_config=vectors_config,
|
||||||
hnsw_config=hnsw_config,
|
hnsw_config=hnsw_config,
|
||||||
timeout=int(self._client_config.timeout),
|
timeout=int(self._client_config.timeout),
|
||||||
|
replication_factor=self._client_config.replication_factor,
|
||||||
)
|
)
|
||||||
|
|
||||||
# create group_id payload index
|
# create group_id payload index
|
||||||
@ -484,6 +486,7 @@ class TidbOnQdrantVectorFactory(AbstractVectorFactory):
|
|||||||
timeout=dify_config.TIDB_ON_QDRANT_CLIENT_TIMEOUT,
|
timeout=dify_config.TIDB_ON_QDRANT_CLIENT_TIMEOUT,
|
||||||
grpc_port=dify_config.TIDB_ON_QDRANT_GRPC_PORT,
|
grpc_port=dify_config.TIDB_ON_QDRANT_GRPC_PORT,
|
||||||
prefer_grpc=dify_config.TIDB_ON_QDRANT_GRPC_ENABLED,
|
prefer_grpc=dify_config.TIDB_ON_QDRANT_GRPC_ENABLED,
|
||||||
|
replication_factor=dify_config.QDRANT_REPLICATION_FACTOR,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -412,6 +412,7 @@ QDRANT_API_KEY=difyai123456
|
|||||||
QDRANT_CLIENT_TIMEOUT=20
|
QDRANT_CLIENT_TIMEOUT=20
|
||||||
QDRANT_GRPC_ENABLED=false
|
QDRANT_GRPC_ENABLED=false
|
||||||
QDRANT_GRPC_PORT=6334
|
QDRANT_GRPC_PORT=6334
|
||||||
|
QDRANT_REPLICATION_FACTOR=1
|
||||||
|
|
||||||
# Milvus configuration. Only available when VECTOR_STORE is `milvus`.
|
# Milvus configuration. Only available when VECTOR_STORE is `milvus`.
|
||||||
# The milvus uri.
|
# The milvus uri.
|
||||||
|
@ -138,6 +138,7 @@ x-shared-env: &shared-api-worker-env
|
|||||||
QDRANT_CLIENT_TIMEOUT: ${QDRANT_CLIENT_TIMEOUT:-20}
|
QDRANT_CLIENT_TIMEOUT: ${QDRANT_CLIENT_TIMEOUT:-20}
|
||||||
QDRANT_GRPC_ENABLED: ${QDRANT_GRPC_ENABLED:-false}
|
QDRANT_GRPC_ENABLED: ${QDRANT_GRPC_ENABLED:-false}
|
||||||
QDRANT_GRPC_PORT: ${QDRANT_GRPC_PORT:-6334}
|
QDRANT_GRPC_PORT: ${QDRANT_GRPC_PORT:-6334}
|
||||||
|
QDRANT_REPLICATION_FACTOR: ${QDRANT_REPLICATION_FACTOR:-1}
|
||||||
MILVUS_URI: ${MILVUS_URI:-http://host.docker.internal:19530}
|
MILVUS_URI: ${MILVUS_URI:-http://host.docker.internal:19530}
|
||||||
MILVUS_DATABASE: ${MILVUS_DATABASE:-}
|
MILVUS_DATABASE: ${MILVUS_DATABASE:-}
|
||||||
MILVUS_TOKEN: ${MILVUS_TOKEN:-}
|
MILVUS_TOKEN: ${MILVUS_TOKEN:-}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user