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: docs/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,8 +53,8 @@ In order to run these examples, you need to create a free account
53
53
on Replicate, get an API key and store it in the environment variable:
54
54
-`REPLICATE_API_TOKEN`
55
55
56
-
In order to use foundation models hosted on [Watsonx](https://www.ibm.com/watsonx) via LiteLLM, you need a WatsonX account (a free plan is available) and set up the following environment variables:
57
-
-`WATSONX_URL`, the API url (set to `https://{region}.ml.cloud.ibm.com`) of your WatsonX instance. The region can be found by clicking in the upper right corner of the Watsonx dashboard (for example a valid region is `us-south` ot `eu-gb`).
56
+
In order to use foundation models hosted on [watsonx](https://www.ibm.com/watsonx) via LiteLLM, you need a WatsonX account (a free plan is available) and set up the following environment variables:
57
+
-`WATSONX_URL`, the API url (set to `https://{region}.ml.cloud.ibm.com`) of your WatsonX instance. The region can be found by clicking in the upper right corner of the watsonx dashboard (for example a valid region is `us-south` ot `eu-gb`).
58
58
-`WATSONX_APIKEY`, the API key (see information on [key creation](https://cloud.ibm.com/docs/account?topic=account-userapikey&interface=ui#create_user_key))
59
59
-`WATSONX_PROJECT_ID`, the project hosting the resources (see information about [project creation](https://www.ibm.com/docs/en/watsonx/saas?topic=projects-creating-project) and [finding project ID](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-project-id.html?context=wx)).
60
60
@@ -133,7 +133,7 @@ text:
133
133
temperature: 0
134
134
```
135
135
136
-
The `description` field is a description for the program. Field `text` contains a list of either strings or *block*s which together form the text to be produced. In this example, the text starts with the string `"Hello\n"` followed by a block that calls out to a model. In this case, it is model with id `replicate/ibm-granite/granite-20b-code-instruct-8k` on Replicate, via LiteLLM, with the indicated parameters: the stop sequence is `!`, and temperature set to `0`. Stop sequences are provided with a comman separated list of strings. The input to the model call is everything that has been produced so far in the program (here `"Hello\n"`).
136
+
The `description` field is a description for the program. Field `text` contains a list of either strings or *block*s which together form the text to be produced. In this example, the text starts with the string `"Hello\n"` followed by a block that calls out to a model. In this case, it is model with id `replicate/ibm-granite/granite-20b-code-instruct-8k` on Replicate, via LiteLLM, with the indicated parameters: the stop sequence is `!`, and temperature set to `0`. Stop sequences are provided with a comma separated list of strings. The input to the model call is everything that has been produced so far in the program (here `"Hello\n"`).
137
137
138
138
When we execute this program using the PDL interpreter:
Copy file name to clipboardExpand all lines: docs/tutorial.md
+7-17Lines changed: 7 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,7 @@ In PDL, we can declaratively chain models together as in the following example (
119
119
--8<-- "./examples/tutorial/model_chaining.pdl"
120
120
```
121
121
122
-
In this program, the first call is to a granite model to complete the sentence `Hello, world!`. The following block in the document prints out the sentence: `Translate this to French`. The final line of the program takes the entire document produced so far and passes it as input to the granite multilingual model. Notice that the input passed to this model is the document up to that point, represented as a conversation. This makes it easy to chain models together and continue building on previous interactions.
122
+
In this program, the first call is to a Granite model to complete the sentence `Hello, world!`. The following block in the document prints out the sentence: `Translate this to French`. The final line of the program takes the entire document produced so far and passes it as input to the Granite multilingual model. Notice that the input passed to this model is the document up to that point, represented as a conversation. This makes it easy to chain models together and continue building on previous interactions.
123
123
124
124
When we execute this program, we obtain:
125
125
@@ -151,7 +151,7 @@ The translation of 'I love Paris!' to French is 'J'aime Paris!'.
151
151
The translation of 'I love Madrid!' to Spanish is 'Me encanta Madrid!'.
152
152
```
153
153
154
-
A function only contributes to the output document when it is called. So the definition itself results in `""`. When we call a function, we implicitly pass the current background context, and this is used as input to model calls inside the function body. In the above example, since the `input` field is omitted, the entire document produced at that point is passed as input to the granite model.
154
+
A function only contributes to the output document when it is called. So the definition itself results in `""`. When we call a function, we implicitly pass the current background context, and this is used as input to model calls inside the function body. In the above example, since the `input` field is omitted, the entire document produced at that point is passed as input to the Granite model.
155
155
156
156
To reset the context when calling a function, we can pass the special argument: `pdl_context: []`.
157
157
@@ -223,12 +223,12 @@ An `object` constructs an object:
223
223
```
224
224
object:
225
225
name: Bob
226
-
job: mananger
226
+
job: manager
227
227
```
228
228
229
229
This results in the following output:
230
230
```
231
-
{"name": "Bob", "job": "mananger"}
231
+
{"name": "Bob", "job": "manager"}
232
232
```
233
233
234
234
Each value in the object can be any PDL block, and the result is presented as an object.
@@ -328,7 +328,7 @@ PDL programs can contain calls to REST APIs with Python code. Consider a simple
328
328
--8<-- "./examples/tutorial/calling_apis.pdl"
329
329
```
330
330
331
-
In this program, we first define a query about the weather in some location (assigned to variable `QUERY`). The next block is a call to a granite model with few-shot examples to extract the location, which we assign to variable `LOCATION`. The next block makes an API call with Python (mocked in this example). Here the `LOCATION` is appended to the `url`. The result is a JSON object, which may be hard to interpret for a human user. So we make a final call to an LLM to interpret the JSON in terms of weather. Notice that many blocks have `contribute` set to `[]` to hide intermediate results.
331
+
In this program, we first define a query about the weather in some location (assigned to variable `QUERY`). The next block is a call to a Granite model with few-shot examples to extract the location, which we assign to variable `LOCATION`. The next block makes an API call with Python (mocked in this example). Here the `LOCATION` is appended to the `url`. The result is a JSON object, which may be hard to interpret for a human user. So we make a final call to an LLM to interpret the JSON in terms of weather. Notice that many blocks have `contribute` set to `[]` to hide intermediate results.
332
332
333
333
334
334
## Data Block
@@ -538,7 +538,7 @@ role: user
538
538
```
539
539
540
540
In PDL, any block can be adorned with a `role` field indicating the role for that block. These are high-level annotations
541
-
that help to make programs more portable accross different models. If the role of a block is not specified (except for model blocks that have `assistant` role),
541
+
that help to make programs more portable across different models. If the role of a block is not specified (except for model blocks that have `assistant` role),
542
542
then the role is inherited from the surrounding block. So in the above example, we only need to specify `role: user` at the top level (this is the default, so it doesn't
543
543
need to be specified explicitly).
544
544
@@ -607,7 +607,7 @@ the examples below:
607
607
- `{list: {int: {minimum: 0}}}`: a list of integers satisfying the indicated constraints
608
608
- `[{int: {minimum: 0}}]`: same as above
609
609
- `{list: {minItems: 1, int: {}}}`, a list satisfying the indicated constraints
610
-
- `{obj: {latitude: float, longitude: float}}`: an ibject with fields `latitude` and `longitude`
610
+
- `{obj: {latitude: float, longitude: float}}`: an object with fields `latitude` and `longitude`
611
611
- `{latitude: float, longitude: float}`: same as above
612
612
- `{obj: {question: str, answer: str, context: {optional: str}}}`: an object with an optional field
613
613
- `{question: str, answer: str, context: {optional: str}}`: same as above
@@ -931,13 +931,3 @@ Output:
931
931
Several lines of text, with some "quotes" of various 'types'. Escapes (like \n) don't do anything.
932
932
Newlines can be added by leaving a blank line. Additional leading whitespace is ignored.
0 commit comments