promptgun 0.10.0 → 0.10.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 +7 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ for await (const chunk of stream) {
|
|
|
18
18
|
|
|
19
19
|
### Data output - single
|
|
20
20
|
```typescript
|
|
21
|
-
const count /* type:
|
|
21
|
+
const count /* type: number */ = await ai
|
|
22
22
|
.chat('How many countries are in the EU')
|
|
23
23
|
.toNumber()
|
|
24
24
|
```
|
|
@@ -26,12 +26,12 @@ Promptgun will both tell the LLM what shape its output data should be, parse tha
|
|
|
26
26
|
|
|
27
27
|
You can do this for types of any complexity:
|
|
28
28
|
```typescript
|
|
29
|
-
const restaurants /* type: {name: string, address
|
|
29
|
+
const restaurants /* type: {name: string, address?: string}[] */ = await ai
|
|
30
30
|
.chat('Give 5 top restaurants in London')
|
|
31
31
|
.toArray(o => o
|
|
32
32
|
.object(o => o
|
|
33
33
|
.hasString('name')
|
|
34
|
-
.
|
|
34
|
+
.canHaveString('address')
|
|
35
35
|
)
|
|
36
36
|
)
|
|
37
37
|
```
|
|
@@ -51,12 +51,10 @@ You can put callbacks on elements of the result data, which get called as they c
|
|
|
51
51
|
```typescript
|
|
52
52
|
await ai
|
|
53
53
|
.chat('Give 5 top restaurants in London')
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
.hasString('address')
|
|
59
|
-
)
|
|
54
|
+
.toArray(d => d
|
|
55
|
+
.object(obj => obj
|
|
56
|
+
.hasString('name')
|
|
57
|
+
.hasString('address')
|
|
60
58
|
)
|
|
61
59
|
)
|
|
62
60
|
.onElement(restaurantStream /* type safe */ => {
|