72 lines
3.9 KiB
Markdown
72 lines
3.9 KiB
Markdown
# Sloppy
|
|
|
|
Sloppy is a terminal app where two AI models discuss an initial prompt. AI 1 replies first, then AI 2, alternating for a chosen number of replies. It supports OpenAI-compatible chat-completions APIs, including local servers.
|
|
|
|
## Setup
|
|
|
|
Use Python 3.10 or newer and configure two reachable models. The same endpoint can serve both.
|
|
|
|
```powershell
|
|
python -m venv .venv
|
|
.venv\Scripts\Activate.ps1
|
|
python -m pip install -r requirements.txt
|
|
Copy-Item .env.example .env
|
|
```
|
|
|
|
Edit `.env` for your endpoints, keys, model IDs, and topic, then run `python run_example.py`. On macOS or Linux, activate with `source .venv/bin/activate` and copy the example with `cp .env.example .env`. `python ai_chat.py` is an equivalent entry point.
|
|
|
|
```powershell
|
|
python run_example.py --prompt "Can AI be creative?" --turns 6
|
|
python run_example.py --help
|
|
```
|
|
|
|
## Configuration
|
|
|
|
`.env` accepts `AI1_NAME`, `AI1_BASE_URL`, `AI1_API_KEY`, `AI1_MODEL`, and `AI1_SYSTEM_PROMPT`, plus matching `AI2_*` variables. `INITIAL_PROMPT` is required. `MAX_TURNS` defaults to 20 and must be positive. Set each base URL to an API root such as `http://localhost:11434/v1`; Sloppy appends `/chat/completions`.
|
|
|
|
Command-line options `--ai1-name`, `--ai1-url`, `--ai1-key`, `--ai1-model`, `--ai1-prompt` and matching `--ai2-*` options override `.env` values for a run. When any connection option is supplied, both connections need a base URL and API key after applying defaults. Prefer environment variables over command-line arguments for hosted-provider secrets, since command-line values can enter shell history.
|
|
|
|
Press **Ctrl+M** to add, edit, delete, and select saved connections. They are stored in `sloppy.json` in the current working directory:
|
|
|
|
```json
|
|
{
|
|
"models": {
|
|
"local": {
|
|
"name": "Local Llama",
|
|
"base_url": "http://localhost:11434/v1",
|
|
"api_key": "env:LOCAL_API_KEY",
|
|
"model": "llama3",
|
|
"system_prompt": "You are a helpful assistant."
|
|
}
|
|
},
|
|
"selected": {"ai1": "local", "ai2": "local"}
|
|
}
|
|
```
|
|
|
|
Set `LOCAL_API_KEY` in the process environment when using `env:LOCAL_API_KEY`. The app resolves it when selecting the connection. You can select the current `.env` connection for either speaker. `.env` values are reread on launch and are never copied into `sloppy.json`. With complete `.env` connections and no `sloppy.json`, the conversation starts directly; otherwise a picker opens. Changes to speaker selection during a conversation apply on the next run.
|
|
|
|
## Controls and exports
|
|
|
|
| Key | Action |
|
|
| --- | --- |
|
|
| Ctrl+M | Connections and speaker selection |
|
|
| Ctrl+P | Command palette |
|
|
| F1 | Reading controls |
|
|
| S or F2 | Sharing menu |
|
|
| Mouse wheel, Up / Down, Page Up / Page Down | Scroll |
|
|
| Home / End | Oldest / latest message |
|
|
| Ctrl+C | Quit |
|
|
|
|
Scrolling up pauses automatic following; **End** resumes it. The UI shows elapsed time, reply count, word counts, and token usage when the provider reports it. Token and speed figures may be estimates when usage is unavailable.
|
|
|
|
The sharing menu saves the full conversation or visible screen as SVG in `screenshots/`, or a Markdown transcript in `transcripts/`. The transcript includes the initial prompt and replies in order. Both directories are created in the current working directory and ignored by Git.
|
|
|
|
## Troubleshooting
|
|
|
|
- **No connection in the picker:** Complete the base URL and key in `.env`, or add a saved connection with **Ctrl+M**.
|
|
- **Missing API key:** Set the environment variable named by a saved `env:NAME` reference before launch.
|
|
- **API error:** Check the API root, model ID, server availability, and credentials. A failed or incomplete stream falls back to a non-streaming request; transport and empty-response failures receive up to two retries.
|
|
- **Invalid settings:** Fix malformed `sloppy.json` in the current working directory. `models` and `selected` must be objects; connection fields and selections must be strings. The error identifies the invalid field.
|
|
|
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for code structure and tests.
|