Metadata-Version: 2.5
Name: fl-style-transfer
Version: 0.2.1
Summary: Profile-conditioned author style transfer for LLM agents
Author-email: Igor Beschastnov <i.beschastnov@focuslabs.ru>
License-Expression: MIT
License-File: LICENSE
Keywords: authorship,russian-nlp,style-transfer,stylometry,writing-agent
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Russian
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Text Processing
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.12
Requires-Dist: diversity==0.3.1
Requires-Dist: elfen==1.3.3
Requires-Dist: markdown-it-py
Requires-Dist: numpy<3
Requires-Dist: odfpy
Requires-Dist: openai
Requires-Dist: polars
Requires-Dist: pymupdf
Requires-Dist: python-docx
Requires-Dist: python-dotenv
Requires-Dist: pyyaml
Requires-Dist: scikit-learn
Requires-Dist: scipy
Requires-Dist: sentence-transformers>=4.0
Requires-Dist: stanza<2,>=1.14.0
Requires-Dist: statsmodels
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Description-Content-Type: text/markdown

# fl-style-transfer

Инструментарий переноса авторского стиля для LLM-агентов: строит профиль
автора по его текстам (стилометрия, эмбеддинги, словарь функций абзацев) и
поддерживает написание новых русских текстов в этом профиле — сборка промпта
с авторскими примерами, детерминированная проверка содержания и формата,
локальные правки.

Пакет не требует внешнего LLM API: генерация выполняется агентом, который
использует пакет (своими субагентами); пакет делает тяжёлую обработку.

## Установка

```bash
pip install fl-style-transfer
# или как инструмент без установки:
uvx fl-style-transfer --help
```

При первом запуске скачиваются модели (Stanza ru, эмбеддинги). Каталоги
кэша/данных конфигурируемы:

| Переменная | Назначение | По умолчанию |
|---|---|---|
| `FL_STYLE_DATA_DIR` | профили, индексы | `~/.local/share/fl-style-transfer` |
| `FL_STYLE_CACHE_DIR` | модели | `~/.cache/fl-style-transfer` |
| `HF_HOME`, `STANZA_RESOURCES_DIR` | низкоуровневые кэши | внутри `FL_STYLE_CACHE_DIR` |

Если CUDA не нужна, уменьшите установку, поставив CPU-сборку torch заранее:
`uv pip install torch --index https://download.pytorch.org/whl/cpu`.

## Команды

### Профиль автора

```bash
# построить профиль из корпуса текстов (txt/md/docx/odt/pdf)
fl-style-transfer profile build --input corpus/author1 --output profiles/author1 --config ru.yaml

# посмотреть профиль
fl-style-transfer profile inspect profiles/author1
```

### Сравнение текста с профилем (диагностика)

```bash
fl-style-transfer compare --profile profiles/author1 --text draft.md [--reference original.md] [--json]
```

### Skill-режим (автономный навык для агента)

```bash
# первый запуск: профиль + формат-норма + задание на разметку абзацев
fl-style-transfer skill setup --skill-dir ~/.agents/skills/ghostwriter \
    --corpus ~/.agents/skills/ghostwriter/corpus/author1 --author author1

# прогрев моделей в кэш навыка
fl-style-transfer skill warmup --skill-dir ~/.agents/skills/ghostwriter

# импорт разметки ролей абзацев, выполненной агентом (JSONL)
fl-style-transfer skill labels import --profile profiles/author1/ru-v1 --labels labels.jsonl

# сборка промпта генерации (авторские примеры + план) для субагента
fl-style-transfer skill retrieve --profile profiles/author1/ru-v1 \
    --brief-file brief.md --plan-file plan.md --out prompt.md

# детерминированная проверка кандидата: якоря, формат, шаблонные конструкции
fl-style-transfer skill check --text candidate.md --brief-file brief.md \
    --anchors anchors.json --profile profiles/author1/ru-v1
```

`retrieve` кладёт рядом с промптом `prompt.json` с рекомендованными
параметрами для вызываемого субагента (temperature 0.7, thinking off,
max_tokens 2200).

### Эксперименты (research)

```bash
fl-style-transfer experiment run --profile profiles/author1 --output exp/001 --config ru.yaml
fl-style-transfer experiment evaluate exp/001
fl-style-transfer experiment judge exp/001 --config ru.yaml
```

## Лицензия

MIT. Автор: Igor Beschastnov <i.beschastnov@focuslabs.ru>.
