### Local Development with Poetry Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Installs project dependencies and runs tests locally using Poetry. This is the recommended approach for development work. ```bash poetry install poetry run pytest ``` -------------------------------- ### Install vectordb-orm Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Installs the vectordb-orm package and its dependencies using pip. Ensure you have a vector database running before connecting. ```bash pip install vectordb-orm ``` -------------------------------- ### Clone and Run vectordb-orm with Docker Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Clones the vectordb-orm repository, navigates into the directory, and starts the necessary services using Docker Compose. This is primarily for testing Milvus. ```bash git clone https://github.com/piercefreeman/vectordb-orm.git cd vectordb-orm docker-compose up -d ``` -------------------------------- ### Insert and Query Data Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Demonstrates inserting a single object and performing batch insertion with a progress bar in vectordb-orm. It also shows basic filtering and similarity-based ordering in queries. ```Python obj = MyObject(text="my_text", embedding=np.array([1.0]*128)) session.insert(obj) obj = MyObject(text="my_text", embedding=np.array([1.0]*128)) session.insert_batch([obj], show_progress=True) session = VectorSession(...) # Perform a simple boolean query results = session.query(MyObject).filter(MyObject.text == 'bar').limit(2).all() # Rank results by their similarity to a given reference vector query_vector = np.array([8.0]*128) results = session.query(MyObject).filter(MyObject.text == 'bar').order_by_similarity(MyObject.embedding, query_vector).limit(2).all() ``` -------------------------------- ### Create Milvus Session Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Establishes a database session for Milvus using vectordb-orm. It involves connecting to Milvus and creating a collection based on a defined schema. ```Python from pymilvus import Milvus, connections from vectordb_orm import MilvusBackend, VectorSession # Instantiate a Milvus session session = VectorSession(MilvusBackend(Milvus())) connections.connect("default", host="localhost", port="19530") session.create_collection(MyObject) ``` -------------------------------- ### Create Pinecone Session Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Establishes a database session for Pinecone using vectordb-orm. It requires API key and environment variables for authentication and initializes the session. ```Python from vectordb_orm import PineconeBackend, VectorSession # Instantiate a Pinecone session session = VectorSession( PineconeBackend( api_key=getenv("PINECONE_API_KEY"), environment=getenv("PINECONE_ENVIRONMENT"), ) ) session.create_collection(MyObject) ``` -------------------------------- ### Define Milvus Schema Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Defines a data schema for Milvus using vectordb-orm. It includes primary key, variable character field, and an embedding field with Milvus-specific indexing (Milvus_IVF_FLAT). ```Python from vectordb_orm import VectorSchemaBase, EmbeddingField, VarCharField, PrimaryKeyField, Milvus_IVF_FLAT import numpy as np class MyObject(VectorSchemaBase): __collection_name__ = 'my_object_collection' id: int = PrimaryKeyField() text: str = VarCharField(max_length=128) embedding: np.ndarray = EmbeddingField(dim=128, index=Milvus_IVF_FLAT(cluster_units=128)) ``` -------------------------------- ### Define Pinecone Schema Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Defines a data schema for Pinecone using vectordb-orm. It includes primary key, variable character field, and an embedding field with Pinecone-specific indexing (PineconeIndex with cosine similarity). ```Python from vectordb_orm import VectorSchemaBase, EmbeddingField, VarCharField, PrimaryKeyField, PineconeIndex, PineconeSimilarityMetric import numpy as np class MyObject(VectorSchemaBase): __collection_name__ = 'my_object_collection' id: int = PrimaryKeyField() text: str = VarCharField(max_length=128) embedding: np.ndarray = EmbeddingField(dim=128, index=PineconeIndex(metric_type=PineconeSimilarityMetric.COSINE)) ``` -------------------------------- ### Define Floating Point Embedding Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Specifies a floating-point embedding type for vectordb-orm, using numpy's default array type and a BIN_FLAT index. ```Python embedding: np.ndarray = EmbeddingField( dim=128, index=BIN_FLAT() ) ``` -------------------------------- ### Define Binary Embedding Source: https://github.com/piercefreeman/vectordb-orm/blob/main/README.md Specifies a binary embedding type for vectordb-orm, using numpy's boolean type signature and a FLAT index. ```Python embedding: np.ndarray[np.bool_] = EmbeddingField( dim=128, index=FLAT() ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.