Skip to main content

Python client for Barq DB

Project description

Barq SDK Python

Official Python client for Barq DB - a high-performance vector database.

Installation

pip install barq-sdk-python

Quick Start

HTTP Client

from barq import BarqClient

# Initialize client
client = BarqClient("http://localhost:8080", api_key="your-api-key")

# Check health
if client.health():
    print("Connected!")

# Create a collection
client.create_collection(
    name="documents",
    dimension=384,
    metric="L2"
)

# Insert a document
client.insert_document(
    collection="documents",
    id=1,
    vector=[0.1] * 384,
    payload={"title": "Hello World"}
)

# Search
results = client.search(
    collection="documents",
    vector=[0.1] * 384,
    top_k=5
)

for result in results:
    print(f"ID: {result['id']}, Score: {result['score']}")

client.close()

gRPC Client

from barq import GrpcClient

# Initialize gRPC client
client = GrpcClient("localhost:50051")

# Check health
if client.health():
    print("Connected via gRPC!")

# Create collection
client.create_collection(
    name="documents",
    dimension=384,
    metric="L2"
)

# Insert document
client.insert_document(
    collection="documents",
    id="doc1",
    vector=[0.1] * 384,
    payload={"title": "Hello World"}
)

# Search
results = client.search(
    collection="documents",
    vector=[0.1] * 384,
    top_k=5
)

for result in results:
    print(f"ID: {result['id']}, Score: {result['score']}")

API Reference

BarqClient (HTTP)

Method Description
health() Check server health
create_collection(name, dimension, metric, index, text_fields) Create a new collection
insert_document(collection, id, vector, payload) Insert a document
search(collection, vector, query, top_k, filter) Search for similar vectors
close() Close the client connection

GrpcClient

Method Description
health() Check server health
create_collection(name, dimension, metric) Create a new collection
insert_document(collection, id, vector, payload) Insert a document
search(collection, vector, top_k) Search for similar vectors

Requirements

  • Python >= 3.8
  • httpx >= 0.23
  • grpcio >= 1.50.0
  • protobuf >= 4.21.0

License

MIT License - see LICENSE for details.

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

barq_sdk_python-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

barq_sdk_python-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file barq_sdk_python-0.1.0.tar.gz.

File metadata

  • Download URL: barq_sdk_python-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for barq_sdk_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac12f14aa5d9beedcf8baae54bc7dc7a14098db5a6a48cf60d798258ed58b0b6
MD5 6c1070b1ea63444ee866b8f0cfb98e29
BLAKE2b-256 7790a3e4c5b8036a11b3c8a321f76a533bf47421121b0300f427435f0d4270fd

See more details on using hashes here.

File details

Details for the file barq_sdk_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for barq_sdk_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a59d7cb5b6e5f9eece350dd93db855201e96faefeae41d84c48c88e071cacd
MD5 e22df5509115bf55006b096b3229406c
BLAKE2b-256 86a3406029782abf6d3826ddf4b219ea91fe82d38354c570ec1b941e3e428f85

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