Metadata-Version: 2.2
Name: brainbase-engine
Version: 0.1.1
Summary: Official Python SDK for Brainbase's REST & WebSocket API
Home-page: https://github.com/brainbase/brainbase-python
Author: Brainbase Labs
Author-email: 	support@usebrainbase.xyz
Project-URL: Bug Tracker, https://github.com/brainbase/brainbase-python/issues
Project-URL: Documentation, https://docs.brainbase.com/python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: websocket-client>=1.0.0
Requires-Dist: requests>=2.25.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: mypy>=0.900; extra == "dev"
Requires-Dist: sphinx>=4.0; extra == "dev"
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Brainbase Python SDK

The official Python SDK for interacting with Brainbase's REST & WebSocket API. This SDK provides a simple and intuitive way to establish real-time connections with Brainbase workers and handle streaming messages.

## Installation

```bash
pip install brainbase
```

## Features

- WebSocket-based real-time communication
- Message streaming support
- Event-driven architecture
- Function calling capabilities
- Connection monitoring
- Error handling

## Quick Start

```python
from brainbase import BrainbaseEngine

# Initialize the engine with your API key
engine = BrainbaseEngine("your-api-key")

# Get a worker instance
worker = engine.get_worker("worker-id")

# Define a message handler
def handle_message(data, ws):
    if isinstance(data, dict) and data.get("type") == "stream":
        print(data.get("content"), end="", flush=True)

# Establish connection
connection = worker.run(streaming=True)

# Register message handler
connection.on("message", handle_message)

# Send a message
connection.send("Hello, Brainbase!")
```

## Documentation

For detailed documentation, visit [https://docs.brainbase.com/python](https://docs.brainbase.com/python)

## API Reference

### BrainbaseEngine

The main class for interacting with Brainbase's API.

```python
engine = BrainbaseEngine(
    api_key="your-api-key",
)
```

### Worker

Represents a Brainbase worker that can establish WebSocket connections.

```python
worker = engine.get_worker("worker-id")
connection = worker.run(
    streaming=True,  # Enable message streaming
    monitor=True,    # Enable connection monitoring
    functions=[]     # Optional function definitions
)
```

### Connection

Manages the WebSocket connection to a Brainbase worker.

```python
# Register event handlers
connection.on("message", handle_message)
connection.on("error", handle_error)
connection.on("close", handle_close)

# Send messages
connection.send("Your message")

# Close connection
connection.close()
```

## Development

To set up the development environment:

1. Clone the repository
2. Install development dependencies:

```bash
pip install -e ".[dev]"
```

### Running Tests

```bash
pytest
```

### Code Formatting

```bash
black .
isort .
```

## Requirements

- Python 3.7+
- websocket-client>=1.0.0
- requests>=2.25.0

## License

MIT License

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## Support

For support, email support@usebrainbase.xyz or create an issue on our [GitHub repository](https://github.com/brainbase/brainbase-python/issues).

```

```
