mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
tools/chat: rename tools to ask_user_line, ask_user_choice, ask_user_form
Model-facing names via @tool(name=…); Python symbols unchanged.
This commit is contained in:
@@ -4,9 +4,9 @@ from plyngent.agent import tool
|
||||
from plyngent.prompting import NonInteractiveError, ask_async
|
||||
|
||||
|
||||
@tool
|
||||
@tool(name="ask_user_line")
|
||||
async def ask_user(question: str, default: str = "") -> str:
|
||||
"""Ask the human a free-form question and return their answer.
|
||||
"""Ask the human a free-form one-line question and return their answer.
|
||||
|
||||
Always allows arbitrary text. Use for clarifying requirements, preferences,
|
||||
or any input that is not a fixed menu. Optional ``default`` is used if the
|
||||
|
||||
@@ -46,7 +46,7 @@ def parse_options(raw: str) -> list[ChoiceOption]:
|
||||
return out
|
||||
|
||||
|
||||
@tool
|
||||
@tool(name="ask_user_choice")
|
||||
async def choose_user(
|
||||
question: str,
|
||||
options: str,
|
||||
@@ -54,7 +54,7 @@ async def choose_user(
|
||||
*,
|
||||
allow_custom: bool = True,
|
||||
) -> str:
|
||||
"""Ask the human to pick from options (or type a custom answer).
|
||||
"""Ask the human to pick from a list of options (or type a custom answer).
|
||||
|
||||
``options`` is a JSON array of strings, or objects with
|
||||
``label``, optional ``description``, optional ``value``.
|
||||
|
||||
@@ -54,13 +54,13 @@ def parse_fields(raw: str) -> list[FormField]:
|
||||
return out
|
||||
|
||||
|
||||
@tool
|
||||
@tool(name="ask_user_form")
|
||||
async def form_user(title: str, fields: str, *, confirm_submit: bool = True) -> str:
|
||||
"""Run a multi-step form with the human; returns JSON object of answers.
|
||||
|
||||
``fields`` is a JSON array of objects:
|
||||
``name``, ``prompt``, optional ``default``, optional ``options`` (same shape
|
||||
as choose_user), optional ``allow_custom`` (default true).
|
||||
as ask_user_choice), optional ``allow_custom`` (default true).
|
||||
When ``confirm_submit`` is true, the human reviews a summary before submit.
|
||||
"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user