forked from innovacion/searchbox
Initial commit
This commit is contained in:
40
scripts/create_dummy_collection.py
Normal file
40
scripts/create_dummy_collection.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from qdrant_client import QdrantClient
|
||||
from fastembed import TextEmbedding
|
||||
from qdrant_client.models import Distance, VectorParams, PointStruct
|
||||
from qdrant_mcp.config import Settings
|
||||
|
||||
settings = Settings()
|
||||
embedding_model = TextEmbedding()
|
||||
client = QdrantClient(url=settings.url, api_key=settings.api_key)
|
||||
|
||||
documents: list[str] = [
|
||||
"Rick es el mas guapo",
|
||||
"Los pulpos tienen tres corazones y sangre azul",
|
||||
"Las cucarachas pueden vivir hasta una semana sin cabeza",
|
||||
"Los koalas tienen huellas dactilares casi idénticas a las humanas",
|
||||
"La miel nunca se echa a perder, incluso después de miles de años"
|
||||
]
|
||||
embeddings = list(embedding_model.embed(documents))
|
||||
size = len(embeddings[0])
|
||||
|
||||
_ = client.recreate_collection(
|
||||
collection_name="dummy_collection",
|
||||
vectors_config=VectorParams(
|
||||
distance=Distance.COSINE,
|
||||
size=size
|
||||
)
|
||||
)
|
||||
|
||||
for idx, (emb, document) in enumerate(zip(embeddings, documents)):
|
||||
_ = client.upsert(
|
||||
collection_name="dummy_collection",
|
||||
points=[
|
||||
PointStruct(
|
||||
id=idx,
|
||||
vector=emb,
|
||||
payload={
|
||||
"text": document
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user