Skip to main content

A framework-agnostic prompt engine: preset + worldbook + character + regex + macros -> compiled messages.

Project description

fast-tavern(Python 版)

Repo: Lianues/fast-tavern

这是主项目 fast-tavernPython 移植版,目标是对齐 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 -> Python re 对应 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.4.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_tavern-0.1.4-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file fast_tavern-0.1.4.tar.gz.

File metadata

  • Download URL: fast_tavern-0.1.4.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for fast_tavern-0.1.4.tar.gz
Algorithm Hash digest
SHA256 fb9505e92f6c07d3dee47188a3072d58ce5f5dc62f6c3fa92fb0a61b7f514706
MD5 6e20a625f6b813fb51142101c35d98e9
BLAKE2b-256 9a8e0c4181ecdc83e5ce95468f4d4dea96e8ffff6891a7ceb54d7382b4b7ad45

See more details on using hashes here.

File details

Details for the file fast_tavern-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: fast_tavern-0.1.4-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

Hashes for fast_tavern-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ed4345a5cbc40e40b523ff0a3d8eaae2927120097207708ba1f4bbf32af82022
MD5 301c629127aa6195280ce555d4ed4b07
BLAKE2b-256 1bca191bf33188f2ddde5625a859820ebabb62f06ba45f089bb1415a82748653

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page