promptgun 1.4.0 → 1.4.1

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.
Files changed (2) hide show
  1. package/README.md +9 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -17,7 +17,7 @@ For example:
17
17
  const restaurants = ai
18
18
  .chat("Recommend 3 restaurants in Paris perfect for today's weather")
19
19
  .tool('get-weather', s => s.string(), async loc => {
20
- const res = await fetch(`https://api.weather.com/v1/current?location=${loc}`)
20
+ const res = await fetch(`api.weather.com/v1/current?location=${loc}`)
21
21
  return res.json()
22
22
  })
23
23
  .getArray(s => s.object(o => o
@@ -27,7 +27,7 @@ const restaurants = ai
27
27
  ))
28
28
 
29
29
  for await (const restaurant of restaurants) {
30
- // do stuff with a type-safe restaurant object,
30
+ // do stuff with a type-safe, typed restaurant object,
31
31
  // streamed as soon as they come in
32
32
  }
33
33
  ```
@@ -72,7 +72,7 @@ for await (const parsedPartialJson of parsedPartialJsonStream) {
72
72
  ### Data output - single
73
73
  Simply put `await` in front of your prompt to make it a single output rather than a streamed one:
74
74
  ```typescript
75
- const restaurants /* type: {name: string, address?: string}[] */ = await ai
75
+ const restaurants = await ai
76
76
  .chat('Give 5 top restaurants in London')
77
77
  .getArray(o => o
78
78
  .object(o => o
@@ -80,6 +80,7 @@ const restaurants /* type: {name: string, address?: string}[] */ = await ai
80
80
  .canHaveString('description', 'A 50 character description')
81
81
  )
82
82
  )
83
+ // do stuff with array of type: {name: string, address?: string}[]
83
84
  ```
84
85
 
85
86
  ### Text output – streamed
@@ -91,11 +92,13 @@ for await (const chunk of stream) {
91
92
  }
92
93
  ```
93
94
  ### Text output – single
95
+ Again, just add `await`:
94
96
  ```typescript
95
97
  const fruit = await ai.chat('What company makes the iPhone?')
96
98
  ```
97
99
 
98
- ### Image out
100
+ ## Image generation
101
+ Promptgun has a simple, type-safe image generation API:
99
102
  ```typescript
100
103
  await ai
101
104
  .image('A black hole')
@@ -215,7 +218,7 @@ Tools can be added directly using `.tool()`:
215
218
  const result = await ai
216
219
  .chat("What's the weather in Paris?")
217
220
  .tool('get-weather', s => s.string(), async location => {
218
- const res = await fetch(`https://api.weather.com/v1/current?location=${location}`)
221
+ const res = await fetch(`api.weather.com/v1/current?location=${location}`)
219
222
  return res.json()
220
223
  })
221
224
  ```
@@ -224,7 +227,7 @@ const result = await ai
224
227
  For tools used across multiple prompts, define them once with `aiTool()`:
225
228
  ```typescript
226
229
  const getWeather = aiTool('get-weather', s => s.string(), async location => {
227
- const res = await fetch(`https://api.weather.com/v1/current?location=${location}`)
230
+ const res = await fetch(`api.weather.com/v1/current?location=${location}`)
228
231
  return res.json()
229
232
  })
230
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptgun",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "exports": "./build/index.js",
6
6
  "types": "./build/index.d.ts",