Promptantic
An interactive CLI tool for populating Pydantic models using prompt-toolkit.
Features
- Interactive prompts for populating Pydantic models
- Rich formatting and syntax highlighting
- Type-aware input with validation
- Autocompletion for paths, timezones, and custom values
- Support for all common Python and Pydantic types
- Nested model support
- Union type handling via selection dialogs
- Sequence input (lists, sets, tuples)
- Customizable styling
Installation
pip install promptantic
Quick Start
from pydantic import BaseModel, Field
from promptantic import ModelGenerator
class Person(BaseModel):
name: str = Field(description="Person's full name")
age: int = Field(description="Age in years", gt=0)
email: str = Field(description="Email address", pattern=r"[^@]+@[^@]+\.[^@]+")
# Create and use the generator
generator = ModelGenerator()
person = await generator.apopulate(Person)
print(person)
Supported Types
Basic Types
str,int,float,bool,decimal.Decimal- Constrained types (e.g.,
constr,conint) EnumclassesLiteraltypes
Complex Types
list,set,tuple(with nested type support)Uniontypes (with interactive type selection)- Nested Pydantic models
Special Types
Path(with path autocompletion)UUIDSecretStr(masked input)datetime,date,time,timedeltaZoneInfo(with timezone autocompletion)IPv4Address,IPv6Address,IPv4Network,IPv6Network- Email addresses (with validation)
- URLs (with validation)
Advanced Usage
Custom Completions
from pydantic import BaseModel, Field
from pathlib import Path
class Config(BaseModel):
environment: str = Field(
description="Select environment",
completions=["development", "staging", "production"]
)
config_path: Path = Field(description="Path to config file") # Has path completion
Nested Models
class Address(BaseModel):
street: str = Field(description="Street name")
city: str = Field(description="City name")
country: str = Field(description="Country name")
class Person(BaseModel):
name: str = Field(description="Full name")
address: Address = Field(description="Person's address")
# Will prompt for all fields recursively
person = await ModelGenerator().apopulate(Person)
Union Types
class Student(BaseModel):
student_id: int
class Teacher(BaseModel):
teacher_id: str
subject: str
class Person(BaseModel):
name: str
role: Student | Teacher # Will show selection dialog
# Will prompt for type selection before filling fields
person = await ModelGenerator().apopulate(Person)
Styling
from prompt_toolkit.styles import Style
from promptantic import ModelGenerator
custom_style = Style.from_dict({
"field-name": "bold #00aa00", # Green bold
"field-description": "italic #888888", # Gray italic
"error": "bold #ff0000", # Red bold
})
generator = ModelGenerator(style=custom_style)
Options
generator = ModelGenerator(
show_progress=True, # Show field progress
allow_back=True, # Allow going back to previous fields
retry_on_validation_error=True # Retry on validation errors
)
Error Handling
from promptantic import ModelGenerator, PromptanticError
try:
result = await ModelGenerator().apopulate(MyModel)
except KeyboardInterrupt:
print("Operation cancelled by user")
except PromptanticError as e:
print(f"Error: {e}")
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
Built with prompt-toolkit and Pydantic.
Metadata
Release files for promptantic 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| promptantic-1.0.0.tar.gz | 24.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| promptantic-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.7 kB
Release files / promptantic-1.0.0.tar.gz
| Download URL | promptantic-1.0.0.tar.gz |
|---|---|
| Size | 24.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84422e4c83bd372c4fd3f13cbff317b8867c3807c4050d88a94496bf5813e663
|
|
BLAKE2b-256 checksum How to use checksums |
3e9d0581eadf715aa31d61bfe2b7463b65dc6f08bc3220d3b2432d688f1a7979
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2025.
Transparency logRelease files / promptantic-1.0.0-py3-none-any.whl
| Download URL | promptantic-1.0.0-py3-none-any.whl |
|---|---|
| Size | 33.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90ad4e7e860b1296427cd50a99abc1562e90ae482af104174acb99cb9dd6138b
|
|
BLAKE2b-256 checksum How to use checksums |
b2d1d4987d168b6942fee14cd49b00317658cc24f8db0fe121f4395576616290
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2025.
Transparency log