Metadata-Version: 2.5
Name: otaku
Version: 0.11.0
Summary: LLM frontend for roleplay and creative writing
Project-URL: Homepage, https://otaku.sh
Project-URL: Repository, https://github.com/enclavum/otaku
Project-URL: Issues, https://github.com/enclavum/otaku/issues
Author-email: enclavum <support@otaku.sh>
License-Expression: AGPL-3.0-only
License-File: LICENSE
Keywords: ai-roleplay,cli,creative-writing,interactive-fiction,koboldcpp,llamacpp,llm,lmstudio,local-llm,lore,mlx,nanogpt,ollama,omlx,openrouter,roleplay,sillytavern,sillytavern-alternative,story,storytelling,terminal,tui,web-ui
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Games/Entertainment :: Role-Playing
Requires-Python: >=3.11
Requires-Dist: click<9.0,>=8.4
Requires-Dist: cryptography<49,>=48; sys_platform == 'darwin' and platform_machine == 'x86_64'
Requires-Dist: cryptography<51,>=49; sys_platform != 'darwin' or platform_machine == 'arm64'
Requires-Dist: httpx<1.0,>=0.28
Requires-Dist: pillow-heif<2.0,>=1.7
Requires-Dist: pillow<13.0,>=12.3
Requires-Dist: prompt-toolkit<4.0,>=3.0.53
Requires-Dist: pyte<0.9,>=0.8.2
Requires-Dist: sounddevice<0.6,>=0.5.6
Description-Content-Type: text/markdown

# otaku — AI roleplay app

[![CI](https://github.com/enclavum/otaku/actions/workflows/ci.yml/badge.svg)](https://github.com/enclavum/otaku/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/otaku.svg)](https://pypi.org/project/otaku/)
[![Changelog](https://img.shields.io/badge/changelog-latest-blue)](https://github.com/enclavum/otaku/blob/main/CHANGELOG.md)
[![License: AGPL-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](https://github.com/enclavum/otaku/blob/main/LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)](https://github.com/enclavum/otaku/blob/main/pyproject.toml)
[![Platforms](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey)](https://github.com/enclavum/otaku#requirements)

Otaku is a free open source LLM frontend for roleplay. It runs on your machine and connects to
your local LLM backends and cloud providers. Otaku offers two interfaces — web (optimized for
mobile) and terminal, provides a streamlined UI and requires minimal configuration.

## Interactive demos

Fully functional demos are available on the [website](https://otaku.sh/) (all but the agents'
background work):

- [Web and mobile](https://otaku.sh/demo-web/)
- [Terminal](https://otaku.sh/demo-terminal/)

Both demos include two sample stories and a scripted "model", so you can see how the UI works and
actually send prompts.

## Screenshots

### Web interface

Main page:

![Web: story with state](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-light.png?v=0.11.0)

<details>
<summary>More screenshots</summary>

Expanded story state (updated by the supervisor agent and injected in the context tail):

![Web: story state](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-state-light.png?v=0.11.0)

Model selection:

![Web: model picker](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-models-light.png?v=0.11.0)

Story list:

![Web: stories](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-stories-light.png?v=0.11.0)

Story premise (goes to the system message):

![Web: premise](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-dossier-premise-light.png?v=0.11.0)

Story messages:

![Web: messages](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-dossier-messages-light.png?v=0.11.0)

Story scenes (summaries and long-term memory):

![Web: scenes](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-dossier-scenes-light.png?v=0.11.0)

Story cast (some characters are linked to cards in the character gallery):

![Web: cast](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-dossier-cast-light.png?v=0.11.0)

Tools and injections:

![Web: tools](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-dossier-tools-light.png?v=0.11.0)

Supervisor agent configuration:

![Web: supervisor settings](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-dossier-agents-supervisor-light.png?v=0.11.0)

Character gallery:

![Web: character gallery](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-cards-light.png?v=0.11.0)

Context explorer:

![Web: context explorer](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-web-context-light.png?v=0.11.0)

</details>

### Terminal interface

Main view:

![Terminal: story](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-terminal-light.png?v=0.11.0)

<details>
<summary>More screenshots</summary>

Model selection:

![Terminal: model picker](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-terminal-models-light.png?v=0.11.0)

Story messages:

![Terminal: messages](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-terminal-dossier-messages-light.png?v=0.11.0)

Story scenes (summaries and long-term memory):

![Terminal: scenes](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-terminal-dossier-scenes-light.png?v=0.11.0)

Story cast:

![Terminal: cast](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-terminal-dossier-cast-light.png?v=0.11.0)

Agents, tools and injections:

![Terminal: agents and tools](https://raw.githubusercontent.com/enclavum/otaku/main/images/capture-terminal-dossier-tools-light.png?v=0.11.0)

</details>

## Features overview

### Onboarding

Otaku installs in one command with no dependencies and autodiscovers your local LLM
backends and models, so you can start playing immediately.

### Roleplay features

**Terminal interface** — in addition to the web interface, you can also play in your terminal
window as if it were a coding agent session. Stories and all functions are shared with the web
interface. See the [terminal user guide](https://github.com/enclavum/otaku/blob/main/docs/terminal_guide.md).

**Memory system** — otaku has *short-term* and *long-term* memories. Short-term memory is updated
after each turn and tracks the current story state (configurable); long-term memory splits the
story into scenes and generates two-level summaries — per scene and from the beginning of the
story to the scene. Characters also get their long-term memories in the story: summaries are
generated from each character's perspective too.

**[Context management](https://github.com/enclavum/otaku/blob/main/docs/context_design.md)** — the first few and the last messages are sent as
they are, and as the context grows, the middle messages are replaced by summaries. Character cards
and pinned messages are always sent as is. You can see the final context to be sent to the LLM in
the "Context" menu section, showing how many tokens will be spent on each context section (system,
injections, summaries, etc.). You can also set a custom limit on the overall context size.

**Character cards** are optional — you can chat and play without them, or import cards in the
middle of a story, directly into it or into the library, from online resources and SillyTavern.
Characters you have introduced in your story without a card are extracted and added to the list
of story characters automatically, and can be linked to a character card later.

**No fixed personas** — you can switch characters during play just by saying who you are playing
for now.

**Story mode** — when switched to, you can write the story directly on the page and let the LLM
continue, as in NovelAI.

**Standard roleplay features** (short list): sending pictures (always kept in context);
dictation; author's notes (story and global reminders injected in the story tail); tool calls
(questions, web search, etc.); branching stories from any message; regenerating and undoing
messages; splitting a story into chapters; and more.

### Agentic support

Agents run in the background; you can disable any agent in the story settings.

<table>
  <tr>
    <th style="width: 10%">Agent</th>
    <th style="width: 15%">When triggered</th>
    <th style="width: 20%">What it does</th>
    <th style="width: 25%">Configuration</th>
    <th style="width: 30%">Where to see results</th>
  </tr>
  <tr>
    <td>Supervisor</td>
    <td>After each turn</td>
    <td>Creates <strong>short-term memory</strong> by keeping track of the current story state — place, time, characters leaving, joining, etc.</td>
    <td>1. Set what you want to be tracked in the story settings, e.g. world weather, character health, mood, etc.<br>2. (Optional) Choose a model different from the one you use for writing.</td>
    <td>1. The state is injected at the end of the story so that the LLM doesn't mess up story facts.<br>2. See the state at the top of the transcript and in the expandable state panel.</td>
  </tr>
  <tr>
    <td>Extractor</td>
    <td>After you've been idle for 5 minutes</td>
    <td>Creates <strong>long-term memory</strong> — story summaries — and also extracts characters that have been introduced without a card</td>
    <td>(Optional) Choose a model different from the one you use for writing.</td>
    <td>Browse the extracted summaries and characters in the story dossier; summaries are editable</td>
  </tr>
  <tr>
    <td>Warm-up <em>(only local backends)</em></td>
    <td>Your next turn won't use the LLM cache, and therefore will be slow (*)</td>
    <td>Sends the currently available context to the LLM, so that it's cached</td>
    <td>None; always sends the context to the writing model</td>
    <td>Your next turn will be answered fast</td>
  </tr>
</table>

(*) Warm-up trigger examples: a new summary kicks in, or you've edited one of the messages at the
beginning of the story, e.g. the system message.

Agents are designed not to disturb your roleplay:

- the supervisor agent is put back into its queue immediately after you've sent a prompt, and will
  be retried after you get the response;
- the warm-up agent is canceled immediately after you've sent a prompt, as there's nothing to warm
  up anymore;
- the extractor agent is the heaviest, so it's scheduled after 5 minutes of idle time, which
  usually means you are away and the run won't disturb your play. If you send a prompt, the run
  stops at its next step and resumes once you've been idle for another 5 minutes.

## Installation

### Requirements

- Platform: Windows / macOS / Linux.
- Python 3.11+.

### How to install

The recommended way is the installation script, which first installs the `uv` package manager — if
you don't have it yet — and then installs otaku with it. To run otaku without installing it,
from a git checkout, see [launch without installation](#launch-without-installation).

```bash
# macOS and Linux
curl -LsSf https://otaku.sh/install.sh | sh

# Windows
irm https://otaku.sh/install.ps1 | iex
```

<details>
<summary>How to install via uv or brew (expand)</summary>

```bash
# directly with uv
uv tool install otaku

# with Homebrew
brew trust enclavum/tap
brew install enclavum/tap/otaku
```

</details>

How to update or uninstall:

```bash
otaku update
otaku uninstall  # also purges data on request
```

### How to launch

In the terminal, type one of the commands:

```bash
otaku  # opens the terminal UI;
otaku serve  # serves the web interface at http://localhost:9600;
otaku serve --any-host  # serves the web interface at http://localhost:9600, available over the network.
```

<a id="launch-without-installation"></a>
<details>
<summary>You can run the app without installing it, from the checked-out repo (expand)</summary>

```bash
git clone https://github.com/enclavum/otaku.git
cd otaku

# macOS and Linux
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/otaku          # or: .venv/bin/otaku serve

# Windows
py -m venv .venv
.venv\Scripts\pip install -e .
.venv\Scripts\otaku      # or: .venv\Scripts\otaku serve
```

</details>

### Running in Docker

When run from Docker, the terminal interface is not fully functional — you need to install otaku
to use the terminal interface as it's intended.

```bash
# without checking out
docker compose -f https://github.com/enclavum/otaku.git up -d

# from the checked-out repo
git clone https://github.com/enclavum/otaku.git
cd otaku
docker compose up -d

# then open http://localhost:9600
```

## Configuration

### Database and config files

Everything lives in otaku's home folder — `~/.otaku` when installed, or `data/` when run from a
checkout. You can set an alternative `OTAKU_HOME` to run a separate environment, e.g.:
`OTAKU_HOME=~/.otaku-alt otaku`.

### Web interface

By default, the web interface is available on the local machine only. You can make it available
over the network by setting the `host` parameter to `0.0.0.0` in the `[web]` section of
`~/.otaku/configs/config.toml`, or run `otaku serve --any-host`.

_If you go public, you should also consider turning on the next two parameters, `https` and
`password`, for privacy._

The web interface can serve over HTTPS. Turn on `https` in the config file and otaku generates a
self-signed certificate, which you can also replace with your own if you need to. Browsers will
show warnings about an untrusted certificate — that is unavoidable with a self-signed certificate,
but the encryption is real.

When the web interface is available over the network, protect it with a password — set it in the
same config file.

To restyle the web interface, create `~/.otaku/web/custom.css`; it overrides styles in the bundled
design. The custom properties it can set are listed in
[docs/web_tokens.md](https://github.com/enclavum/otaku/blob/main/docs/web_tokens.md).

## Storage and privacy

Stories live in a local SQLite database; the database is backed up daily into a subfolder, keeping
the last seven snapshots. Logs (see `otaku logs -h`) are also rotated and kept for seven days.

Pictures attached to a turn and cards' pictures are kept beside the database, downsized and
stripped of their metadata; they are not part of the daily snapshot.

Encryption at rest is disabled by default but can be switched on in the config file, with several
options: the key can live in your OS keychain, come from a command of your choice (a password
manager, a hardware token), derive from a passphrase, or sit on disk. The request log and the
pictures are sealed with the same cipher.

Provider API keys are always stored sealed, their key in the OS keychain.

Details in [SECURITY.md](https://github.com/enclavum/otaku/blob/main/SECURITY.md).

## Contributing

See [CONTRIBUTING.md](https://github.com/enclavum/otaku/blob/main/CONTRIBUTING.md).

## License

[AGPL-3.0-only](https://github.com/enclavum/otaku/blob/main/LICENSE).
