promptgun 0.8.6 → 0.9.0

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 CHANGED
@@ -63,14 +63,12 @@ await ai
63
63
  )
64
64
  )
65
65
  )
66
- .onElement(restaurantStream => restaurantStream
67
- .onCompleteAs(restaurant => {
68
- // do stuff every time a restaurant has come through
69
- })
70
- )
66
+ .onElement(restaurantStream /* type safe */ => {
67
+ console.log(await restaurantStream)
68
+ })
71
69
  ```
72
- #### Streamed, "dumb"
73
- You can also simply get the partial data, "what has come in so far". The data is parsed for you, even as the underlying JSON that is received is incomplete.
70
+
71
+ And iterating (not awaiting) any streamed json element simply gives the stream of accumulated partial data, "what has come in so far" as it comes in. The data is parsed for you, even as the underlying JSON that is received is incomplete.
74
72
  ```typescript
75
73
  const parsedPartialJsonStream = ai
76
74
  .chat('What are the top 5 restaurants in New York City?')
@@ -87,6 +85,25 @@ for await (const parsedPartialJson of parsedPartialJsonStream) {
87
85
  }
88
86
  ```
89
87
 
88
+ ### Image out
89
+ ```typescript
90
+ await ai
91
+ .image('A black hole')
92
+ .imageSize('1024x1024') // optional
93
+ .model('gpt-image-1') // optional, default: gpt-image-1
94
+ .toFile('blackhole.png')
95
+ ```
96
+ This writes the file, but it also returns a reference to that file:
97
+ ```typescript
98
+ const file = await ai
99
+ .image('A black hole')
100
+ .toFile('blackhole.png')
101
+ ```
102
+ You can also avoid writing a file altogether and get the byte array directly:
103
+ ```typescript
104
+ const byteArray = await ai.image('A black hole')
105
+ ```
106
+
90
107
  ## Setup
91
108
  Before you do any prompts, do:
92
109
  ```typescript