taolib.symphony.prompt#

提示词子包。

提供用户模板渲染(Jinja2 strict)和内部模板构建(PEP 750 t-string)。

Submodules#

Exceptions#

PromptError

模板渲染失败。

Functions#

build_continuation_prompt(→ str)

构建续运轮次提示词。

build_default_prompt(→ str)

构建默认提示词(无用户模板时的回退)。

render_prompt(→ str)

渲染用户模板(Jinja2 strict 模式)。

Package Contents#

exception taolib.symphony.prompt.PromptError#

Bases: SymphonyError

模板渲染失败。

taolib.symphony.prompt.build_continuation_prompt(identifier: str, title: str, turn: int, max_turns: int) str#

构建续运轮次提示词。

当 Codex 智能体需要继续上一轮未完成的工作时, 使用此模板生成引导性提示词。

参数:
  • identifier -- Issue 标识符。

  • title -- Issue 标题。

  • turn -- 当前轮次号。

  • max_turns -- 最大轮次数。

返回:

续运提示词字符串。

taolib.symphony.prompt.build_default_prompt(identifier: str, title: str) str#

构建默认提示词(无用户模板时的回退)。

当用户未提供 WORKFLOW.md 模板时, 使用此模板生成基本的提示词。

参数:
  • identifier -- Issue 标识符。

  • title -- Issue 标题。

返回:

默认提示词字符串。

taolib.symphony.prompt.render_prompt(template_str: str, issue: Any, attempt: int | None = None) str#

渲染用户模板(Jinja2 strict 模式)。

将 Issue 数据注入模板,严格模式确保引用未定义变量时 抛出异常而非静默渲染为空字符串。

参数:
  • template_str -- Jinja2 模板字符串。

  • issue -- Issue 对象(需支持 model_dump() 方法)。

  • attempt -- 当前尝试序号。

返回:

渲染后的提示词字符串。

抛出:

PromptError -- 模板语法错误或渲染错误。