Skip to main content

Client library for Vector Store service

Project description

Vector Store Client

A Python client for interacting with Vector Store API services. This client provides a convenient interface for working with vector embeddings, semantic search, and metadata filtering.

PyPI Version Python Versions License

Features

  • Full-featured API for Vector Store operations
  • Asynchronous interface based on httpx
  • Automatic parameter handling and validation
  • Comprehensive error management
  • Support for all vector store operations:
    • Creating records from text or vectors
    • Vector similarity search
    • Metadata filtering
    • Record management

Installation

pip install vector-store-client

Or install from source:

git clone https://github.com/yourusername/vector-store-client.git
cd vector-store-client
pip install -e .

Quick Start

import asyncio
from vector_store_client import create_client

async def main():
    # Create client with connection to the service
    client = await create_client(base_url="http://localhost:8007")
    
    # Create a record from text
    record_id = await client.create_text_record(
        text="Example text for vectorization",
        metadata={"type": "example", "tags": ["test", "vector"]}
    )
    
    # Search for similar records
    results = await client.search_text_records(
        text="vectorization example",
        limit=5
    )
    
    for result in results:
        print(f"ID: {result.id}, Similarity: {result.score:.4f}")

    # Close the client session
    await client._client.aclose()

if __name__ == "__main__":
    asyncio.run(main())

Documentation

Detailed documentation is available in both English and Russian:

Examples

Check out the example scripts to get started:

Development

Requirements

  • Python 3.7+
  • httpx
  • pydantic

Running Tests

# Install test dependencies
pip install pytest pytest-asyncio pytest-cov

# Run tests
python run_tests.py

License

MIT

Пример использования

# ...
record = await client.create_record(vector=vector, metadata=metadata)
print("Record ID:", record["record_id"])

text_record = await client.create_text_record(text="Some text", metadata=metadata)
print("Text Record ID:", text_record["record_id"])
# ... existing code ...

Metadata Validation

All metadata passed to create_record or create_text_record must pass strict validation using the chunk_metadata_adapter package. This ensures compatibility with the server and prevents runtime errors.

Example:

from chunk_metadata_adapter.models import SemanticChunk

metadata = {"type": "example", "body": "Some text"}
obj, err = SemanticChunk.validate_and_fill(metadata)
if not obj:
    raise Exception(f"Strict metadata validation failed: {err}")
record = await client.create_record(vector=vector, metadata=metadata)

If validation fails, fix your metadata according to the requirements of the server schema.

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

vector_store_client-1.1.3.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vector_store_client-1.1.3-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file vector_store_client-1.1.3.tar.gz.

File metadata

  • Download URL: vector_store_client-1.1.3.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for vector_store_client-1.1.3.tar.gz
Algorithm Hash digest
SHA256 d48bd7fb403bac80cad52f91f07f4209956e1593b6d53d1bc755e579d8b31aa4
MD5 20892b53cb08f0ab3807569a528658c7
BLAKE2b-256 4916fe40338e0601a095e093a79ef8dc36159987c43b6035046c3e97eb2a22c3

See more details on using hashes here.

File details

Details for the file vector_store_client-1.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for vector_store_client-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a03a598019b387ff99b86f0844ab19b882e25775095bef86331f0f1ee99a86cb
MD5 dd123b11d607a27b2af8ec1ef78a3d6c
BLAKE2b-256 31a2860be4d88e4d8586cbbc2cbc1bd0e6b32de7d20dba4bc10aca350e31fea9

See more details on using hashes here.

Supported by

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