Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Jul 15, 2024
1 parent 4fdcb30 commit 997901e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 132 deletions.
11 changes: 8 additions & 3 deletions api/core/rag/datasource/vdb/milvus/milvus_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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
Expand Down Expand Up @@ -248,11 +249,15 @@ def create_collection(
# 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:
Expand Down
Loading

0 comments on commit 997901e

Please sign in to comment.