# Agata Chat

Interactive and non-interactive chat with AI models via OpenRouter or Ollama.

## Usage

### Interactive Mode (default)
```bash
agata chat
```

### Single Query
```bash
agata chat "What is the capital of France?"
agata chat "Explain quantum physics" --model openai/gpt-4
```

### From File
```bash
agata chat -f prompt.txt
agata chat -f prompt.txt -o response.txt
cat prompt.txt | agata chat -f -
```

## Options

| Option | Description |
|--------|-------------|
| `-m, --model` | Model to use (e.g., `openai/gpt-4`, `anthropic/claude-3-opus`) |
| `-p, --provider` | Provider: `openrouter` (default) or `ollama` |
| `-t, --timeout` | Timeout in seconds (default: 60 for OpenRouter, 90 for Ollama) |
| `-f, --input-file` | Read prompt from file (use `-` for stdin) |
| `-o, --output-file` | Save response to file |
| `-s, --system-prompt` | Custom system prompt (overrides config) |

## Interactive Commands

Once in interactive mode:

| Command | Description |
|---------|-------------|
| `/q, /quit, /exit` | Exit chat |
| `/c, /clear, /r` | Clear conversation history |
| `/m, /model <name>` | Switch to a model for this session |
| `/m` | Show current model |
| `/mf, /modelsfree` | List free models from OpenRouter |
| `/mp, /modelspaid` | List paid models from OpenRouter |
| `/mx, /modelsx` | List preferred models (marked with `*`) |
| `/mx <model>` | Set a working model as default |

## System Prompt

The default system prompt can be customized:

```bash
# View current system prompt
agata system-prompt

# Set custom prompt (use {timestamp} for current time)
agata system-prompt --set "You are an expert coder. Time: {timestamp}"
agata system-prompt -s "You are a helpful assistant. Current time: {timestamp}"

# Reset to default
agata system-prompt --reset
```

The `{timestamp}` placeholder is automatically replaced with the current datetime at runtime.

### One-time Override

Use `-s` or `--system-prompt` with the chat command to override for a single session:

```bash
# Use custom prompt for this chat only
agata chat "Hello" -s "You are a Python expert. Time: {timestamp}"
```

## Configuration Files

Config stored in `~/.config/agata/`:

- `config.yaml` - Default models, preferred models, default provider, system prompt
- `successful_models.yaml` - Models that worked (with timestamps)
- `failed_models.yaml` - Models that failed (with timestamps)

## Examples

```bash
# Interactive chat with default model
agata chat

# Use specific model
agata chat "Hello" -m openai/gpt-5.4

# Use local Ollama
agata chat "Hello" -p ollama -m llama3.2

# Longer timeout for complex queries
agata chat "Write a novel" -t 120

# Batch processing
agata chat -f task.yaml -o result.txt

# Custom system prompt for single query
agata chat "Review this code" -s "You are a senior developer. Time: {timestamp}"
```
