ask-my-llm 1.0.9 → 1.1.1

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/bin/ask-ai +18 -1
  2. package/index.js +9 -2
  3. package/package.json +1 -1
package/bin/ask-ai CHANGED
@@ -3,6 +3,7 @@
3
3
  const inquirer = require('inquirer');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
+ const { ask } = require('../index.js');
6
7
 
7
8
  const CONFIG_PATH = path.join(process.env.HOME || process.env.USERPROFILE, '.askairc');
8
9
 
@@ -18,6 +19,20 @@ function saveConfig(config) {
18
19
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
19
20
  }
20
21
 
22
+ async function testConfig(config) {
23
+ const { prompt } = await inquirer.prompt([{
24
+ type: 'input',
25
+ name: 'prompt',
26
+ message: 'Enter prompt:'
27
+ }]);
28
+
29
+ try {
30
+ console.log('Response:', ask(prompt));
31
+ } catch (e) {
32
+ console.log('Error:', e.message);
33
+ }
34
+ }
35
+
21
36
  async function mainMenu() {
22
37
  let config = loadConfig();
23
38
 
@@ -27,7 +42,7 @@ async function mainMenu() {
27
42
  return;
28
43
  }
29
44
 
30
- const choices = ['Add new config', 'Select config', 'Edit config', 'Remove config'];
45
+ const choices = ['Add new config', 'Select config', 'Edit config', 'Remove config', 'Test config'];
31
46
 
32
47
  const { action } = await inquirer.prompt([{
33
48
  type: 'list',
@@ -44,6 +59,8 @@ async function mainMenu() {
44
59
  await editConfig(config);
45
60
  } else if (action === 'Remove config') {
46
61
  await removeConfig(config);
62
+ } else if (action === 'Test config') {
63
+ await testConfig(config);
47
64
  }
48
65
  }
49
66
 
package/index.js CHANGED
@@ -7,8 +7,15 @@ const CONFIG_PATH = path.join(process.env.HOME || process.env.USERPROFILE, '.ask
7
7
  function loadConfig() {
8
8
  try {
9
9
  const data = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));
10
- const current = data.current || 'default';
11
- if (!data.configs || !data.configs[current]) {
10
+
11
+ // Old format: direct baseApi, apiKey, model
12
+ if (!data.configs) {
13
+ return data;
14
+ }
15
+
16
+ // New format with configs
17
+ const current = data.current || Object.keys(data.configs)[0];
18
+ if (!data.configs[current]) {
12
19
  throw new Error('No config found. Run `npx ask-my-llm` first.');
13
20
  }
14
21
  return data.configs[current];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ask-my-llm",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "Oversimplified AI usage npm module",
5
5
  "main": "index.js",
6
6
  "bin": {