Skip to main content

The official Python SDK for the ColiVara API

Project description

colivara-py

PyPI Changelog License Tests codecov

The official Python SDK for the ColiVara API

Installation

Install this library using pip:

pip install colivara-py

Usage

Please see the ColiVara API documentation for more information on how to use this library.

from colivara import ColiVara

rag_client = ColiVara(api_key='your-api-key')
# Create a new collection
new_collection = rag_client.create_collection(name="my_collection", metadata={"description": "A sample collection"})
print(f"Created collection: {new_collection.name}")

# Upload a document to the collection
document = rag_client.upsert_document(
    name="sample_document",
    collection_name="my_collection",
    url="https://example.com/sample.pdf",
    metadata={"author": "John Doe"}
)
print(f"Uploaded document: {document.name}")

# Search for documents
search_results = rag_client.search(
    query="machine learning",
    collection_name="my_collection",
    top_k=3
)
for result in search_results.results:
    print(f"Page {result.page_number} of {result.document_name}: Score {result.normalized_score}")

# List documents in a collection
documents = client.list_documents(collection_name="my_collection")
for doc in documents:
    print(f"Document: {doc.name}, Pages: {doc.num_pages}")

# Generate embeddings
embeddings = rag_client.create_embedding(
    input_data=["This is a sample text for embedding"],
    task="query"
)
print(f"Generated {len(embeddings.data)} embeddings")

# Delete a document
rag_client.delete_document("sample_document", collection_name="my_collection")
print("Document deleted")

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

We use uv, but you can use the pip interface if you prefer:

cd colivara-py
uv .venv
source .venv/bin/activate

Now install the dependencies and test dependencies:

uv sync --extra dev-dependencies

To run the tests:

pytest

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

colivara_py-0.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

colivara_py-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: colivara_py-0.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for colivara_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 51e2e7b7220ea0e2837a826e811e0e1c7bc4fea270d2d4d1f3d1533c706e3ad5
MD5 2713a81302bc4a7a1b537534ba1e5bd9
BLAKE2b-256 6a7ef8212d012d568416de4da6f1cdabeaea366471b279af1bb80358e5a90d3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: colivara_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for colivara_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 059e5c808896bc8ed89c674594042efc1f83eda64baadbd28a0856c14a1cb952
MD5 c1d3723d69b1aa2ce226097743efbb21
BLAKE2b-256 ebb97ff3abab9f8ffe698efb9e447cc000bf5946c53a646d8b916b2dff326ed1

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