heyi 3.1.0 → 3.1.2
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 +2 -2
- package/package.json +11 -11
- package/src/index.js +8 -6
package/README.md
CHANGED
|
@@ -59,8 +59,8 @@ heyi prompt "Analyze: revenue 100k, costs 60k" --format object --schema "z.objec
|
|
|
59
59
|
heyi prompt "Analyze top 3 tech companies" --format array --schema "z.object({name:z.string(),founded:z.number(),products:z.array(z.string())})"
|
|
60
60
|
|
|
61
61
|
# Variable replacement in prompts
|
|
62
|
-
heyi prompt "
|
|
63
|
-
heyi prompt "
|
|
62
|
+
heyi prompt "Translate to {{language}}" --var language="German"
|
|
63
|
+
heyi prompt "Translate {{input}} to {{output}}" --var input="German" --var output="English"
|
|
64
64
|
|
|
65
65
|
# Interactive variable prompting (prompts for undefined variables)
|
|
66
66
|
heyi prompt "Translate {{text}} to {{language}}"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heyi",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "CLI tool to execute AI prompts with flexible output formatting",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"test": "npm run lint"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@openrouter/ai-sdk-provider": "^
|
|
34
|
-
"ai": "^
|
|
33
|
+
"@openrouter/ai-sdk-provider": "^2.9.0",
|
|
34
|
+
"ai": "^6.0.176",
|
|
35
35
|
"commander": "^14.0.3",
|
|
36
|
-
"dotenv": "^
|
|
37
|
-
"puppeteer": "^24.
|
|
38
|
-
"sanitize-html": "^2.17.
|
|
39
|
-
"zod": "^4.3
|
|
36
|
+
"dotenv": "^17.4.2",
|
|
37
|
+
"puppeteer": "^24.43.0",
|
|
38
|
+
"sanitize-html": "^2.17.3",
|
|
39
|
+
"zod": "^4.4.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@electerious/eslint-config": "^5.
|
|
43
|
-
"@electerious/prettier-config": "^4.0.
|
|
44
|
-
"eslint": "^9.39.
|
|
45
|
-
"prettier": "^3.8.
|
|
42
|
+
"@electerious/eslint-config": "^5.3.0",
|
|
43
|
+
"@electerious/prettier-config": "^4.0.1",
|
|
44
|
+
"eslint": "^9.39.4",
|
|
45
|
+
"prettier": "^3.8.3"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=22"
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createOpenRouter } from '@openrouter/ai-sdk-provider'
|
|
2
|
-
import {
|
|
2
|
+
import { Output, generateText } from 'ai'
|
|
3
3
|
import { config } from 'dotenv'
|
|
4
4
|
import { getFormatSchema } from './utils/schema.js'
|
|
5
5
|
|
|
6
6
|
// Load environment variables from .env file
|
|
7
|
-
config()
|
|
7
|
+
config({ quiet: true })
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Execute an AI prompt with the specified model and format.
|
|
@@ -29,20 +29,22 @@ export const executePrompt = async (prompt, options = {}) => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
const zodSchema = getFormatSchema(format, schema)
|
|
32
|
-
const {
|
|
32
|
+
const { output } = await generateText({
|
|
33
33
|
model: openrouter(model),
|
|
34
34
|
prompt,
|
|
35
|
-
|
|
35
|
+
output: Output.object({
|
|
36
|
+
schema: zodSchema,
|
|
37
|
+
}),
|
|
36
38
|
})
|
|
37
39
|
|
|
38
40
|
switch (format) {
|
|
39
41
|
case 'string':
|
|
40
42
|
case 'number': {
|
|
41
|
-
return
|
|
43
|
+
return output.result
|
|
42
44
|
}
|
|
43
45
|
case 'object':
|
|
44
46
|
case 'array': {
|
|
45
|
-
return JSON.stringify(
|
|
47
|
+
return JSON.stringify(output.result, null, 2)
|
|
46
48
|
}
|
|
47
49
|
default: {
|
|
48
50
|
throw new Error(`Can't format response for unknown format '${format}'`)
|