feat: initial support for Milvus 2.4.x (#3795)

This commit is contained in:
Bowen Liang
2024-06-19 13:55:44 +08:00
committed by GitHub
parent 3cc6093e4b
commit bb33ffc332
5 changed files with 31 additions and 84 deletions

View File

@@ -6,6 +6,7 @@ from uuid import uuid4
from flask import current_app
from pydantic import BaseModel, model_validator
from pymilvus import MilvusClient, MilvusException, connections
from pymilvus.milvus_client import IndexParams
from core.rag.datasource.entity.embedding import Embeddings
from core.rag.datasource.vdb.field import Field
@@ -254,11 +255,15 @@ class MilvusVector(BaseVector):
# Since primary field is auto-id, no need to track it
self._fields.remove(Field.PRIMARY_KEY.value)
# Create Index params for the collection
index_params_obj = IndexParams()
index_params_obj.add_index(field_name=Field.VECTOR.value, **index_params)
# Create the collection
collection_name = self._collection_name
self._client.create_collection_with_schema(collection_name=collection_name,
schema=schema, index_param=index_params,
consistency_level=self._consistency_level)
self._client.create_collection(collection_name=collection_name,
schema=schema, index_params=index_params_obj,
consistency_level=self._consistency_level)
redis_client.set(collection_exist_cache_key, 1, ex=3600)
def _init_client(self, config) -> MilvusClient: