Metadata-Version: 2.4
Name: dragoman-server
Version: 0.2.0
Summary: Self-hosted API that translates Markdown and moderates comments with a small local model (llama.cpp), on CPU, without API keys
Author: FauZaPespi
License-Expression: MIT
Project-URL: Homepage, https://github.com/FauZaPespi/Dragoman
Project-URL: Documentation, https://github.com/FauZaPespi/Dragoman/tree/main/docs
Project-URL: Issues, https://github.com/FauZaPespi/Dragoman/issues
Project-URL: Changelog, https://github.com/FauZaPespi/Dragoman/blob/main/CHANGELOG.md
Keywords: translation,machine-translation,markdown,moderation,llama.cpp,self-hosted,local-llm,qwen,i18n,api
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="assets/banner-dark.svg">
    <img alt="Dragoman" src="assets/banner-light.svg" width="720">
  </picture>
</p>

<p align="center">
  <b>Translate Markdown and moderate comments with a small model on your own machine.</b><br>
  No API key, no per-request bill, no text leaving your server.
</p>

<p align="center">
  <a href="https://github.com/FauZaPespi/Dragoman/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/FauZaPespi/Dragoman/actions/workflows/ci.yml/badge.svg"></a>
  <a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-1f5c4d"></a>
  <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-1f5c4d">
  <img alt="Runs on CPU" src="https://img.shields.io/badge/runs%20on-CPU-1f5c4d">
</p>

<p align="center">
  <a href="docs/guide/install.md">Install</a> ·
  <a href="docs/guide/use-in-your-app.md">Use it in your app</a> ·
  <a href="docs/guide/api.md">API</a> ·
  <a href="docs/README.md">Documentation</a> ·
  <a href="ROADMAP.md">Roadmap</a>
</p>

<p align="center">
  <img alt="Dragoman translating a Markdown snippet and moderating two comments in a terminal" src="assets/demo.gif" width="800">
</p>

Dragoman is a self-hosted translation and moderation API: a small HTTP service in front of [llama.cpp](https://github.com/ggml-org/llama.cpp). Send it a blog post in French, get it back in English with every heading, link, image and code block where it was. Send it a comment, get back `ok` or `insult`. It was built to run a bilingual portfolio on a shared server with no GPU, and it works for any blog, CMS, documentation site or app that wants free, private machine translation and comment moderation instead of a paid API.

## Features

- **Markdown stays intact.** Code blocks never reach the model. Links, images, inline code and HTML attributes are checked after translation; if the model changes one, Dragoman retries, then refuses, instead of silently breaking your page.
- **Moderation that knows criticism from insults.** "This article is useless" passes, "you idiot" does not, in French and English, even with misspellings.
- **A fair queue.** One job at a time, and a comment to moderate goes ahead of a 20-minute translation.
- **Polite on shared machines.** CPU, memory and priority limits out of the box.
- **Clear errors.** Every failure has a status, a code and a hint, with `Retry-After` when waiting helps.
- **Small.** About 500 lines of standard-library Python, one 2.5 GB model file.

## Quickstart

With Docker:

```sh
git clone https://github.com/FauZaPespi/Dragoman && cd Dragoman
./scripts/download-model.sh                       # 2.5 GB, checksum verified
cp .env.example .env && sed -i "s/^API_TOKEN=.*/API_TOKEN=$(openssl rand -hex 24)/" .env
docker compose up -d
curl localhost:8090/health                        # ready once the model has loaded, about 15 s
```

Without Docker, one script builds llama.cpp, fetches the model and installs a service:

```sh
git clone https://github.com/FauZaPespi/Dragoman && sh Dragoman/scripts/install.sh --service
```

Already running `llama-server`? `pip install dragoman-server` installs only the API. All three ways are in the [install guide](docs/guide/install.md).

## Use it from your app

```js
const res = await fetch("http://127.0.0.1:8090/v1/translate", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.DRAGOMAN_TOKEN}` },
  body: JSON.stringify({ text: "## Bonjour", source: "fr", target: "en" }),
});
const { text } = await res.json(); // "## Hello"
```

Python, PHP, error handling and the background-job pattern are in [Use it in your app](docs/guide/use-in-your-app.md).

## Speed

On 6 threads of a Xeon Gold 6154, no GPU:

| Task | Time |
|---|---|
| Moderate one comment | about 1.5 s |
| Translate a 500-word article | about 3 min |
| Load the model | about 11 s |

Slow, but free and unlimited, which is what background work needs. How the default model was chosen is in the [benchmarks](docs/dev/benchmarks.md).

## Languages

French, English, German, Spanish, Italian, Portuguese, Dutch, Polish, Japanese, Chinese, Korean, Russian, Turkish, Arabic, Ukrainian, Swedish and Hindi. Quality is best between French and English, which is what the prompts and tests cover.

## Documentation

| Using Dragoman | Working on Dragoman |
|---|---|
| [Install](docs/guide/install.md) | [Architecture](docs/dev/architecture.md) |
| [Use it in your app](docs/guide/use-in-your-app.md) | [Development](docs/dev/development.md) |
| [API reference](docs/guide/api.md) | [Benchmarks](docs/dev/benchmarks.md) |
| [Configuration](docs/guide/configuration.md) | [Contributing](CONTRIBUTING.md) |
| [Put it on a server](docs/guide/deploy.md) | [Roadmap](ROADMAP.md) |
| [Troubleshooting](docs/guide/troubleshooting.md) | [Changelog](CHANGELOG.md) |

## Contributing

Bug reports, ideas and pull requests are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md), and report security issues privately as described in [SECURITY.md](SECURITY.md).

## License

[MIT](LICENSE). The default model, Qwen3 4B Instruct 2507, is released by Alibaba under Apache 2.0. The wordmark uses [Fraunces](https://github.com/undercasetype/Fraunces) (SIL Open Font License).
