promptantic 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. promptantic-0.0.1/.copier-answers.yml +21 -0
  2. promptantic-0.0.1/.github/FUNDING.yml +3 -0
  3. promptantic-0.0.1/.github/copilot-instructions.md +19 -0
  4. promptantic-0.0.1/.github/dependabot.yml +9 -0
  5. promptantic-0.0.1/.github/workflows/build.yml +88 -0
  6. promptantic-0.0.1/.github/workflows/documentation.yml +57 -0
  7. promptantic-0.0.1/.gitignore +32 -0
  8. promptantic-0.0.1/.pre-commit-config.yaml +48 -0
  9. promptantic-0.0.1/LICENSE +22 -0
  10. promptantic-0.0.1/PKG-INFO +241 -0
  11. promptantic-0.0.1/README.md +192 -0
  12. promptantic-0.0.1/docs/.empty +0 -0
  13. promptantic-0.0.1/duties.py +60 -0
  14. promptantic-0.0.1/mkdocs.yml +92 -0
  15. promptantic-0.0.1/overrides/_dummy.txt +1 -0
  16. promptantic-0.0.1/pyproject.toml +243 -0
  17. promptantic-0.0.1/scripts/test.py +117 -0
  18. promptantic-0.0.1/src/promptantic/__init__.py +10 -0
  19. promptantic-0.0.1/src/promptantic/completers.py +103 -0
  20. promptantic-0.0.1/src/promptantic/exceptions.py +19 -0
  21. promptantic-0.0.1/src/promptantic/generator.py +266 -0
  22. promptantic-0.0.1/src/promptantic/handlers/__init__.py +0 -0
  23. promptantic-0.0.1/src/promptantic/handlers/base.py +27 -0
  24. promptantic-0.0.1/src/promptantic/handlers/constrained.py +144 -0
  25. promptantic-0.0.1/src/promptantic/handlers/date_time.py +148 -0
  26. promptantic-0.0.1/src/promptantic/handlers/enums.py +55 -0
  27. promptantic-0.0.1/src/promptantic/handlers/literal.py +63 -0
  28. promptantic-0.0.1/src/promptantic/handlers/models.py +40 -0
  29. promptantic-0.0.1/src/promptantic/handlers/network.py +90 -0
  30. promptantic-0.0.1/src/promptantic/handlers/primitives.py +130 -0
  31. promptantic-0.0.1/src/promptantic/handlers/sequences.py +130 -0
  32. promptantic-0.0.1/src/promptantic/handlers/special.py +151 -0
  33. promptantic-0.0.1/src/promptantic/handlers/unions.py +73 -0
  34. promptantic-0.0.1/src/promptantic/py.typed +0 -0
  35. promptantic-0.0.1/src/promptantic/type_utils.py +64 -0
  36. promptantic-0.0.1/src/promptantic/ui/__init__.py +0 -0
  37. promptantic-0.0.1/src/promptantic/ui/dialogs.py +0 -0
  38. promptantic-0.0.1/src/promptantic/ui/formatting.py +31 -0
  39. promptantic-0.0.1/src/promptantic/ui/prompts.py +0 -0
  40. promptantic-0.0.1/src/promptantic/ui/style.py +13 -0
  41. promptantic-0.0.1/src/promptantic/utils/__init__.py +0 -0
  42. promptantic-0.0.1/src/promptantic/utils/pydantic.py +0 -0
  43. promptantic-0.0.1/src/promptantic/utils/type_utils.py +0 -0
  44. promptantic-0.0.1/src/promptantic/utils/validation.py +0 -0
  45. promptantic-0.0.1/tests/__init__.py +3 -0
  46. promptantic-0.0.1/tests/conftest.py +1 -0
  47. promptantic-0.0.1/tests/test_generator.py +2 -0
@@ -0,0 +1,21 @@
1
+ # Changes here will be overwritten by Copier
2
+ _commit: v1.8.1
3
+ _src_path: .\copier-phil65\
4
+ author_email: philipptemminghoff@googlemail.com
5
+ author_fullname: Philipp Temminghoff
6
+ author_username: phil65
7
+ copyright_date: '2024'
8
+ copyright_holder: Philipp Temminghoff
9
+ copyright_holder_email: philipptemminghoff@googlemail.com
10
+ libraries_use_pydantic: true
11
+ libraries_use_qt: false
12
+ project_description: Generate pydantic models using prompts
13
+ project_name: Promptantic
14
+ python_minimum_version: '3.12'
15
+ python_package_command_line_name: promptantic
16
+ python_package_distribution_name: promptantic
17
+ python_package_import_name: promptantic
18
+ repository_name: promptantic
19
+ repository_namespace: phil65
20
+ repository_provider: github.com
21
+
@@ -0,0 +1,3 @@
1
+ github: phil65
2
+ custom:
3
+ - https://www.paypal.me/phil65
@@ -0,0 +1,19 @@
1
+ ## Code style
2
+
3
+ You can assume Python 3.12.
4
+ Use newest language features if possible
5
+ Consider using pattern matching, walrus operators and other new syntax features.
6
+ Adhere to pep8.
7
+
8
+ ## Tests
9
+
10
+ Tests are written using PyTest. Dont put tests into a class.
11
+
12
+ ## DocStrings
13
+
14
+ DocStrings are written in google-style.
15
+ Dont add the types to the "Args" section.
16
+ Only add a Return section if a value is returned and the meaning of the returned value
17
+ is not obvious.
18
+ You can use markdown admonitions with python-markdown syntax if neccessary (!!! info, !!! note, !!! warning).
19
+ You can use markdown tables and markdown lists if neccessary.
@@ -0,0 +1,9 @@
1
+ # Set update schedule for GitHub Actions
2
+
3
+ version: 2
4
+ updates:
5
+ - package-ecosystem: "github-actions"
6
+ directory: "/"
7
+ schedule:
8
+ # Check for updates to GitHub Actions every week
9
+ interval: "weekly"
@@ -0,0 +1,88 @@
1
+ name: Build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ${{ matrix.os }}
8
+ continue-on-error: ${{ matrix.python_version == '3.14' }}
9
+ strategy:
10
+ matrix:
11
+ python_version: ["3.12", "3.13", "3.14"]
12
+ os: ["ubuntu-latest", "macos-latest", "windows-latest"]
13
+ steps:
14
+ - name: Check out repository
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Set up Python ${{ matrix.python_version }}
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python_version }}
21
+ allow-prereleases: true
22
+
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v4
25
+ with:
26
+ enable-cache: true
27
+ cache-dependency-glob: pyproject.toml
28
+ cache-suffix: py${{ matrix.python_version }}
29
+
30
+ - name: Install dependencies (uv sync)
31
+ run: uv sync --all-extras --no-group docs
32
+
33
+ - name: Check for code issues (ruff check)
34
+ uses: astral-sh/ruff-action@v1
35
+
36
+ - name: Check code format (ruff format)
37
+ uses: astral-sh/ruff-action@v1
38
+ with:
39
+ args: "format --check"
40
+
41
+ - name: Static type checking (MyPy)
42
+ run: uv run --no-group docs mypy src/promptantic/
43
+
44
+ - name: Run tests
45
+ run: uv run --no-group docs pytest --cov-report=xml --cov=src/promptantic/ --cov-report=term-missing
46
+
47
+ - name: Upload test results to Codecov
48
+ uses: codecov/codecov-action@v5
49
+ with:
50
+ fail_ci_if_error: false
51
+ verbose: true
52
+
53
+ release:
54
+ runs-on: ubuntu-latest
55
+ needs: test
56
+ if: startsWith(github.ref, 'refs/tags/')
57
+ permissions:
58
+ # this permission is mandatory for trusted publishing
59
+ id-token: write
60
+ contents: write
61
+ steps:
62
+ - name: Check out repository
63
+ uses: actions/checkout@v4
64
+
65
+ - name: Set up Python
66
+ uses: actions/setup-python@v5
67
+ with:
68
+ python-version: "3.12"
69
+
70
+ - name: Install uv
71
+ uses: astral-sh/setup-uv@v4
72
+ with:
73
+ enable-cache: true
74
+ cache-dependency-glob: pyproject.toml
75
+ cache-suffix: py${{ matrix.python_version }}
76
+
77
+ - name: Build package
78
+ run: uv build
79
+
80
+ - name: Publish package distributions to PyPI
81
+ uses: pypa/gh-action-pypi-publish@release/v1
82
+
83
+ - name: Release package on GitHub
84
+ uses: ncipollo/release-action@v1
85
+ with:
86
+ body: ${{ github.event.head_commit.message }}
87
+ artifacts: dist/*.whl,dist/*.tar.gz
88
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,57 @@
1
+ name: Build documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ # Allow one concurrent deployment
15
+ concurrency:
16
+ group: "pages"
17
+ cancel-in-progress: true
18
+
19
+ # Default to bash
20
+ defaults:
21
+ run:
22
+ shell: bash
23
+
24
+ jobs:
25
+ build:
26
+ runs-on: ubuntu-latest
27
+
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ with:
31
+ fetch-depth: 0
32
+ - name: Set up Python
33
+ uses: actions/setup-python@v5
34
+ with:
35
+ python-version: "3.12"
36
+ - name: Install uv
37
+ uses: astral-sh/setup-uv@v4
38
+ - name: Install dependencies
39
+ run: |
40
+ uv sync --all-extras
41
+ - name: Build
42
+ run: uv run mknodes build
43
+ - name: Upload artifact
44
+ uses: actions/upload-pages-artifact@v3
45
+ with:
46
+ path: ./site
47
+
48
+ deploy:
49
+ environment:
50
+ name: github-pages
51
+ url: ${{ steps.deployment.outputs.page_url }}
52
+ runs-on: ubuntu-latest
53
+ needs: build
54
+ steps:
55
+ - name: Deploy to GitHub Pages
56
+ id: deployment
57
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,32 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ # Distribution / packaging
5
+ *.sublime-workspace
6
+ # Unit test / coverage reports
7
+ .coverage
8
+ coverage.xml
9
+ .cache
10
+ .hatch
11
+ .pytest_cache/
12
+ junit.xml
13
+ # Jupyter Notebook
14
+ .ipynb_checkpoints
15
+ # pyenv
16
+ .python-version
17
+ # dotenv
18
+ .env
19
+ # virtualenv
20
+ .venv
21
+ # mkdocs documentation
22
+ /site
23
+ # mypy
24
+ .mypy_cache/
25
+ # .vscode
26
+ .vscode/
27
+ # OS files
28
+ .DS_Store
29
+ # uv
30
+ uv.lock
31
+ # DiskCache cache file
32
+ ./model_cache
@@ -0,0 +1,48 @@
1
+ default_language_version:
2
+ python: python3.12
3
+ default_stages: [pre-commit]
4
+ repos:
5
+ - repo: local
6
+ hooks:
7
+ - id: pytest-check
8
+ name: pytest-check
9
+ entry: uv run pytest
10
+ language: system
11
+ # stages: [push]
12
+ types: [python]
13
+ pass_filenames: false
14
+ always_run: true
15
+
16
+ - repo: https://github.com/pre-commit/pre-commit-hooks
17
+ # https://pre-commit.com/hooks.html
18
+ rev: v5.0.0
19
+ hooks:
20
+ - id: check-added-large-files
21
+ - id: check-case-conflict
22
+ - id: check-merge-conflict
23
+ - id: check-toml
24
+ - id: check-json
25
+ - id: check-xml
26
+ - id: check-yaml
27
+ args: [--allow-multiple-documents, --unsafe]
28
+ - id: debug-statements
29
+ - id: detect-private-key
30
+
31
+ - repo: https://github.com/pre-commit/mirrors-mypy
32
+ rev: v1.13.0
33
+ hooks:
34
+ - id: mypy
35
+ additional_dependencies: [orjson, pydantic]
36
+
37
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
38
+ rev: v0.8.2
39
+ hooks:
40
+ - id: ruff
41
+ - id: ruff-format
42
+
43
+ - repo: https://github.com/commitizen-tools/commitizen
44
+ rev: v4.1.0
45
+ hooks:
46
+ - id: commitizen
47
+ stages: [commit-msg]
48
+ additional_dependencies: [typing-extensions]
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Philipp Temminghoff
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.3
2
+ Name: promptantic
3
+ Version: 0.0.1
4
+ Summary: Generate pydantic models using prompts
5
+ Project-URL: Documentation, https://phil65.github.io/promptantic/
6
+ Project-URL: Source, https://github.com/phil65/promptantic
7
+ Project-URL: Issues, https://github.com/phil65/promptantic/issues
8
+ Project-URL: Discussions, https://github.com/phil65/promptantic/discussions
9
+ Project-URL: Code coverage, https://app.codecov.io/gh/phil65/promptantic
10
+ Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
11
+ License: MIT License
12
+
13
+ Copyright (c) 2024, Philipp Temminghoff
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3 :: Only
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Programming Language :: Python :: 3.13
40
+ Classifier: Programming Language :: Python :: 3.14
41
+ Classifier: Topic :: Documentation
42
+ Classifier: Topic :: Software Development
43
+ Classifier: Topic :: Utilities
44
+ Classifier: Typing :: Typed
45
+ Requires-Python: >=3.12
46
+ Requires-Dist: prompt-toolkit>=3.0.48
47
+ Requires-Dist: pydantic
48
+ Description-Content-Type: text/markdown
49
+
50
+ # Promptantic
51
+
52
+ An interactive CLI tool for populating Pydantic models using prompt-toolkit.
53
+
54
+ [![PyPI License](https://img.shields.io/pypi/l/promptantic.svg)](https://pypi.org/project/promptantic/)
55
+ [![Package status](https://img.shields.io/pypi/status/promptantic.svg)](https://pypi.org/project/promptantic/)
56
+ [![Daily downloads](https://img.shields.io/pypi/dd/promptantic.svg)](https://pypi.org/project/promptantic/)
57
+ [![Weekly downloads](https://img.shields.io/pypi/dw/promptantic.svg)](https://pypi.org/project/promptantic/)
58
+ [![Monthly downloads](https://img.shields.io/pypi/dm/promptantic.svg)](https://pypi.org/project/promptantic/)
59
+ [![Distribution format](https://img.shields.io/pypi/format/promptantic.svg)](https://pypi.org/project/promptantic/)
60
+ [![Wheel availability](https://img.shields.io/pypi/wheel/promptantic.svg)](https://pypi.org/project/promptantic/)
61
+ [![Python version](https://img.shields.io/pypi/pyversions/promptantic.svg)](https://pypi.org/project/promptantic/)
62
+ [![Implementation](https://img.shields.io/pypi/implementation/promptantic.svg)](https://pypi.org/project/promptantic/)
63
+ [![Releases](https://img.shields.io/github/downloads/phil65/promptantic/total.svg)](https://github.com/phil65/promptantic/releases)
64
+ [![Github Contributors](https://img.shields.io/github/contributors/phil65/promptantic)](https://github.com/phil65/promptantic/graphs/contributors)
65
+ [![Github Discussions](https://img.shields.io/github/discussions/phil65/promptantic)](https://github.com/phil65/promptantic/discussions)
66
+ [![Github Forks](https://img.shields.io/github/forks/phil65/promptantic)](https://github.com/phil65/promptantic/forks)
67
+ [![Github Issues](https://img.shields.io/github/issues/phil65/promptantic)](https://github.com/phil65/promptantic/issues)
68
+ [![Github Issues](https://img.shields.io/github/issues-pr/phil65/promptantic)](https://github.com/phil65/promptantic/pulls)
69
+ [![Github Watchers](https://img.shields.io/github/watchers/phil65/promptantic)](https://github.com/phil65/promptantic/watchers)
70
+ [![Github Stars](https://img.shields.io/github/stars/phil65/promptantic)](https://github.com/phil65/promptantic/stars)
71
+ [![Github Repository size](https://img.shields.io/github/repo-size/phil65/promptantic)](https://github.com/phil65/promptantic)
72
+ [![Github last commit](https://img.shields.io/github/last-commit/phil65/promptantic)](https://github.com/phil65/promptantic/commits)
73
+ [![Github release date](https://img.shields.io/github/release-date/phil65/promptantic)](https://github.com/phil65/promptantic/releases)
74
+ [![Github language count](https://img.shields.io/github/languages/count/phil65/promptantic)](https://github.com/phil65/promptantic)
75
+ [![Github commits this week](https://img.shields.io/github/commit-activity/w/phil65/promptantic)](https://github.com/phil65/promptantic)
76
+ [![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/promptantic)](https://github.com/phil65/promptantic)
77
+ [![Github commits this year](https://img.shields.io/github/commit-activity/y/phil65/promptantic)](https://github.com/phil65/promptantic)
78
+ [![Package status](https://codecov.io/gh/phil65/promptantic/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/promptantic/)
79
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
80
+ [![PyUp](https://pyup.io/repos/github/phil65/promptantic/shield.svg)](https://pyup.io/repos/github/phil65/promptantic/)
81
+
82
+ [Read the documentation!](https://phil65.github.io/promptantic/)
83
+
84
+
85
+ ## Features
86
+
87
+ - Interactive prompts for populating Pydantic models
88
+ - Rich formatting and syntax highlighting
89
+ - Type-aware input with validation
90
+ - Autocompletion for paths, timezones, and custom values
91
+ - Support for all common Python and Pydantic types
92
+ - Nested model support
93
+ - Union type handling via selection dialogs
94
+ - Sequence input (lists, sets, tuples)
95
+ - Customizable styling
96
+
97
+ ## Installation
98
+
99
+ ```bash
100
+ pip install promptantic
101
+ ```
102
+
103
+ ## Quick Start
104
+
105
+ ```python
106
+ from pydantic import BaseModel, Field
107
+ from promptantic import ModelGenerator
108
+
109
+ class Person(BaseModel):
110
+ name: str = Field(description="Person's full name")
111
+ age: int = Field(description="Age in years", gt=0)
112
+ email: str = Field(description="Email address", pattern=r"[^@]+@[^@]+\.[^@]+")
113
+
114
+ # Create and use the generator
115
+ generator = ModelGenerator()
116
+ person = await generator.populate(Person)
117
+ print(person)
118
+ ```
119
+
120
+ ## Supported Types
121
+
122
+ ### Basic Types
123
+ - `str`, `int`, `float`, `bool`, `decimal.Decimal`
124
+ - Constrained types (e.g., `constr`, `conint`)
125
+ - `Enum` classes
126
+ - `Literal` types
127
+
128
+ ### Complex Types
129
+ - `list`, `set`, `tuple` (with nested type support)
130
+ - `Union` types (with interactive type selection)
131
+ - Nested Pydantic models
132
+
133
+ ### Special Types
134
+ - `Path` (with path autocompletion)
135
+ - `UUID`
136
+ - `SecretStr` (masked input)
137
+ - `datetime`, `date`, `time`, `timedelta`
138
+ - `ZoneInfo` (with timezone autocompletion)
139
+ - `IPv4Address`, `IPv6Address`, `IPv4Network`, `IPv6Network`
140
+ - Email addresses (with validation)
141
+ - URLs (with validation)
142
+
143
+ ## Advanced Usage
144
+
145
+ ### Custom Completions
146
+
147
+ ```python
148
+ from pydantic import BaseModel, Field
149
+ from pathlib import Path
150
+
151
+ class Config(BaseModel):
152
+ environment: str = Field(
153
+ description="Select environment",
154
+ completions=["development", "staging", "production"]
155
+ )
156
+ config_path: Path = Field(description="Path to config file") # Has path completion
157
+ ```
158
+
159
+ ### Nested Models
160
+
161
+ ```python
162
+ class Address(BaseModel):
163
+ street: str = Field(description="Street name")
164
+ city: str = Field(description="City name")
165
+ country: str = Field(description="Country name")
166
+
167
+ class Person(BaseModel):
168
+ name: str = Field(description="Full name")
169
+ address: Address = Field(description="Person's address")
170
+
171
+ # Will prompt for all fields recursively
172
+ person = await ModelGenerator().populate(Person)
173
+ ```
174
+
175
+ ### Union Types
176
+
177
+ ```python
178
+ class Student(BaseModel):
179
+ student_id: int
180
+
181
+ class Teacher(BaseModel):
182
+ teacher_id: str
183
+ subject: str
184
+
185
+ class Person(BaseModel):
186
+ name: str
187
+ role: Student | Teacher # Will show selection dialog
188
+
189
+ # Will prompt for type selection before filling fields
190
+ person = await ModelGenerator().populate(Person)
191
+ ```
192
+
193
+ ### Styling
194
+
195
+ ```python
196
+ from prompt_toolkit.styles import Style
197
+ from promptantic import ModelGenerator
198
+
199
+ custom_style = Style.from_dict({
200
+ "field-name": "bold #00aa00", # Green bold
201
+ "field-description": "italic #888888", # Gray italic
202
+ "error": "bold #ff0000", # Red bold
203
+ })
204
+
205
+ generator = ModelGenerator(style=custom_style)
206
+ ```
207
+
208
+ ### Options
209
+
210
+ ```python
211
+ generator = ModelGenerator(
212
+ show_progress=True, # Show field progress
213
+ allow_back=True, # Allow going back to previous fields
214
+ retry_on_validation_error=True # Retry on validation errors
215
+ )
216
+ ```
217
+
218
+ ## Error Handling
219
+
220
+ ```python
221
+ from promptantic import ModelGenerator, PromptanticError
222
+
223
+ try:
224
+ result = await ModelGenerator().populate(MyModel)
225
+ except KeyboardInterrupt:
226
+ print("Operation cancelled by user")
227
+ except PromptanticError as e:
228
+ print(f"Error: {e}")
229
+ ```
230
+
231
+ ## Contributing
232
+
233
+ Contributions are welcome! Please feel free to submit a Pull Request.
234
+
235
+ ## License
236
+
237
+ This project is licensed under the MIT License - see the LICENSE file for details.
238
+
239
+ ## Credits
240
+
241
+ Built with [prompt-toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) and [Pydantic](https://github.com/pydantic/pydantic).