luojunhui 3 days ago
parent
commit
1aa1e9b9cc

+ 0 - 0
applications/vector_database/__init__.py


+ 18 - 0
applications/vector_database/field.py

@@ -0,0 +1,18 @@
+from applications.config import MODEL_CONFIG
+
+from pymilvus import Collection, CollectionSchema, FieldSchema, DataType
+
+
+collections = {}
+for model_name, cfg in MODEL_CONFIG.items():
+    col_name = model_name.replace("/", "_").replace("-", "_").lower()
+    fields = [
+        FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
+        FieldSchema(name="text", dtype=DataType.VARCHAR, max_length=1024),
+        FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=cfg["dim"])
+    ]
+    schema = CollectionSchema(fields, description=f"{model_name} embeddings")
+    collection = Collection(col_name, schema=schema)
+    collection.load()
+    collections[model_name] = collection
+

+ 1 - 1
docker-compose.yml

@@ -41,7 +41,7 @@ services:
 
   # Milvus 向量数据库
   milvus:
-    image: milvusdb/milvus:2.4.0
+    image: registry.cn-hangzhou.aliyuncs.com/milvusdb/milvus:2.4.0
     container_name: milvus
     ports:
       - "19530:19530"