Skip to main content

A Milvus API used for quickly setting up a Milvus vector database

Project description

milvus_logo_with_a_steampunk_and_industrial_style

milvus_api

milvus_api is a Python library that primarily provides functionalities to manage databases, including creating collections, inserting data, searching and updating index.

Installation

This project depends on several Python libraries. Use the following command to install the necessary libraries:

pip install pymilvus==2.4.0 milvus-model==0.2.0 pydantic==2.7.0 tqdm==4.66.2 FlagEmbedding==1.2.9 torch==2.2.2 numpy==1.24.4

Usage Examples

Creating a Database Collection

Here's how to create a new database collection using milvus_api:

from milvus_api.db_model.milvus_db import MilvusDB
from pymilvus import FiledSchema, DataType

host = 'localhost'
port = '19530'
db = MilvusDB(host, port)

fields = [  
    FieldSchema(name="id", dtype=DataType.INT64, auto_id=True, is_primary=True),
    FieldSchema(name="embeddings", dtype=DataType.FLOAT_VECTOR, dim=1024)
]

db.create_collection("my_collection", 1000, fields, "FLAT", "COSINE")

Data Encoding Using the Model

Here's how to perform query encoding using the embedding model in milvus_api:

from milvus_api.embed_model.bgem3 import PyMilvusBGEM3

query = ["Are you afraid of the earthquake"]
model_name = 'bgem3_model'

# Initialize the model
bgem3 = PyMilvusBGEM3(model_name)
results = bgem3.encode(query)

Release Note

  • 0.2.1:(Feat): support IVF_PQ indexing algorithm for switch_index.
  • 0.2.0:(Feat): add the switch_index operation to MilvusDB object.
from milvus_api.db_model.milvus_db import MilvusDB

db = MilvusDB(host, port)

# Assume you already have a collection with index.
db.switch_index("your_collection_name", "drop_index_name", "new_index_type", "field_name", metric_type")
  • 0.1.4:(BugFix): Fix the logic error when do search operation.
  • 0.1.3:(BugFix): Fix the error caused by the non-specific field argument during creating collection.
  • 0.1.2:(BugFix): Cancel partial information of info function.
  • 0.1.1: Modify this project structure to ensure that users can import 'milvus_api' normally.

Contributions

Thanks to all developers who contributed to this project. If you would like to contribute code, please follow the existing code style and submit a pull request.

Copyright and License

This project is licensed under the Apache License 2.0.

Other Information

This README.md file is now complete, including an introduction to the project, installation instructions, usage examples, contribution guidelines, and copyright and licensing information. You can save this content as the README.md file in the root directory of your project. If you need further modifications or wish to add additional information, feel free to let me know!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

milvus_api-0.2.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

milvus_api-0.2.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file milvus_api-0.2.1.2.tar.gz.

File metadata

  • Download URL: milvus_api-0.2.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for milvus_api-0.2.1.2.tar.gz
Algorithm Hash digest
SHA256 fae6edfcdb41534e19e6be1c0802aea007f07688b54015a5706203abefc90015
MD5 135180db0a6c03cfa91e85190da014e2
BLAKE2b-256 d34c522c04cf5fafb0291e1fa6f122ced141a95862cfa1e81f3e5c1cf55f67c8

See more details on using hashes here.

File details

Details for the file milvus_api-0.2.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for milvus_api-0.2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9c6f39b46d4fcb419b1bd581c8b671406951c96d5d00da6c55985781ea5b3b2e
MD5 1ee6fd8a64ff1e5e56a3590a4c0ec1f2
BLAKE2b-256 75b4bff61c90812fa5aa76f26e5a65a7731aafd95c4532754acfa2d8250ed6e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page