Skip to main content

WaveAssist Python SDK for storing and retrieving structured data, LLM integration, and credit management

Project description

WaveAssist SDK & CLI ๐ŸŒŠ

WaveAssist SDK makes it simple to store and retrieve data in your automation workflows. Access your projects through our Python SDK or CLI.


โœจ Features

  • ๐Ÿ” One-line init() to connect with your WaveAssist project
  • โš™๏ธ Automatically works on local and WaveAssist Cloud (worker) environments
  • ๐Ÿ“ฆ Store and retrieve data (DataFrames, JSON, strings)
  • ๐Ÿง  LLM-friendly function names (init, store_data, fetch_data)
  • ๐Ÿ“ Auto-serialization for common Python objects
  • ๐Ÿค– LLM integration with structured outputs via Instructor and OpenRouter
  • ๐Ÿ’ณ Credit management and automatic email notifications
  • ๐Ÿ–ฅ๏ธ Command-line interface for project management
  • โœ… Built for automation workflows, cron jobs, and AI pipelines

๐Ÿš€ Getting Started

1. Install

pip install waveassist

2. Initialize the SDK

import waveassist

# Option 1: Use no arguments (recommended)
waveassist.init()

# Option 2: With explicit parameters
waveassist.init(
    token="your-user-id",
    project_key="your-project-key",
    environment_key="your-env-key",  # optional
    run_id="run-123",  # optional
    check_credits=True  # optional: raises error if credits_available is "0"
)

# Will auto-resolve from:
# 1. Explicit args (if passed)
# 2. .env file (uid, project_key, environment_key)
# 3. Worker-injected credentials (on [WaveAssist Cloud](https://waveassist.io))

๐Ÿ›  Setting up .env (for local runs)

uid=your-user-id
project_key=your-project-key

# optional
environment_key=your-env-key

This file will be ignored by Git if you use our default .gitignore.


3. Store Data

๐Ÿงพ Store a string

waveassist.store_data("welcome_message", "Hello, world!")

๐Ÿ“Š Store a DataFrame

import pandas as pd

df = pd.DataFrame({"name": ["Alice", "Bob"], "score": [95, 88]})
waveassist.store_data("user_scores", df)

๐Ÿง  Store JSON/dict/array

profile = {"name": "Alice", "age": 30}
waveassist.store_data("profile_data", profile)

4. Fetch Data

result = waveassist.fetch_data("user_scores")

# Will return:
# - A DataFrame (if stored as one)
# - A dict/list (if stored as JSON)
# - A string (if stored as text)

5. Check Credits and Notify

Check OpenRouter credits and automatically send email notifications if insufficient credits are available:

# Check if you have enough credits for an operation
has_credits = waveassist.check_credits_and_notify(
    required_credits=10.5,
    assistant_name="WavePredict"
)

if has_credits:
    # Proceed with your operation
    print("Credits available, proceeding...")
else:
    # Credits insufficient - email notification sent (max 3 times)
    print("Insufficient credits, operation skipped")

Features:

  • Automatically checks OpenRouter credit balance
  • Sends email notification if credits are insufficient (max 3 times)
  • Resets notification count when credits become sufficient
  • Stores credit availability status for workflow control

6. Call LLM with Structured Outputs

Use Instructor library to get structured responses from LLMs via OpenRouter:

from pydantic import BaseModel

# Define your response structure
class UserInfo(BaseModel):
    name: str
    age: int
    email: str

# Call LLM with structured output
result = waveassist.call_llm(
    model="gpt-4o",
    prompt="Extract user info: John Doe, 30, john@example.com",
    response_model=UserInfo
)

print(result.name)  # "John Doe"
print(result.age)    # 30
print(result.email)  # "john@example.com"

Setup:

  1. Store your OpenRouter API key:
waveassist.store_data('open_router_key', 'your_openrouter_api_key')
  1. Use call_llm() with any Pydantic model for structured outputs

Advanced Usage:

result = waveassist.call_llm(
    model="anthropic/claude-3-opus",
    prompt="Analyze this data...",
    response_model=MyModel,
    max_tokens=3000,
    extra_body={"web_search_options": {"search_context_size": "medium"}}
)

๐Ÿ–ฅ๏ธ Command Line Interface

WaveAssist CLI comes bundled with the Python package. After installation, you can use the following commands:

๐Ÿ”‘ Authentication

waveassist login

This will open your browser for authentication and store the token locally.

๐Ÿ“ค Push Code

waveassist push PROJECT_KEY [--force]

Push your local Python code to a WaveAssist project.

๐Ÿ“ฅ Pull Code

waveassist pull PROJECT_KEY [--force]

Pull Python code from a WaveAssist project to your local machine.

โ„น๏ธ Version Info

waveassist version

Display CLI version and environment information.


๐Ÿงช Running Tests

Run the test files directly:

# Core SDK tests (init, store_data, fetch_data)
python tests/test_core.py

# JSON generation tests (create_json_prompt, generate_json_template)
python tests/test_json_generate.py

# JSON extraction/parsing tests (extract_json_from_content, soft_parse, parse_json_response)
python tests/test_json_extract.py

โœ… Includes tests for:

  • String, JSON, and DataFrame roundtrips
  • Error handling when init() is not called
  • Environment variable and .env file resolution
  • JSON template generation for Pydantic models
  • JSON extraction from various formats (pure JSON, markdown code blocks, embedded text)
  • Soft parsing with missing required fields (safety fallback for LLM responses)
  • Type coercion and nested model handling

๐Ÿ›  Project Structure

WaveAssist/
โ”œโ”€โ”€ waveassist/
โ”‚   โ”œโ”€โ”€ __init__.py          # init(), store_data(), fetch_data(), check_credits_and_notify(), call_llm()
โ”‚   โ”œโ”€โ”€ _config.py           # Global config vars
โ”‚   โ”œโ”€โ”€ constants.py         # Constants and email templates
โ”‚   โ”œโ”€โ”€ utils.py             # API utilities, JSON parsing, soft_parse
โ”‚   โ””โ”€โ”€ cli.py               # Command-line interface
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_core.py         # Core SDK tests (init, store, fetch)
โ”‚   โ”œโ”€โ”€ test_json_generate.py # JSON template generation tests
โ”‚   โ””โ”€โ”€ test_json_extract.py  # JSON extraction/parsing tests

๐Ÿ“Œ Notes

  • Data is stored in your WaveAssist backend (e.g. MongoDB) as serialized content
  • store_data() auto-detects the object type and serializes it (CSV/JSON/text)
  • fetch_data() deserializes it back to the right Python object

๐Ÿง  Example Use Cases

Basic Data Storage

import waveassist
waveassist.init()  # Auto-initialized from .env or worker

# Store GitHub PR data
waveassist.store_data("latest_pr", {
    "title": "Fix bug in auth",
    "author": "alice",
    "status": "open"
})

# Later, fetch it for further processing
pr = waveassist.fetch_data("latest_pr")
print(pr["title"])

LLM Integration with Credit Management

import waveassist
from pydantic import BaseModel

waveassist.init()

# Store OpenRouter API key
waveassist.store_data('open_router_key', 'your_api_key')

# Check credits before expensive operation
required_credits = 5.0
if waveassist.check_credits_and_notify(required_credits, "MyAssistant"):
    # Use LLM with structured output
    class AnalysisResult(BaseModel):
        summary: str
        confidence: float
        recommendations: list[str]

    result = waveassist.call_llm(
        model="gpt-4o",
        prompt="Analyze this data and provide recommendations...",
        response_model=AnalysisResult
    )

    # Store the structured result
    waveassist.store_data("analysis_result", result.dict())

๐Ÿค Contributing

Want to add formats, features, or cloud extensions? PRs welcome!


๐Ÿ“ฌ Contact

Need help or have feedback? Reach out at connect@waveassist.io, visit WaveAssist.io, or open an issue.


ยฉ 2025 WaveAssist

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

waveassist-0.4.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

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

waveassist-0.4.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file waveassist-0.4.0.tar.gz.

File metadata

  • Download URL: waveassist-0.4.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for waveassist-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c15768c42d5a1490c59f57530c4763126126e416e6552b6a1574e9e6d2b5bfa6
MD5 7b2b0ad35dd2eccc1105cde64eed7854
BLAKE2b-256 c5f5603ea7c01da07934d1dd74595f8bab8566eb2e761e3e5e7a3640120c58da

See more details on using hashes here.

Provenance

The following attestation bundles were made for waveassist-0.4.0.tar.gz:

Publisher: python-publish.yml on WaveAssist/WaveAssist

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

File details

Details for the file waveassist-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: waveassist-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for waveassist-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38984b0a2efec553702b5febd922c9206866c2df35546f5e4214d86b502ef4f7
MD5 da9dcc03badba21fe87f4026b0c9aa70
BLAKE2b-256 39aff7ab5d987f5c73c3f8618cf178dc3def72447e8dd9ef6f0af60ce0259379

See more details on using hashes here.

Provenance

The following attestation bundles were made for waveassist-0.4.0-py3-none-any.whl:

Publisher: python-publish.yml on WaveAssist/WaveAssist

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