You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom generators registered via `register_custom_generator()` always use the unweighted `ChecklistResponse` schema. To use weighted output (`WeightedChecklistResponse`), instantiate `DirectGenerator` directly with `response_schema=WeightedChecklistResponse`.
132
132
133
+
### Custom Response Schemas
134
+
135
+
You can pass any Pydantic model as `response_schema` to define your own output structure. When a custom schema is provided, format instructions are skipped and the LLM is guided entirely via structured output enforcement.
136
+
137
+
```python
138
+
from pydantic import BaseModel
139
+
from autochecklist import DirectGenerator
140
+
141
+
classActionItem(BaseModel):
142
+
item: str
143
+
sources: list[int]
144
+
145
+
classActionItemsResponse(BaseModel):
146
+
questions: list[ActionItem]
147
+
148
+
gen = DirectGenerator(
149
+
custom_prompt="Generate evaluation criteria with source references for:\n\n{input}",
150
+
response_schema=ActionItemsResponse,
151
+
model="openai/gpt-5-mini",
152
+
)
153
+
checklist = gen.generate(input="Write a literature review.")
154
+
```
155
+
156
+
The parser auto-detects the list field and question text:
157
+
158
+
-**List field**: uses `questions` if present, otherwise the first list field (e.g., `items`, `criteria`)
159
+
-**Question text**: uses `question` if present, otherwise the first `str` field (e.g., `item`, `text`)
160
+
-**Extra fields**: any fields beyond the question text, `weight`, and `category` are preserved in `ChecklistItem.metadata`
161
+
162
+
```python
163
+
checklist.items[0].question # "Is it cited?"
164
+
checklist.items[0].metadata # {"sources": [1, 3]}
165
+
```
166
+
133
167
**Scorers** also use structured JSON output (`BatchScoringResponse`, `ItemScoringResponse`, etc.) with the same provider-level enforcement and fallback. Your custom scorer prompt does not need to dictate the output format.
0 commit comments