ask-my-llm 1.0.1 → 1.0.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 (2) hide show
  1. package/index.js +8 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -21,15 +21,20 @@ function ask(prompt) {
21
21
  temperature: 0.7
22
22
  });
23
23
 
24
- const url = new URL('/v1/chat/completions', config.baseApi);
25
- const isHttps = url.protocol === 'https:';
24
+ let baseUrl = config.baseApi.replace(/\/$/, '');
25
+ if (!baseUrl.endsWith('/v1')) {
26
+ baseUrl += '/v1';
27
+ }
28
+ const url = baseUrl + '/chat/completions';
26
29
 
27
30
  const args = [
28
31
  '-s', '-X', 'POST',
29
32
  '-H', 'Content-Type: application/json',
30
33
  '-H', config.apiKey ? `Authorization: Bearer ${config.apiKey}` : '',
34
+ '-H', 'HTTP-Referer: https://www.npmjs.com/package/ask-my-llm',
35
+ '-H', 'X-OpenRouter-Title: ask-my-llm',
31
36
  '-d', postData,
32
- `${url.protocol}//${url.host}${url.pathname}`
37
+ url
33
38
  ];
34
39
 
35
40
  const result = spawnSync('curl', args, { encoding: 'utf8' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ask-my-llm",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Oversimplified AI usage npm module",
5
5
  "main": "index.js",
6
6
  "bin": {