ai-functions 0.0.3 → 0.0.5
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 +3 -4
- package/ai.js +1 -1
- package/example.js +14 -0
- package/package.json +1 -1
- /package/{index.d.ts → test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -40,11 +40,10 @@ for await (const thing of list`fun things to do in Miami`) {
|
|
|
40
40
|
Or in a more complex example:
|
|
41
41
|
|
|
42
42
|
```javascript
|
|
43
|
+
const listBlogPosts = (count, topic) => list`${count} blog post titles about ${topic}`
|
|
44
|
+
const writeBlogPost = title => gpt`write a blog post in markdown starting with "# ${title}"`
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
const writeBlogPost => title => gpt`write a blog post in markdown starting with "# ${title}"`
|
|
46
|
-
|
|
47
|
-
const writeBlog = async (count, topic) => {
|
|
46
|
+
async function* writeBlog(count, topic) {
|
|
48
47
|
for await (const title of listBlogPosts(count, topic)) {
|
|
49
48
|
const content = await writeBlogPost(title)
|
|
50
49
|
yield { title, content }
|
package/ai.js
CHANGED
package/example.js
CHANGED
|
@@ -10,3 +10,17 @@ for await (const item of list`synonyms for "fun"`) {
|
|
|
10
10
|
for await (const item of list`fun things to do in Miami`) {
|
|
11
11
|
console.log(item)
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
const listBlogPosts = (count, topic) => list`${count} blog post titles about ${topic}`
|
|
15
|
+
const writeBlogPost = title => gpt`write a blog post in markdown starting with "# ${title}"`
|
|
16
|
+
|
|
17
|
+
async function* writeBlog(count, topic) {
|
|
18
|
+
for await (const title of listBlogPosts(count, topic)) {
|
|
19
|
+
const content = await writeBlogPost(title)
|
|
20
|
+
yield { title, content }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for await (const post of writeBlog(5, 'future of car sales')) {
|
|
25
|
+
console.log({ post })
|
|
26
|
+
}
|
package/package.json
CHANGED
|
File without changes
|