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
Copy file name to clipboardExpand all lines: README.md
+21-6Lines changed: 21 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,27 @@ class Output(BaseLLMResponse):
95
95
96
96
```
97
97
98
+
### Example 4
99
+
100
+
You can nest response types. Note that you need to use `BaseLLMArrayElement` for classes that you want to nest inside a list. To add instructions inside an element of `BaseLLMArrayElement`, you must use `LLMArrayElementOutput` instead of `LLMOutput`.
101
+
102
+
```python
103
+
classOutput(BaseLLMResponse):
104
+
105
+
classItem(BaseLLMArrayElement):
106
+
107
+
classDescription(BaseLLMResponse):
108
+
short: str|None
109
+
long: str
110
+
111
+
title: str
112
+
description: Description
113
+
price: float= LLMArrayElementOutput(instruction=lambdapos: f"The price of the {pos.ordinal} item")
114
+
115
+
items: list[Item]
116
+
count: int
117
+
```
118
+
98
119
99
120
100
121
@@ -222,9 +243,3 @@ MOUSE 2: <Put the second mouse here>
222
243
```
223
244
Notice how the plural "mice" is automatically converted to the singular "mouse" to avoid confusing the language model.
224
245
225
-
226
-
227
-
228
-
## Coming Soon
229
-
230
-
- Support for output classes within output classes, especially arrays
0 commit comments