Skip to content

Commit

Permalink
enhancement:support Qdrant gRPC mode (langgenius#3929)
Browse files Browse the repository at this point in the history
  • Loading branch information
leslie2046 authored and dengpeng committed Jun 16, 2024
1 parent f1f1a90 commit 187cb4a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
4 changes: 3 additions & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ WEAVIATE_BATCH_SIZE=100
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=difyai123456
QDRANT_CLIENT_TIMEOUT=20
QDRANT_GRPC_ENABLED=false
QDRANT_GRPC_PORT=6334

# Milvus configuration
MILVUS_HOST=127.0.0.1
Expand Down Expand Up @@ -148,4 +150,4 @@ API_TOOL_DEFAULT_CONNECT_TIMEOUT=10
API_TOOL_DEFAULT_READ_TIMEOUT=60

# Log file path
LOG_FILE=
LOG_FILE=
3 changes: 3 additions & 0 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'WEAVIATE_GRPC_ENABLED': 'True',
'WEAVIATE_BATCH_SIZE': 100,
'QDRANT_CLIENT_TIMEOUT': 20,
'QDRANT_GRPC_ENABLED': 'False',
'CELERY_BACKEND': 'database',
'LOG_LEVEL': 'INFO',
'LOG_FILE': '',
Expand Down Expand Up @@ -226,6 +227,8 @@ def __init__(self):
self.QDRANT_URL = get_env('QDRANT_URL')
self.QDRANT_API_KEY = get_env('QDRANT_API_KEY')
self.QDRANT_CLIENT_TIMEOUT = get_env('QDRANT_CLIENT_TIMEOUT')
self.QDRANT_GRPC_ENABLED = get_env('QDRANT_GRPC_ENABLED')
self.QDRANT_GRPC_PORT = get_env('QDRANT_GRPC_PORT')

# milvus / zilliz setting
self.MILVUS_HOST = get_env('MILVUS_HOST')
Expand Down
6 changes: 5 additions & 1 deletion api/core/rag/datasource/vdb/qdrant/qdrant_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class QdrantConfig(BaseModel):
api_key: Optional[str]
timeout: float = 20
root_path: Optional[str]
grpc_port: int = 6334
prefer_grpc: bool = False

def to_qdrant_params(self):
if self.endpoint and self.endpoint.startswith('path:'):
Expand All @@ -51,7 +53,9 @@ def to_qdrant_params(self):
'url': self.endpoint,
'api_key': self.api_key,
'timeout': self.timeout,
'verify': self.endpoint.startswith('https')
'verify': self.endpoint.startswith('https'),
'grpc_port': self.grpc_port,
'prefer_grpc': self.prefer_grpc
}


Expand Down
4 changes: 3 additions & 1 deletion api/core/rag/datasource/vdb/vector_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def _init_vector(self) -> BaseVector:
endpoint=config.get('QDRANT_URL'),
api_key=config.get('QDRANT_API_KEY'),
root_path=current_app.root_path,
timeout=config.get('QDRANT_CLIENT_TIMEOUT')
timeout=config.get('QDRANT_CLIENT_TIMEOUT'),
grpc_port=config.get('QDRANT_GRPC_PORT'),
prefer_grpc=config.get('QDRANT_GRPC_ENABLED')
)
)
elif vector_type == "milvus":
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.middleware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ services:
# QDRANT_API_KEY: 'difyai123456'
# ports:
# - "6333:6333"
# - "6334:6334"
1 change: 1 addition & 0 deletions docker/docker-compose.qdrant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ services:
QDRANT_API_KEY: 'difyai123456'
ports:
- "6333:6333"
- "6334:6334"
11 changes: 10 additions & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ services:
QDRANT_URL: http://qdrant:6333
# The Qdrant API key.
QDRANT_API_KEY: difyai123456
# The Qdrant clinet timeout setting.
# The Qdrant client timeout setting.
QDRANT_CLIENT_TIMEOUT: 20
# The Qdrant client enable gRPC mode.
QDRANT_GRPC_ENABLED: 'false'
# The Qdrant server gRPC mode PORT.
QDRANT_GRPC_PORT: 6334
# Milvus configuration Only available when VECTOR_STORE is `milvus`.
# The milvus host.
MILVUS_HOST: 127.0.0.1
Expand Down Expand Up @@ -214,6 +218,10 @@ services:
QDRANT_API_KEY: difyai123456
# The Qdrant clinet timeout setting.
QDRANT_CLIENT_TIMEOUT: 20
# The Qdrant client enable gRPC mode.
QDRANT_GRPC_ENABLED: 'false'
# The Qdrant server gRPC mode PORT.
QDRANT_GRPC_PORT: 6334
# Milvus configuration Only available when VECTOR_STORE is `milvus`.
# The milvus host.
MILVUS_HOST: 127.0.0.1
Expand Down Expand Up @@ -354,6 +362,7 @@ services:
# # uncomment to expose qdrant port to host
# # ports:
# # - "6333:6333"
# # - "6334:6334"

# The nginx reverse proxy.
# used for reverse proxying the API service and Web service.
Expand Down

0 comments on commit 187cb4a

Please sign in to comment.