Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/how_to_guides/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ You can combine `RAIL` elements to create an arbitrarily complex output structur
<rail version="0.1">
<output>
<object name="some_object">
<string name="some_str_key" description="What should the value for this key represent?" format="two-words; upper-case" />
<integer name="some_other_key" description="What should this integer represent?" format="min-val: 0"/>
<string name="some_str_key" description="What should the value for this key represent?" validators="guardrails/uppercase; guardrails/two_words" />
<integer name="some_other_key" description="What should this integer represent?" validators="guardrails/valid_range:0" />
</object>
</output>
</rail>
Expand Down Expand Up @@ -139,7 +139,7 @@ In the above example, `"SOME STRING"` is the value for the `some_str_key` key, a
<rail version="0.1">
<output>
<list name="some_list" format="min-len: 2">
<string format="two-words; upper-case" />
<string validators="guardrails/uppercase; guardrails/two_words" />
</list>
</output>
</rail>
Expand Down Expand Up @@ -237,7 +237,7 @@ Each element can have attributes that specify additional information about the d

2. `description` attribute that specifies the description of the field. This is similar to a prompt that will be provided to the LLM. It can contain more context to help the LLM generate the correct output.
3. (Coming soon!) `required` attribute that specifies whether the field is required or not. If the field is required, the LLM will be asked to generate the field until it is generated correctly. If the field is not required, the LLM will not be asked to generate the field if it is not generated correctly.
4. `format` attribute that specifies the quality criteria that the field should respect. The `format` attribute can contain multiple quality criteria separated by a colon (`;`). For example, `two-words; upper-case`.
4. `validators` attribute that specifies the quality criteria that the field should respect. The `format` attribute can contain multiple quality criteria separated by a colon (`;`). For example, `guardrails/uppercase; guardrails/two_words`.
5. `on-fail-{quality-criteria}` attribute that specifies the corrective action to take in case the quality criteria is not met. For example, `on-fail-two-words="reask"` specifies that if the field does not have two words, the LLM should be asked to re-generate the field.


Expand All @@ -251,9 +251,9 @@ E.g.,
name="some_key"
description="Detailed description of what the value of the key should be"
required="true"
format="two-words; upper-case"
on-fail-two-words="reask"
on-fail-upper-case="noop"
validators="guardrails/uppercase; guardrails/two_words"
on-fail-guardrails_two_words="reask"
on-fail-guardrails_uppercase="noop"
/>
</output>
</rail>
Expand All @@ -277,8 +277,8 @@ The `format` attribute allows specifying the quality criteria for each field in
<string
name="text"
description="The generated text"
format="two-words; upper-case"
on-fail-two-words="reask"
validators="guardrails/uppercase; guardrails/two_words"
on-fail-guardrails_two_words="reask"
/>
</output>
</rail>
Expand Down Expand Up @@ -339,7 +339,7 @@ An example of the compiled `output` element:
<string
name="text"
description="The generated text"
format="two-words; upper-case"
validators="guardrails/uppercase; guardrails/two_words"
/>
</output>
</rail>
Expand Down
21 changes: 11 additions & 10 deletions docs/how_to_guides/rail.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ You can combine `RAIL` elements to create an arbitrarily complex output structur
<rail version="0.1">
<output>
<object name="some_object">
<string name="some_str_key" description="What should the value for this key represent?" format="two-words; upper-case" />
<string name="some_str_key" description="What should the value for this key represent?" validators="guardrails/uppercase; guardrails/two_words" />
<integer name="some_other_key" description="What should this integer represent?" format="min-val: 0"/>
</object>
</output>
Expand Down Expand Up @@ -362,15 +362,15 @@ In the above example, `"SOME STRING"` is the value for the `some_str_key` key, a
- Currently, a list element can only contain a single child element. This means that a list can only contain a single type of data. For example, a list can only contain strings, or a list can only contain integers, but a list cannot contain both strings and integers.
- This child element can be any RAIL element, including another `list` or `object` elements.
- The child of a list element doesn't need to have a `name` attribute, since items in a list don't have names.
- Formatters can be applied to the child element of a list element. For example, if the child element is a `string` element, the `format` attribute can be used to specify the quality criteria for the strings in the list.
- Formatters can be applied to the child element of a list element. For example, if the child element is a `string` element, the `validators` attribute can be used to specify the quality criteria for the strings in the list.

=== "RAIL Spec"

```xml
<rail version="0.1">
<output>
<list name="some_list" format="min-len: 2">
<string format="two-words; upper-case" />
<string validators="guardrails/uppercase; guardrails/two_words" />
</list>
</output>
</rail>
Expand Down Expand Up @@ -466,7 +466,7 @@ Each element can have attributes that specify additional information about the d

2. `description` attribute that specifies the description of the field. This is similar to a prompt that will be provided to the LLM. It can contain more context to help the LLM generate the correct output.
3. (Coming soon!) `required` attribute that specifies whether the field is required or not. If the field is required, the LLM will be asked to generate the field until it is generated correctly. If the field is not required, the LLM will not be asked to generate the field if it is not generated correctly.
4. `format` attribute that specifies the quality criteria that the field should respect. The `format` attribute can contain multiple quality criteria separated by a colon (`;`). For example, `two-words; upper-case`.
4. `validators` attribute that specifies the quality criteria that the field should respect. The `validators` attribute can contain multiple quality criteria separated by a colon (`;`). For example, `guardrails/uppercase; guardrails/two_words`.
5. `on-fail-{quality-criteria}` attribute that specifies the corrective action to take in case the quality criteria is not met. For example, `on-fail-two-words="reask"` specifies that if the field does not have two words, the LLM should be asked to re-generate the field.


Expand All @@ -480,9 +480,9 @@ E.g.,
name="some_key"
description="Detailed description of what the value of the key should be"
required="true"
format="two-words; upper-case"
on-fail-two-words="reask"
on-fail-upper-case="noop"
validators="guardrails/uppercase; guardrails/two_words"
on-fail-guardrails_two_words="reask"
on-fail-guardrails_uppercase="noop"
/>
</output>
</rail>
Expand All @@ -506,8 +506,9 @@ The `format` attribute allows specifying the quality criteria for each field in
<string
name="text"
description="The generated text"
format="two-words; upper-case"
on-fail-two-words="reask"
validators="guardrails/uppercase; guardrails/two_words"
on-fail-guardrails_two_words="reask"
on-fail-guardrails_uppercase="noop"
/>
</output>
</rail>
Expand Down Expand Up @@ -568,7 +569,7 @@ An example of the compiled `output` element:
<string
name="text"
description="The generated text"
format="two-words; upper-case"
validators="guardrails/uppercase; guardrails/two_words"
/>
</output>
</rail>
Expand Down