ask-my-llm 1.1.6 → 1.1.7

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 (2) hide show
  1. package/index.js +4 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -66,11 +66,11 @@ function ask(prompt, options) {
66
66
  const args = [
67
67
  '-s', '-S', '-X', 'POST',
68
68
  ...headerArgs,
69
- '-d', postData,
69
+ '-d', '@-',
70
70
  url
71
71
  ];
72
72
 
73
- const result = spawnSync('curl', args, { encoding: 'utf8' });
73
+ const result = spawnSync('curl', args, { encoding: 'utf8', input: postData });
74
74
 
75
75
  if (result.error) throw result.error;
76
76
  if (result.status !== 0) throw new Error('curl failed: ' + (result.stderr || result.stdout));
@@ -103,7 +103,7 @@ function askAsync(prompt, options) {
103
103
  if (config.apiKey) {
104
104
  headerArgs.push('-H', `Authorization: Bearer ${config.apiKey}`);
105
105
  }
106
- headerArgs.push('-d', postData, url);
106
+ headerArgs.push('-d', '@-', url);
107
107
 
108
108
  const child = spawn('curl', headerArgs, { encoding: 'utf8' });
109
109
  let data = '';
@@ -111,6 +111,7 @@ function askAsync(prompt, options) {
111
111
 
112
112
  child.stdout.on('data', chunk => data += chunk);
113
113
  child.stderr.on('data', chunk => error += chunk);
114
+ child.stdin.end(postData);
114
115
  child.on('close', code => {
115
116
  if (code !== 0) {
116
117
  reject(new Error('curl failed: ' + (error || data)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ask-my-llm",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Oversimplified, zero-dependency AI usage npm module",
5
5
  "main": "index.js",
6
6
  "bin": {