Skip to content

Commit 645b159

Browse files
committed
Update docs
Signed-off-by: Louis Mandel <[email protected]>
1 parent 1bec789 commit 645b159

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

docs/tutorial.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ tool_schema:
569569
type: object
570570
properties:
571571
answer:
572-
type: str
572+
type: string
573573
description: The answer
574574
required:
575575
- answer
@@ -586,7 +586,7 @@ finish_action:
586586
type: object
587587
properties:
588588
answer:
589-
type: str
589+
type: string
590590
description: The answer
591591
required:
592592
- answer
@@ -916,12 +916,9 @@ some JSON data.
916916
--8<-- "./examples/tutorial/type_checking.pdl"
917917
```
918918

919-
Upon reading the data we use a parser to parse it into a YAML. The `spec` field indicates the expected type for the
920-
data, which is an object with 2 fields: `questions` and `answers` that are a list of string and a list of objects,
921-
respectively. When the interpreter is executed, it checks this type dynamically and throws errors if necessary.
919+
Upon reading the data we use a parser to parse it into a YAML. The `spec` field indicates the expected type for the data, which is an object with 2 fields: `questions` and `answers` that are an array of string and an array of objects, respectively. When the interpreter is executed, it checks this type dynamically and throws errors if necessary.
922920

923-
Similarly, the output of the model call is parsed as YAML, and the `spec` indicates that we expect an object with
924-
2 fields: `name` of type string, and `age` of type integer.
921+
Similarly, the output of the model call is parsed as YAML, and the `spec` indicates that we expect an object with two fields: `name` of type string, and `age` of type integer.
925922

926923
When we run this program, we obtain the output:
927924

@@ -933,26 +930,27 @@ type_checking.pdl:9 - twentyfive should be of type <class 'int'>
933930

934931
Notice that since we asked the age to be produced in letters, we got a string back and this causes a type error indicated above.
935932

936-
In general, `spec` definitions can be a subset of JSON schema, or use a shorthand notation as illustrated by
937-
the examples below:
938-
939-
- `bool`: boolean
940-
- `str`: string
941-
- `int`: integer
942-
- `float`: float
943-
- `{str: {pattern: '^[A-Za-z][A-Za-z0-9_]*$'}}`: a string satisfying the indicated pattern
944-
- `{float: {minimum: 0, exclusiveMaximum: 1}}`: a float satisfying the indicated constraints
945-
- `{list: int}`: a list of integers
946-
- `[int]`: a list of integers
947-
- `{list: {int: {minimum: 0}}}`: a list of integers satisfying the indicated constraints
948-
- `[{int: {minimum: 0}}]`: same as above
949-
- `{list: {minItems: 1, int: {}}}`, a list satisfying the indicated constraints
950-
- `{obj: {latitude: float, longitude: float}}`: an object with fields `latitude` and `longitude`
951-
- `{latitude: float, longitude: float}`: same as above
952-
- `{obj: {question: str, answer: str, context: {optional: str}}}`: an object with an optional field
953-
- `{question: str, answer: str, context: {optional: str}}`: same as above
954-
- `{list: {obj: {question: str, answer: str}}}`: a list of objects
955-
- `[{question: str, answer: str}]`: same as above
933+
In general, `spec` definitions can be a subset of JSON schema, or use a shorthand notation as illustrated by the examples below:
934+
935+
- `boolean` or `{type: boolean}`: boolean
936+
- `string` or `{type: string}`: string
937+
- `integer` or `{type: integer}`: integer
938+
- `number` or `{type: number}`: floating point numbers
939+
- `"null"` or `{type: "null"}`: type of the `null` value
940+
- `array` or `{type: array}`: array with elements of any type
941+
- `object` or `{type: object}`: object with any fields
942+
- `{type: string, pattern: '^[A-Za-z][A-Za-z0-9_]*$'}`: a string satisfying the indicated pattern
943+
- `{type: number, minimum: 0, exclusiveMaximum: 1}`: a float satisfying the indicated constraints
944+
- `[integer]`: an array of integers
945+
- `{type: array, items: { type: integer }}`: same as above
946+
- `[{ type: integer, minimum: 0}]`: a list of integers satisfying the indicated constraints
947+
- `{type: array, items: { type: integer, minimum: 0}}`: same as above
948+
- `{type: array, minItems: 1}`, a list with at least one element
949+
- `{latitude: number, longitude: number}`: an object with fields `latitude` and `longitude`
950+
- `{object: {latitude: number, longitude: number}}`: same as above
951+
- `{question: string, answer: string, context: {optional: string}}`: an object with an optional field `context`
952+
- `{object: {question: string, answer: string, context: {optional: string}}}`: same as above
953+
- `[{question: string, answer: string}]`: a list of objects
956954
- `{enum: [red, green, blue]}`: an enumeration
957955

958956
Another example of type checking a list can be found [here](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/type_list.pdl).

0 commit comments

Comments
 (0)