Foundation package for the Bruno AI Assistant ecosystem
Project description
Bruno Core
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 orchestratorLLMInterface: Language model providersMemoryInterface: Storage backendsAbilityInterface: Executable actions
Base Implementations
Ready-to-use implementations:
BaseAssistant: Coordinates LLM, memory, and abilitiesBaseAbility: Template for creating custom abilitiesActionExecutor: Manages concurrent ability execution
Models (Pydantic v2)
Type-safe data structures:
Message: Conversation messages with rolesConversationContext: Session and user contextAbilityRequest/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 featuresfix:Bug fixesdocs:Documentation changestest:Test changesrefactor: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
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: https://meggy-ai.github.io/bruno-core/
Made with โค๏ธ by the Meggy AI team
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5953ea161c376cbfb14ec40da3aaf0102ec33251066d7685f3aab0871ac2c37b
|
|
| MD5 |
6e8f49ab76c3543a034236bee777bbaa
|
|
| BLAKE2b-256 |
c5d69269d686b002834c04953e050db859ec7b641e76df63aae1b23303a7699a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5d90b1d4836817f110510d740852e663926bef4757cbce83e0441e03b116f98
|
|
| MD5 |
95c82bfbabff0aca749e9fdff89f0401
|
|
| BLAKE2b-256 |
4457be8a34e83087edae58fb0aa4a0f592db766743a5361616543f493a25120e
|