ai-functions 0.1.2 → 0.1.4
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 -1
- package/example.js +2 -2
- package/package.json +6 -3
- package/proxy.js +3 -4
package/README.md
CHANGED
|
@@ -14,12 +14,14 @@ const { ai, gpt, list } = AI({ apiKey: OPENAI_API_KEY })
|
|
|
14
14
|
Then you can use magic `ai` functions:
|
|
15
15
|
```javascript
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const categorizeProduct = ai.categorizeProduct({
|
|
18
18
|
productType: 'App | API | Marketplace | Platform | Packaged Service | Professional Service | Website',
|
|
19
19
|
customer: 'ideal customer profile in 3-5 words',
|
|
20
20
|
solution: 'describe the offer in 4-10 words',
|
|
21
21
|
description: 'website meta description',
|
|
22
22
|
})
|
|
23
|
+
|
|
24
|
+
const product = await (categorizeProduct({ domain: name }))
|
|
23
25
|
```
|
|
24
26
|
|
|
25
27
|
you can also use `list` tagged template as a convienence function:
|
package/example.js
CHANGED
|
@@ -28,11 +28,11 @@ for await (const post of writeBlog(3, 'future of car sales')) {
|
|
|
28
28
|
console.log({ post })
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const product = await ai.categorizeProduct({
|
|
31
|
+
const product = await ai.categorizeProduct({
|
|
32
32
|
productType: 'App | API | Marketplace | Platform | Packaged Service | Professional Service | Website',
|
|
33
33
|
customer: 'ideal customer profile in 3-5 words',
|
|
34
34
|
solution: 'describe the offer in 4-10 words',
|
|
35
35
|
description: 'website meta description',
|
|
36
|
-
})
|
|
36
|
+
})({ domain: 'OpenSaaS.org' })
|
|
37
37
|
|
|
38
38
|
console.log({ product })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-functions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Library for Developing and Managing AI Functions (including OpenAI GPT4 / GPT3.5)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,10 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/nathanclevenger/ai-functions#readme",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"partial-json-parser": "^1.2.2",
|
|
24
23
|
"vitest": "^0.33.0"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"
|
|
26
|
+
"camelcase-keys": "^9.1.0",
|
|
27
|
+
"js-yaml": "^4.1.0",
|
|
28
|
+
"openai": "^4.11.1",
|
|
29
|
+
"partial-json-parser": "^1.2.2",
|
|
30
|
+
"yaml": "^2.3.2"
|
|
28
31
|
}
|
|
29
32
|
}
|
package/proxy.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// import { OpenAI } from 'openai'
|
|
2
2
|
// import camelcaseKeys from 'camelcase-keys'
|
|
3
|
-
|
|
4
|
-
import { stringify } from 'yaml'
|
|
3
|
+
import { dump } from 'js-yaml'
|
|
5
4
|
import { schema } from './schema.js'
|
|
6
5
|
|
|
7
6
|
export const AI = opts => {
|
|
@@ -29,13 +28,13 @@ export const AI = opts => {
|
|
|
29
28
|
|
|
30
29
|
const ai = new Proxy({}, {
|
|
31
30
|
get: (target, functionName, receiver) => {
|
|
32
|
-
return
|
|
31
|
+
return (returnSchema, options) => async args => {
|
|
33
32
|
console.log(schema(returnSchema))
|
|
34
33
|
const { system, description, model = 'gpt-3.5-turbo', meta = false, ...rest } = options || {}
|
|
35
34
|
const prompt = {
|
|
36
35
|
model,
|
|
37
36
|
messages: [
|
|
38
|
-
{ role: 'user', content: `Call ${functionName} given the context:\n${
|
|
37
|
+
{ role: 'user', content: `Call ${functionName} given the context:\n${dump(args)}` }, // \nThere is no additional information, so make assumptions/guesses as necessary` },
|
|
39
38
|
],
|
|
40
39
|
functions: [{
|
|
41
40
|
name: functionName,
|