The official Python SDK for the ColiVara API
Project description
colivara-py
The official Python SDK for the ColiVara API. ColiVara is a document search and retrieval API that uses advanced machine learning techniques to index and search documents. This SDK allows you to interact with the API to create collections, upload documents, search for documents, and generate embeddings.
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.
You will need to either self-host the API (see the ColiVara API repo) or use the hosted version at https://colivara.com. You will also need an API key, which you can obtain by signing up at ColiVara or from your self-hosted API.
import os
from colivara_py import ColiVara
rag_client = ColiVara(
# This is the default and can be omitted
api_key=os.environ.get("COLIVARA_API_KEY"),
# This is the default and can be omitted
base_url="https://api.colivara.com"
)
# Create a new collection (optional)
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",
# optional, defaults to "default collection"
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
To build the documenation locally:
pdocs server colivara_py #to see the documentation locally.
pdocs as_html colivara_py --overwrite #to generate HTML.
pdocs as_markdown colivara_py #to generate markdown.
License
This SDK is distributed under the Apache License, Version 2.0. The API is licensed under Functional Source License, Version 1.1, Apache 2.0 Future License. See the LICENSE.md file for details.
For commercial licensing, please contact us at tjmlabs.com. We are happy to work with you to provide a license that meets your needs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file colivara_py-1.2.3.tar.gz.
File metadata
- Download URL: colivara_py-1.2.3.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb5d6bc4e18ec2ee67f283de9aada26659bfdf73859836c18042cfb787bcd8f1
|
|
| MD5 |
6d633d0486e472af3b32f8cbff9c298b
|
|
| BLAKE2b-256 |
005917ff92a4b1971ce9daa90102b65b45ef64ef002dcae406a805c840c645f0
|
Provenance
The following attestation bundles were made for colivara_py-1.2.3.tar.gz:
Publisher:
publish.yml on tjmlabs/colivara-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colivara_py-1.2.3.tar.gz -
Subject digest:
eb5d6bc4e18ec2ee67f283de9aada26659bfdf73859836c18042cfb787bcd8f1 - Sigstore transparency entry: 146921888
- Sigstore integration time:
-
Permalink:
tjmlabs/colivara-py@5874eb6666ccb039398f1cd892b9c9f7cc0911e3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tjmlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5874eb6666ccb039398f1cd892b9c9f7cc0911e3 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file colivara_py-1.2.3-py3-none-any.whl.
File metadata
- Download URL: colivara_py-1.2.3-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f2a87e8c793ef643194c4f135312f3b888c8ed347c2bf5655fed9ba7036e3ce
|
|
| MD5 |
4bee559f418c15286c3eda21f221e802
|
|
| BLAKE2b-256 |
b4ae2415e98f67411afc470280303a6c4ecd01cff3aedf0ffc2146f69decd7ae
|
Provenance
The following attestation bundles were made for colivara_py-1.2.3-py3-none-any.whl:
Publisher:
publish.yml on tjmlabs/colivara-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colivara_py-1.2.3-py3-none-any.whl -
Subject digest:
6f2a87e8c793ef643194c4f135312f3b888c8ed347c2bf5655fed9ba7036e3ce - Sigstore transparency entry: 146921891
- Sigstore integration time:
-
Permalink:
tjmlabs/colivara-py@5874eb6666ccb039398f1cd892b9c9f7cc0911e3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tjmlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5874eb6666ccb039398f1cd892b9c9f7cc0911e3 -
Trigger Event:
pull_request
-
Statement type: