promptgun 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,37 +18,23 @@ for await (const chunk of stream) {
|
|
|
18
18
|
|
|
19
19
|
### Data output - single
|
|
20
20
|
```typescript
|
|
21
|
-
const count /* type: number */ = await ai
|
|
22
|
-
.chat('How many countries are in the EU')
|
|
23
|
-
.getNumber()
|
|
24
|
-
```
|
|
25
|
-
Promptgun will both tell the LLM what shape its output data should be, parse that data to JS types
|
|
26
|
-
and correctly Typescript-type the output!
|
|
27
|
-
|
|
28
|
-
You can do this for types of any complexity:
|
|
29
|
-
```typescript
|
|
30
21
|
const restaurants /* type: {name: string, address?: string}[] */ = await ai
|
|
31
22
|
.chat('Give 5 top restaurants in London')
|
|
32
23
|
.getArray(o => o
|
|
33
24
|
.object(o => o
|
|
34
25
|
.hasString('name')
|
|
35
|
-
.canHaveString('
|
|
26
|
+
.canHaveString('description', 'A 50 character description')
|
|
36
27
|
)
|
|
37
28
|
)
|
|
38
29
|
```
|
|
30
|
+
Promptgun will
|
|
31
|
+
* tell the LLM what shape its output data should be,
|
|
32
|
+
* parse that data to JS types,
|
|
33
|
+
* correctly Typescript-type the output and
|
|
34
|
+
* pass your optional hints!
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const restaurants /* type: {name: string, address: string}[] */ = await ai
|
|
43
|
-
.chat('Give the top restaurant in London')
|
|
44
|
-
.getObject(o => o
|
|
45
|
-
.hasString('name')
|
|
46
|
-
.hasString('description', 'A 50 character description')
|
|
47
|
-
)
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Data output - stream data-aware
|
|
51
|
-
You can put callbacks on elements of the result data, which get called as they come in:
|
|
36
|
+
### Data output - stream
|
|
37
|
+
Stream data-aware. Put callbacks on elements of the result data, which get called as they come in:
|
|
52
38
|
```typescript
|
|
53
39
|
await ai
|
|
54
40
|
.chat('Give 5 top restaurants in London')
|