# OomLlama

Smart LLM routing with TIBET provenance. Route queries to the right model, track everything.

## Installation

```bash
pip install oomllama
```

With TIBET provenance:
```bash
pip install oomllama[tibet]
```

## Quick Start

```python
from oomllama import OomLlama

# Simple generation
llm = OomLlama()
response = llm.generate("Hello!")

# With specific model
response = llm.generate("Complex question", model="qwen2.5:32b")

# Auto-routing (picks best model for the query)
llm = OomLlama(auto_route=True)
response = llm.generate("Write a Python function")  # Routes to code model
```

## Smart Routing

OomLlama automatically selects the best model based on your query:

```python
from oomllama import OomLlama, ModelRouter

llm = OomLlama(auto_route=True)

# Code query → routes to code-capable model
llm.generate("Write a binary search function")

# Simple query → routes to fast model
llm.generate("What is 2+2?")

# Complex query → routes to reasoning model
llm.generate("Explain quantum entanglement in detail...")
```

## TIBET Provenance

Track every LLM call with cryptographic provenance:

```python
from oomllama import OomLlama
from tibet_core import Provider

# Enable TIBET tracking
tibet = Provider(actor="jis:company:my_app")
llm = OomLlama(tibet=tibet)

# All calls now create provenance tokens
response = llm.generate("Summarize this document")

# Audit trail
for token in tibet.find(action="llm_generate"):
    print(f"{token.timestamp}: {token.erin['model']}")
    print(f"  Reason: {token.erachter}")
```

## CLI Usage

```bash
# Generate text
oomllama gen "Hello, how are you?"

# Auto-route
oomllama gen --auto "Write a Python web scraper"

# Interactive chat
oomllama chat -m qwen2.5:7b

# List models
oomllama list

# Check status
oomllama status
```

## Configuration

```python
from oomllama import OomLlama

llm = OomLlama(
    model="qwen2.5:7b",           # Default model
    ollama_url="http://localhost:11434",  # Ollama API
    auto_route=True,              # Enable smart routing
    system_prompt="You are helpful."  # Default system prompt
)

# Set defaults
llm.set_defaults(
    temperature=0.8,
    max_tokens=1024
)
```

## Custom Model Router

```python
from oomllama import OomLlama, ModelRouter, ModelConfig, ModelCapability

# Define your models
router = ModelRouter([
    ModelConfig(
        name="my-model:7b",
        size="7b",
        capabilities=[ModelCapability.CODE, ModelCapability.FAST],
        priority=30
    ),
])

llm = OomLlama(router=router, auto_route=True)
```

## Remote Ollama

```python
# Connect to remote GPU server
llm = OomLlama(ollama_url="http://192.168.4.85:11434")
```

## Requirements

- Python 3.10+
- [Ollama](https://ollama.ai) running locally or remotely

## License

MIT - Humotica

## Links

- [Humotica](https://humotica.com)
- [tibet-core](https://github.com/Humotica/tibet-core)
- [Ollama](https://ollama.ai)
