A framework-agnostic prompt engine: preset + worldbook + character + regex + macros -> compiled messages.
Project description
fast-tavern(Python 版)
这是主项目 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"])
print(result["stages"]["output"]["afterPostRegex"])
Regex flags 说明(与 TS 的差异点)
findRegex支持"/pattern/flags"与"pattern"两种写法。- flags 映射:
i/m/s-> Pythonre对应 flags;g用于决定“替换一次/全部”;u默认等价;y不支持(若遇到会按普通正则处理)。
发布后安装
pip install fast-tavern
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fast_tavern-0.1.3.tar.gz
(20.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_tavern-0.1.3.tar.gz.
File metadata
- Download URL: fast_tavern-0.1.3.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c769f29990af26458cb7fb3593c720beac42f58fab6014702b21d7b0e1920cc
|
|
| MD5 |
9c7a3428a56918a01ad50772fb062d31
|
|
| BLAKE2b-256 |
f0f287a213f61758686b97d0de4abaf5d6f2b67fbe5df5b6e374f60c7b9a7707
|
File details
Details for the file fast_tavern-0.1.3-py3-none-any.whl.
File metadata
- Download URL: fast_tavern-0.1.3-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1501aac0e54c8f6fe4cff6216387ff71cbd69689de70c3166a1f853840885ed6
|
|
| MD5 |
11f5d8227dfa235223bbbb02b7bc7cbe
|
|
| BLAKE2b-256 |
8158e8a4f37cb801947b8af50de74e4112fde2ab094d7fe2a2df670f43b1be8e
|