langchain-chat-with-milvus/insert_test.py
2023-11-13 20:23:15 +08:00

35 lines
590 B
Python

import json
import random
MILVUS_HOST = "127.0.0.1"
MILVUS_PORT = "19530"
from pymilvus import (
connections,
Collection,
)
# create connect
connections.connect("default", host=MILVUS_HOST, port=MILVUS_PORT)
collection = Collection("todos")
with open("question_vec.json", "r") as f:
vec = f.read()
vec = json.loads(vec)
mr = collection.insert([
[9999 + random.randint(0, 1000)],
["test todo.awa.im"],
["test title"],
["test desc"],
["test text"],
["zh_CN"],
[9999 + random.randint(0, 1000)],
[vec],
])
# get id
print(mr.primary_keys)