Skip to main content

Python SDK for the Laive RAG API

Project description

Laive Python SDK

PyPI version Python Support Laive

The Laive Python SDK provides a simple and convenient way to interact with the Laive RAG (Retrieval-Augmented Generation) API. This library allows you to easily upload documents, create vaults, and perform intelligent queries on your document collections.

Ressources

This SDK is still in beta. Please report any issues or feedback to contact@laive.ai or open an issue on GitHub

Installation

# Install via pip
pip install laive-sdk

# Or install from source
git clone https://github.com/laive/Python-SDK.git
cd Python-SDK
pip install -e .

Quick Start

import os
from laive import LaiveClient

# Initialize the client with your API key
client = LaiveClient(api_key=os.getenv("LAIVE_API_KEY"))

# Query a vault
results = client.query(
    query="What is the best way to implement RAG?",
    vault_id=123,
    top_k=5
)

print(f"Found {len(results.sources)} relevant documents")

Authentication

Set your API key as an environment variable:

export LAIVE_API_KEY="your_api_key_here"

Or pass it directly when creating the client:

client = LaiveClient(api_key="your_api_key_here")

API Reference

Client Initialization

from laive import LaiveClient

client = LaiveClient(
    api_key="your_api_key",
)

Query Documents

Retrieve relevant documents from a vault based on a search query.

response = client.query(
    query="What is retrieval augmented generation?",
    vault_id=123,  # Optional, if not provided searches across all accessible vaults
    top_k=4  # Optional, defaults to 4
)

# Access results
for source in response.sources:
    print(f"Document: {source['source_name']}")
    print(f"Content: {source['page_content'][:100]}...")
    print(f"Relevance score: {source['score']}")

Upload Files

Upload one or more files to a vault.

response = client.upload_files(
    files=["path/to/document1.pdf", "path/to/document2.docx"],
    source_names=["Document 1", "Document 2"],
    vault_id=123,
    source_urls=["https://example.com/doc1", "https://example.com/doc2"]  # Optional
)

print(f"Started processing {response.files_processed} files")
print(f"Task IDs: {response.task_ids}")

Check Task Status

Check the status of a file processing task.

task_status = client.get_task_status(task_id="task_id_from_upload_response")
print(f"Task state: {task_status['state']}")
print(f"Status: {task_status['status']}")

Jupyter Notebooks

Check out the notebooks/ directory for interactive Jupyter notebooks:

  • 📓 notebooks/simple_query_example.ipynb - Simple querying example in notebook format
  • 📚 notebooks/vault_management_workflow.ipynb - Complete vault management workflow

Development

Installing from Source

git clone https://github.com/laive/Python-SDK.git
cd Python-SDK
pip install -e .

Running Notebooks

# Copy environment template
cp .env.example .env
# Edit .env with your API key

# Install Jupyter and run notebooks
pip install jupyter
export LAIVE_API_KEY="your_api_key_here"
cd notebooks
jupyter notebook

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

laive_sdk-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.

laive_sdk-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for laive_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 50fa776459f5f2f153cf9216c79d09ab315f2ba3ed0e5e0954384df65aa6d0d1
MD5 0fc3ba4a5148231aef94c8b630f76508
BLAKE2b-256 0bf20860876db26e0e0493a98d43728a444eb77430c1889dc13e17d439ef6c4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for laive_sdk-0.1.0.tar.gz:

Publisher: python-publish.yml on laiveai/Python-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: laive_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for laive_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08c5c253ad8f001cb537db08260984d94cb0cdb7e4f93c20e678c07b97905f61
MD5 51739887a4f9107b8228311ec48e1ec3
BLAKE2b-256 9b9fcb9aa44ec076b1124ef9919877b334b94f8b1c40db3a76d7828aa75d7d0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for laive_sdk-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on laiveai/Python-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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