Skip to main content

Foundation package for the Bruno AI Assistant ecosystem

Project description

Bruno Core

Python Version License: MIT Code style: black Type Checked: mypy

Bruno Core is the foundational package for the Bruno AI assistant ecosystem. It provides a modular, extensible framework for building AI assistants with swappable components through a plugin-based architecture.

๐ŸŽฏ Key Features

  • ๐Ÿ”Œ Plugin Architecture: Dynamically load LLM providers, memory backends, and abilities via Python entry points
  • ๐ŸŽญ Interface-Based Design: Code against interfaces, not implementations - swap components without changing code
  • ๐Ÿ›ก๏ธ Type Safety: Full Pydantic v2 models with strict mypy type checking
  • โšก Async-First: Non-blocking I/O for all operations with concurrent ability execution
  • ๐Ÿ“ก Event-Driven: Decoupled components communicate via async event bus
  • ๐Ÿ“ Structured Logging: Built-in structured logging with structlog
  • ๐ŸŽจ Extensible: Create custom abilities, LLM providers, and memory backends

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Application Layer                    โ”‚
โ”‚         (Your AI Assistant Application)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ฒ
                      โ”‚ uses
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Plugin Layer                         โ”‚
โ”‚    (Abilities, LLM Providers, Memory Backends)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ฒ
                      โ”‚ implements
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Base Implementation Layer               โ”‚
โ”‚  (BaseAssistant, BaseAbility, ActionExecutor)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ฒ
                      โ”‚ uses
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Interface Layer                      โ”‚
โ”‚   (Contracts: LLMInterface, MemoryInterface)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ฒ
                      โ”‚ depends on
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Foundation Layer                     โ”‚
โ”‚    (Models, Utils, Registry, Events, Context)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

Installation

pip install bruno-core

Basic Usage

import asyncio
from bruno_core.base import BaseAssistant
from bruno_core.models import Message, MessageRole

# Import your LLM and Memory implementations
from my_llm import MyLLM
from my_memory import MyMemory

async def main():
    # Initialize components
    llm = MyLLM(api_key="your-api-key")
    memory = MyMemory()

    # Create assistant
    assistant = BaseAssistant(llm=llm, memory=memory)
    await assistant.initialize()

    # Process message
    message = Message(role=MessageRole.USER, content="Hello, Bruno!")
    response = await assistant.process_message(message)

    print(response.text)

asyncio.run(main())

๐Ÿ“ฆ Core Components

Interfaces

Define contracts for pluggable components:

  • AssistantInterface: Main orchestrator
  • LLMInterface: Language model providers
  • MemoryInterface: Storage backends
  • AbilityInterface: Executable actions

Base Implementations

Ready-to-use implementations:

  • BaseAssistant: Coordinates LLM, memory, and abilities
  • BaseAbility: Template for creating custom abilities
  • ActionExecutor: Manages concurrent ability execution

Models (Pydantic v2)

Type-safe data structures:

  • Message: Conversation messages with roles
  • ConversationContext: Session and user context
  • AbilityRequest/Response: Structured ability I/O

Plugin Registry

Dynamic component discovery:

  • Scan entry points: bruno.abilities, bruno.llm_providers, bruno.memory_backends
  • Validate plugin classes
  • Lazy instantiation

๐Ÿ”Œ Creating a Custom Ability

from bruno_core.base import BaseAbility
from bruno_core.models import AbilityMetadata, AbilityRequest, AbilityResponse

class CalculatorAbility(BaseAbility):
    def get_metadata(self) -> AbilityMetadata:
        return AbilityMetadata(
            name="calculator",
            description="Perform basic math operations",
            parameters=[...],
            examples=["Calculate 5 + 3"]
        )

    async def execute_action(self, request: AbilityRequest) -> AbilityResponse:
        operation = request.parameters["operation"]
        result = eval(f"{request.parameters['a']} {operation} {request.parameters['b']}")

        return AbilityResponse(
            request_id=request.id,
            ability_name="calculator",
            success=True,
            data={"result": result}
        )

Register in pyproject.toml:

[project.entry-points."bruno.abilities"]
calculator = "my_package.abilities:CalculatorAbility"

๐Ÿ› ๏ธ Development

Setup

# Clone repository
git clone https://github.com/meggy-ai/bruno-core.git
cd bruno-core

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

# Install dev dependencies
pip install -e ".[dev,test,docs]"

# Install pre-commit hooks
pre-commit install

Testing

# Run all tests
pytest

# With coverage
pytest --cov=bruno_core --cov-report=term-missing

# Specific test file
pytest tests/unit/test_base.py

Code Quality

# Format code
black bruno_core/ tests/ examples/

# Type checking
mypy bruno_core/

# Linting
ruff check bruno_core/

Pre-commit hooks automatically run formatting, linting, and type checking.

๐Ÿ“š Documentation

Local Documentation

# Serve docs locally
mkdocs serve

# Build static site
mkdocs build

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Commit Conventions

Follow Conventional Commits:

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • test: Test changes
  • refactor: Code restructuring

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ”— Related Projects

  • bruno-llm: LLM provider implementations (OpenAI, Claude, Ollama)
  • bruno-memory: Memory backend implementations (SQLite, Redis, PostgreSQL)
  • bruno-abilities: Pre-built abilities (timers, notes, weather)
  • bruno-pa: Personal assistant application

๐Ÿ“ž Support


Made with โค๏ธ by the Meggy AI team

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

bruno_core-0.1.0.tar.gz (55.4 kB view details)

Uploaded Source

Built Distribution

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

bruno_core-0.1.0-py3-none-any.whl (69.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bruno_core-0.1.0.tar.gz
  • Upload date:
  • Size: 55.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for bruno_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5953ea161c376cbfb14ec40da3aaf0102ec33251066d7685f3aab0871ac2c37b
MD5 6e8f49ab76c3543a034236bee777bbaa
BLAKE2b-256 c5d69269d686b002834c04953e050db859ec7b641e76df63aae1b23303a7699a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bruno_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 69.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for bruno_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5d90b1d4836817f110510d740852e663926bef4757cbce83e0441e03b116f98
MD5 95c82bfbabff0aca749e9fdff89f0401
BLAKE2b-256 4457be8a34e83087edae58fb0aa4a0f592db766743a5361616543f493a25120e

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