ai-functions 0.1.2 → 0.1.3

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 (3) hide show
  1. package/example.js +22 -22
  2. package/package.json +1 -4
  3. package/proxy.js +3 -2
package/example.js CHANGED
@@ -7,31 +7,31 @@ for await (const item of list`synonyms for "fun"`) {
7
7
  }
8
8
 
9
9
 
10
- for await (const item of list`fun things to do in Miami`) {
11
- console.log(item)
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 contentPromise = writeBlogPost(title).then(content => {
20
- console.log({ title, content })
21
- return { title, content }
22
- })
23
- yield { title, contentPromise }
24
- }
25
- }
26
-
27
- for await (const post of writeBlog(3, 'future of car sales')) {
28
- console.log({ post })
29
- }
10
+ // for await (const item of list`fun things to do in Miami`) {
11
+ // console.log(item)
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 contentPromise = writeBlogPost(title).then(content => {
20
+ // console.log({ title, content })
21
+ // return { title, content }
22
+ // })
23
+ // yield { title, contentPromise }
24
+ // }
25
+ // }
26
+
27
+ // for await (const post of writeBlog(3, 'future of car sales')) {
28
+ // console.log({ post })
29
+ // }
30
30
 
31
31
  const product = await ai.categorizeProduct({ domain: 'OpenSaaS.org' }, {
32
32
  productType: 'App | API | Marketplace | Platform | Packaged Service | Professional Service | Website',
33
- customer: 'ideal customer profile in 3-5 words',
34
- solution: 'describe the offer in 4-10 words',
33
+ customer: 'ideal customer profile in 10-20 words',
34
+ solution: 'describe the offer in 10-20 words',
35
35
  description: 'website meta description',
36
36
  })
37
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-functions",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Library for Developing and Managing AI Functions (including OpenAI GPT4 / GPT3.5)",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,8 +22,5 @@
22
22
  "devDependencies": {
23
23
  "partial-json-parser": "^1.2.2",
24
24
  "vitest": "^0.33.0"
25
- },
26
- "dependencies": {
27
- "yaml": "^2.3.3"
28
25
  }
29
26
  }
package/proxy.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // import { OpenAI } from 'openai'
2
2
  // import camelcaseKeys from 'camelcase-keys'
3
3
  // import { dump } from 'js-yaml'
4
- import { stringify } from 'yaml'
4
+ // import { stringify } from 'yaml'
5
5
  import { schema } from './schema.js'
6
6
 
7
7
  export const AI = opts => {
@@ -35,7 +35,7 @@ export const AI = opts => {
35
35
  const prompt = {
36
36
  model,
37
37
  messages: [
38
- { role: 'user', content: `Call ${functionName} given the context:\n${stringify(args)}` }, // \nThere is no additional information, so make assumptions/guesses as necessary` },
38
+ { role: 'user', content: `Call ${functionName} given the context:\n${JSON.stringify(args).replaceAll('"','')}` }, // \nThere is no additional information, so make assumptions/guesses as necessary` },
39
39
  ],
40
40
  functions: [{
41
41
  name: functionName,
@@ -44,6 +44,7 @@ export const AI = opts => {
44
44
  }],
45
45
  ...rest,
46
46
  }
47
+ // console.log(prompt.messages)
47
48
  if (system) prompt.messages.unshift({ role: 'system', content: system })
48
49
  const completion = await openaiFetch(prompt)
49
50
  let data, error