Skip to main content

Common utilities and base functionalities for all skills in the Private Assistant ecosystem.

Project description

Private Assistant Commons

Copier python uv Ruff Checked with mypy pre-commit

Owner: stkr22

Common utilities and base classes for building distributed voice assistant skills in a Private Assistant ecosystem. This library provides the foundation for creating modular, MQTT-based skills that process voice commands for home automation.

Key Features

  • BaseSkill Framework: Abstract base class with distributed processing, certainty-based filtering, and task management
  • MQTT Communication: Structured message handling using Pydantic models with automatic reconnection
  • Location Awareness: Support for room-based command routing and targeting
  • Audio Integration: Configurable alerts and responses through voice bridge system
  • Performance Metrics: Built-in monitoring with Prometheus export and health checking for production deployments
  • Optional Persistence: PostgreSQL integration for skills requiring state storage

Quick Start

Installation

pip install private-assistant-commons

Basic Skill Example

from private_assistant_commons import BaseSkill, IntentRequest, IntentType

class LightControlSkill(BaseSkill):
    async def calculate_certainty(self, intent_request: IntentRequest) -> float:
        intent = intent_request.classified_intent
        if intent.intent_type in (IntentType.DEVICE_ON, IntentType.DEVICE_OFF):
            return intent.confidence
        return 0.0

    async def process_request(self, intent_request: IntentRequest) -> None:
        await self.send_response("Lights controlled!", intent_request.client_request)

    async def skill_preparations(self) -> None:
        self.logger.info("Light skill ready")

Documentation

📖 Full Documentation

System Overview

Private Assistant Commons enables building a distributed voice assistant system where:

  • Skills run independently and decide whether to handle requests based on confidence scores
  • Communication via MQTT using structured Pydantic messages
  • No central coordinator - skills compete based on certainty thresholds
  • Room-based targeting distinguishes command origin from target locations
  • Local deployment typically on Kubernetes with STT/TTS APIs

Architecture

User Voice → Local Client → Voice Bridge → STT API → MQTT Broker
                                                         ↓
Intent Analysis Engine ← MQTT Broker ← Skills (distributed processing)
                                                         ↓
Voice Bridge ← TTS API ← MQTT Broker ← Skill Responses
       ↓
Local Client → Audio Output

Skills inherit from BaseSkill and implement:

  • calculate_certainty() - Confidence scoring for requests
  • process_request() - Main skill logic
  • skill_preparations() - Initialization setup

Development

Prerequisites

  • Python 3.12+
  • UV package manager

Setup

# Clone and setup environment
git clone <repository-url>
cd private-assistant-commons-py
uv sync --group dev

# Run tests
uv run pytest

# Format and lint
uv run ruff format .
uv run ruff check .

# Type checking
uv run mypy src/

Essential Commands

  • uv sync --group dev - Install/update dependencies
  • uv run pytest - Run tests with coverage
  • uv run ruff check . - Lint code
  • uv run mypy src/ - Type check
  • pre-commit run --all-files - Run all pre-commit hooks

License

GNU General Public License v3.0 - 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

private_assistant_commons-5.2.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

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

private_assistant_commons-5.2.0-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file private_assistant_commons-5.2.0.tar.gz.

File metadata

File hashes

Hashes for private_assistant_commons-5.2.0.tar.gz
Algorithm Hash digest
SHA256 b6d96ed5e1877965dbdd8d2478e2e073292a5c4f3cec516ca9e86e377cebf20e
MD5 5afc6ccf75f0e1285beb2e060fede01c
BLAKE2b-256 806db11ed95e09df44b94fcdae220980946707d36b027266a250858188b953d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for private_assistant_commons-5.2.0.tar.gz:

Publisher: release-to-pypi.yml on stkr22/private-assistant-commons-py

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

File details

Details for the file private_assistant_commons-5.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for private_assistant_commons-5.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba66a8846adda08dbe83fc8708371f18b8bea1addd0581ddda25ff4d0462c5c1
MD5 1236bc1d70a584b7d26364a0d2460bbc
BLAKE2b-256 e0096fd3d4f646adbdea1401e7d5a792907a3d6cf66d83c16a5c81a7851a0da9

See more details on using hashes here.

Provenance

The following attestation bundles were made for private_assistant_commons-5.2.0-py3-none-any.whl:

Publisher: release-to-pypi.yml on stkr22/private-assistant-commons-py

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