Skip to content

Commit 3ba03ed

Browse files
authored
Update README.md
1 parent 3e59022 commit 3ba03ed

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

README.md

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
:::thinking
2-
Let me create a comprehensive README.md file for the PydanticPrompt project, incorporating the development instructions, examples, and other important information.
3-
4-
The updated README should include:
5-
1. Introduction and description
6-
2. Installation instructions
7-
3. Usage examples with various scenarios
8-
4. Development setup
9-
5. License information
10-
11-
I'll use the markdown content we've developed so far and organize it into a cohesive document.
12-
:::
131
# PydanticPrompt
142

153
A simple library to document [Pydantic](https://docs.pydantic.dev/) models for structured LLM outputs using standard Python docstrings.
@@ -25,7 +13,8 @@ pip install pydantic-prompt
2513
- Document Pydantic model fields using standard Python docstrings
2614
- Format field documentation for LLM prompts with a single method call
2715
- Automatic type inference and display
28-
- Optional validation rule display
16+
- Optional validation rule documentation
17+
- Warnings for undocumented fields
2918
- Seamlessly embeds documentation in your prompts
3019

3120
## Usage
@@ -35,9 +24,9 @@ pip install pydantic-prompt
3524
```python
3625
from pydantic import BaseModel, Field
3726
from typing import Optional
38-
from pydantic_prompt import llm_documented
27+
from pydantic_prompt import prompt_schema
3928

40-
@llm_documented
29+
@prompt_schema
4130
class Person(BaseModel):
4231
name: str
4332
"""The person's full name"""
@@ -73,10 +62,10 @@ Person:
7362

7463
```python
7564
from pydantic import BaseModel
76-
from pydantic_prompt import llm_documented
65+
from pydantic_prompt import prompt_schema
7766
from typing import List
7867

79-
@llm_documented
68+
@prompt_schema
8069
class Address(BaseModel):
8170
street: str
8271
"""Street name and number"""
@@ -87,7 +76,7 @@ class Address(BaseModel):
8776
postal_code: str
8877
"""Postal or ZIP code"""
8978

90-
@llm_documented
79+
@prompt_schema
9180
class Contact(BaseModel):
9281
name: str
9382
"""Full name of the contact"""
@@ -116,14 +105,42 @@ Person:
116105
- email (str, optional): Contact email address if available
117106
```
118107

108+
### Warnings for Undocumented Fields
109+
110+
By default, PydanticPrompt warns you when fields don't have docstrings:
111+
112+
```python
113+
@prompt_schema
114+
class PartiallyDocumented(BaseModel):
115+
name: str
116+
"""This field has a docstring"""
117+
118+
age: int
119+
# Missing docstring will generate a warning
120+
```
121+
122+
Output:
123+
```
124+
UserWarning: Field 'age' in PartiallyDocumented has no docstring. Add a docstring for better LLM prompts.
125+
```
126+
127+
To disable these warnings:
128+
129+
```python
130+
@prompt_schema(warn_undocumented=False)
131+
class SilentModel(BaseModel):
132+
name: str
133+
# No warning for missing docstring
134+
```
135+
119136
## Real-World Example
120137

121138
```python
122139
from pydantic import BaseModel, Field
123-
from pydantic_prompt import llm_documented
140+
from pydantic_prompt import prompt_schema
124141
from typing import List
125142

126-
@llm_documented
143+
@prompt_schema
127144
class ProductReview(BaseModel):
128145
product_name: str
129146
"""The exact name of the product being reviewed"""
@@ -254,4 +271,4 @@ ruff format .
254271

255272
## License
256273

257-
MIT
274+
MIT

0 commit comments

Comments
 (0)