fast-tavern(Python 版)
Repo: Lianues/fast-tavern
这是主项目 fast-tavern 的 Python 移植版,目标是对齐 TypeScript 实现的行为(提示词组装与多阶段调试输出)。
安装(开发期)
在本目录下执行:
pip install -e .[dev]
pytest
打包/发布
在本目录下执行:
pip install build twine
python -m build
twine upload dist/*
快速开始(与 TS 用法对齐)
from fast_tavern import build_prompt, History
result = build_prompt(
preset=preset,
character=character,
globals={"worldBooks": world_books, "regexScripts": regex_scripts},
history=History.openai(
[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hi!"},
]
),
view="model",
macros={"user": "Bob"},
variables={"score": 1},
output_format="openai",
system_role_policy="keep",
)
print(result["stages"]["tagged"]["afterPostRegex"])
### 旧酒馆格式直接调用(包装入口)
```python
from fast_tavern import build_prompt_from_silly_tavern
result = build_prompt_from_silly_tavern(
preset=legacy_preset_settings, # 旧 ST preset/settings
character=legacy_character, # 可选,旧 ST character
globals={
"worldBooks": legacy_worldbooks,
"regexScripts": legacy_regexes,
},
history=legacy_chat,
view="model",
outputFormat="openai",
)
也可单独调用转换函数:
convert_preset_from_silly_tavern/convert_worldbook_from_silly_tavernconvert_regex_from_silly_tavern/convert_character_from_silly_tavern/convert_history_from_silly_tavern
print(result["stages"]["output"]["afterPostRegex"])
### Regex flags 说明(与 TS 的差异点)
- `findRegex` 支持 `"/pattern/flags"` 与 `"pattern"` 两种写法。
- flags 映射:`i/m/s` -> Python `re` 对应 flags;`g` 用于决定“替换一次/全部”;`u` 默认等价;`y` 不支持(若遇到会按普通正则处理)。
### 发布后安装
```bash
pip install fast-tavern
Metadata
Release files for fast-tavern 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fast_tavern-0.1.8.tar.gz | 30.8 kB | Without provenance | Details for fast_tavern-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fast_tavern-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for fast_tavern-0.1.8-py3-none-any.whl |
Total release size: 69.5 kB
Release files / fast_tavern-0.1.8.tar.gz
| Download URL | fast_tavern-0.1.8.tar.gz |
|---|---|
| Size | 30.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3ddd82f38da3436666471b08c2d83f8ef8a462a0187e2500d95f18c1de1ea70
|
|
BLAKE2b-256 checksum How to use checksums |
10eeba7e9b89775bec2fb5fb7e3986189e403cbd59a386d253d486896a01b6bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / fast_tavern-0.1.8-py3-none-any.whl
| Download URL | fast_tavern-0.1.8-py3-none-any.whl |
|---|---|
| Size | 38.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2558b0fe8fb5655a805889153218cbfaebd371a8354de73aacb5fdc791d3195d
|
|
BLAKE2b-256 checksum How to use checksums |
d54c2b8b5255a800a696330a1de7feb4f57acc0151d1f8f265b44880b848f70e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for fast-tavern 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.