# Meowdel Python SDK

Official Python client for the Meowdel AI API.

## Installation

```bash
pip install meowdel
```

Or install from source:

```bash
git clone https://github.com/afterdarksystems/meowdel-python
cd meowdel-python
pip install -e .
```

## Quick Start

```python
from meowdel import MeowdelClient

# Initialize client
client = MeowdelClient(api_key="mdl_your_key_here")

# Simple chat
response = client.chat("How do I fix this TypeScript error?")
print(response.message)

# Chat with personality and Brain context
response = client.chat(
    message="Explain quantum computing",
    personality="professor",
    use_brain_context=True
)
print(response.message)

# Combine multiple operations
response = client.combine(
    query="What is machine learning?",
    operations=["search", "explain", "visualize"],
    primary_personality="professor"
)
print(response.result)
```

## Configuration

### API Key

Set your API key via environment variable:

```bash
export MEOWDEL_API_KEY="mdl_your_key_here"
```

Or pass it directly:

```python
client = MeowdelClient(api_key="mdl_your_key_here")
```

Get your API key from: https://meowdel.ai/profile

### Custom Base URL

```python
client = MeowdelClient(
    api_key="mdl_your_key_here",
    base_url="https://api.meowdel.ai"  # Custom endpoint
)
```

## API Reference

### Chat

```python
response = client.chat(
    message="Your question here",
    personality="mittens",  # mittens, luna, professor, ninja, zoomies
    use_brain_context=False,
    conversation_history=[
        {"role": "user", "content": "Previous message"},
        {"role": "assistant", "content": "Previous response"}
    ]
)

print(response.message)
print(response.personality)
print(response.tokens_used)
```

### Combine Operations

```python
response = client.combine(
    query="What is recursion?",
    operations=["search", "explain", "code_example"],
    primary_personality="professor",
    secondary_personality="mittens"
)

print(response.result)
print(response.operations)
```

### Context Manager

```python
with MeowdelClient(api_key="mdl_your_key") as client:
    response = client.chat("Hello!")
    print(response.message)
# Session automatically closed
```

## Available Personalities

- `mittens` - Playful and friendly
- `luna` - Elegant and sophisticated
- `professor` - Scholarly and analytical
- `ninja` - Stealthy and mysterious
- `zoomies` - Hyper and energetic
- And more!

## Error Handling

```python
from meowdel import MeowdelClient, AuthenticationError, RateLimitError, APIError

try:
    client = MeowdelClient(api_key="mdl_invalid")
    response = client.chat("Hello")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded")
except APIError as e:
    print(f"API error: {e}")
```

## Examples

### Chat with conversation history

```python
from meowdel import MeowdelClient, Message

client = MeowdelClient()

history = [
    Message(role="user", content="What is Python?"),
    Message(role="assistant", content="Python is a programming language..."),
]

response = client.chat(
    message="Can you give me an example?",
    conversation_history=history
)
```

### Using Brain context

```python
# Query with knowledge graph context
response = client.chat(
    message="What did we discuss about Docker?",
    use_brain_context=True,
    personality="professor"
)
```

## Development

```bash
# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black meowdel/

# Type checking
mypy meowdel/
```

## License

MIT

## Support

- Documentation: https://docs.meowdel.ai
- Issues: https://github.com/afterdarksystems/meowdel-python/issues
- Email: support@meowdel.ai
