An extension of fabricatio, which provide the capability to question user to make better planning and etc.
Project description
fabricatio-question
Interactive questioning extension for fabricatio agents. Generates LLM-driven selection prompts and presents them to users via terminal UI, enabling agents to gather structured feedback during planning and decision-making.
Installation
pip install fabricatio[question]
# or
uv pip install fabricatio[question]
For a full installation including all fabricatio components:
pip install fabricatio[full]
API
Capability: Questioning
Extends fabricatio_core.capabilities.propose.Propose. Mix into an agent to add interactive questioning.
| Method | Description |
|---|---|
async selection(q: str, k: int = 1, **kwargs) -> str | List[str] |
Generates a selection question via LLM, presents it interactively, and returns the user's choice(s). k=1 returns a single string; k>1 returns a list of up to k selections. |
async selection_string(q: str, k: int = 1, **kwargs) -> str |
Like selection(), but returns a formatted string with the question topic, options, and selected indices. |
Model: SelectionQuestion
A SketchedAble model representing an interactive selection prompt. Generated by the LLM from a user-provided topic.
| Field | Type | Description |
|---|---|---|
q |
str |
Question text displayed to the user. |
option |
List[str] |
Available choices. |
| Method | Description |
|---|---|
async single() -> str |
Presents a single-choice selection via questionary.select. |
async multiple(k: int = 0) -> List[str] |
Presents a multi-choice checkbox. When k > 0, validates that exactly k options are selected. |
Utilities
fabricatio_question.utils
| Function | Description |
|---|---|
async ask_retain(candidates: List[str]) -> List[str] |
Presents a checkbox list with all candidates pre-checked, returning the user's retained subset. |
async ask_retain(candidates, value_mapping) -> List[V] |
Overload that maps retained choices back through value_mapping. |
async ask_edit(text_seq: List[str]) -> List[str] |
Prompts the user to edit each string sequentially; only non-empty edits are returned. |
Configuration
fabricatio_question.config.question_config — a QuestionConfig dataclass with template names used during question generation:
| Field | Default | Description |
|---|---|---|
selection_template |
"built-in/selection" |
Template for generating the SelectionQuestion prompt. |
selection_display_template |
"built-in/selection_display" |
Template for rendering selection_string output. |
Usage
from fabricatio_question.capabilities.questioning import Questioning
class MyAgent(Questioning):
...
async def example():
agent = MyAgent()
# Single choice — returns a str
choice: str = await agent.selection("Pick a database backend")
# Multiple choices — returns list[str]
picks: list[str] = await agent.selection("Select features to enable", k=3)
# Get a formatted response string
result: str = await agent.selection_string("Choose a deployment target")
from fabricatio_question.utils import ask_retain, ask_edit
# Let the user prune a candidate list
kept: list[str] = await ask_retain(["auth", "caching", "logging", "metrics"])
# Let the user edit a list of strings in-place
edited: list[str] = await ask_edit(["step 1", "step 2", "step 3"])
Dependencies
fabricatio-core— core interfaces and capabilitiesquestionary>=2.1.0— interactive terminal prompts
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 fabricatio_question-0.1.7-py3-none-any.whl.
File metadata
- Download URL: fabricatio_question-0.1.7-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
902a4657082f8d5d313b17af73ab756752ca3cf3f4d01b22417d19def83107df
|
|
| MD5 |
b62873ddb1cfb29cdaf44c456d1d1020
|
|
| BLAKE2b-256 |
f0eaf4e7da654500caa4cd20c1010580b09260b5500cfc293fb0283d3067bdf2
|