askimo 1.4.0 → 1.5.0

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/lib/providers.mjs +16 -97
  2. package/package.json +15 -15
package/lib/providers.mjs CHANGED
@@ -12,115 +12,34 @@ const DEFAULT_MODELS = {
12
12
  gemini: 'gemini-3-pro-preview'
13
13
  }
14
14
 
15
- // Perplexity doesn't have a models list API, so we hardcode these
16
- const PERPLEXITY_MODELS = [
17
- { id: 'sonar', description: 'Lightweight, cost-effective search model' },
18
- { id: 'sonar-pro', description: 'Advanced search for complex queries' },
19
- { id: 'sonar-reasoning', description: 'Chain-of-thought problem solving' },
20
- { id: 'sonar-reasoning-pro', description: 'Advanced reasoning (DeepSeek-R1)' },
21
- { id: 'sonar-deep-research', description: 'Deep research sessions' }
22
- ]
23
-
24
- // xAI doesn't have a public models list API, so we hardcode these
25
- const XAI_MODELS = [
26
- { id: 'grok-4-1-fast-reasoning', description: 'Grok 4.1 fast with reasoning' },
27
- { id: 'grok-4-1-fast-non-reasoning', description: 'Grok 4.1 fast without reasoning' },
28
- { id: 'grok-code-fast-1', description: 'Grok optimized for code' },
29
- { id: 'grok-4-fast-reasoning', description: 'Grok 4 fast with reasoning' },
30
- { id: 'grok-4-fast-non-reasoning', description: 'Grok 4 fast without reasoning' },
31
- { id: 'grok-4-0709', description: 'Grok 4 flagship model' },
32
- { id: 'grok-3-mini', description: 'Lightweight Grok 3 model' },
33
- { id: 'grok-3', description: 'Grok 3 base model' },
34
- { id: 'grok-2-vision-1212', description: 'Grok 2 with vision capabilities' },
35
- { id: 'grok-2-image-1212', description: 'Image generation model' }
36
- ]
37
-
38
- async function fetchOpenAiModels(apiKey) {
39
- const response = await fetch('https://api.openai.com/v1/models', {
40
- // biome-ignore lint/style/useNamingConvention: headers use standard capitalization
41
- headers: { Authorization: `Bearer ${apiKey}` }
42
- })
15
+ // Provider name mapping (askimo name models.dev name)
16
+ const PROVIDER_MAP = {
17
+ gemini: 'google'
18
+ }
43
19
 
20
+ async function fetchModelsFromApi() {
21
+ const response = await fetch('https://models.dev/api.json')
44
22
  if (!response.ok) {
45
- throw new Error(`OpenAI API error: ${response.status}`)
23
+ throw new Error(`models.dev API error: ${response.status}`)
46
24
  }
47
-
48
- const data = await response.json()
49
- return data.data.map((m) => ({ id: m.id, created: m.created })).sort((a, b) => b.created - a.created)
25
+ return response.json()
50
26
  }
51
27
 
52
- async function fetchAnthropicModels(apiKey) {
53
- const response = await fetch('https://api.anthropic.com/v1/models', {
54
- headers: {
55
- 'x-api-key': apiKey,
56
- 'anthropic-version': '2023-06-01'
57
- }
58
- })
28
+ async function listModels(provider) {
29
+ const apiData = await fetchModelsFromApi()
30
+ const providerKey = PROVIDER_MAP[provider] || provider
31
+ const providerData = apiData[providerKey]
59
32
 
60
- if (!response.ok) {
61
- throw new Error(`Anthropic API error: ${response.status}`)
33
+ if (!providerData) {
34
+ throw new Error(`Unknown provider: ${provider}`)
62
35
  }
63
36
 
64
- const data = await response.json()
65
- return data.data.map((m) => ({
37
+ return Object.values(providerData.models).map((m) => ({
66
38
  id: m.id,
67
- displayName: m.display_name
39
+ description: m.name
68
40
  }))
69
41
  }
70
42
 
71
- async function fetchGeminiModels(apiKey) {
72
- const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`)
73
-
74
- if (!response.ok) {
75
- throw new Error(`Google AI API error: ${response.status}`)
76
- }
77
-
78
- const data = await response.json()
79
- return data.models
80
- .filter((m) => m.name.includes('gemini'))
81
- .map((m) => ({
82
- id: m.name.replace('models/', ''),
83
- displayName: m.displayName
84
- }))
85
- }
86
-
87
- async function listModels(provider, config) {
88
- switch (provider) {
89
- case 'perplexity':
90
- return PERPLEXITY_MODELS
91
-
92
- case 'openai': {
93
- const apiKey = config.OPENAI_API_KEY
94
- if (!apiKey) {
95
- throw new Error('OPENAI_API_KEY not found in config')
96
- }
97
- return fetchOpenAiModels(apiKey)
98
- }
99
-
100
- case 'anthropic': {
101
- const apiKey = config.ANTHROPIC_API_KEY
102
- if (!apiKey) {
103
- throw new Error('ANTHROPIC_API_KEY not found in config')
104
- }
105
- return fetchAnthropicModels(apiKey)
106
- }
107
-
108
- case 'xai':
109
- return XAI_MODELS
110
-
111
- case 'gemini': {
112
- const apiKey = config.GOOGLE_GENERATIVE_AI_API_KEY
113
- if (!apiKey) {
114
- throw new Error('GOOGLE_GENERATIVE_AI_API_KEY not found in config')
115
- }
116
- return fetchGeminiModels(apiKey)
117
- }
118
-
119
- default:
120
- throw new Error(`Unknown provider: ${provider}`)
121
- }
122
- }
123
-
124
43
  function getProvider(providerName, config) {
125
44
  switch (providerName) {
126
45
  case 'perplexity': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askimo",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A CLI tool for communicating with AI providers (Perplexity, OpenAI, Anthropic)",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Amit Tal",
@@ -20,10 +20,6 @@
20
20
  "bin": {
21
21
  "askimo": "./index.mjs"
22
22
  },
23
- "scripts": {
24
- "test": "ava",
25
- "lint": "biome check --write"
26
- },
27
23
  "ava": {
28
24
  "files": [
29
25
  "test/**/*.mjs"
@@ -32,18 +28,22 @@
32
28
  "repository": "https://github.com/amitosdev/askimo.git",
33
29
  "homepage": "https://github.com/amitosdev/askimo#readme",
34
30
  "devDependencies": {
35
- "@biomejs/biome": "^2.3.8",
31
+ "@biomejs/biome": "^2.3.14",
36
32
  "ava": "^6.4.1"
37
33
  },
38
34
  "dependencies": {
39
- "@ai-sdk/anthropic": "^3.0.2",
40
- "@ai-sdk/google": "^3.0.2",
41
- "@ai-sdk/openai": "^3.0.2",
42
- "@ai-sdk/perplexity": "^3.0.2",
43
- "@ai-sdk/xai": "^3.0.3",
44
- "@inquirer/input": "^5.0.2",
45
- "ai": "^6.0.6",
46
- "commander": "^14.0.2",
35
+ "@ai-sdk/anthropic": "^3.0.35",
36
+ "@ai-sdk/google": "^3.0.20",
37
+ "@ai-sdk/openai": "^3.0.25",
38
+ "@ai-sdk/perplexity": "^3.0.17",
39
+ "@ai-sdk/xai": "^3.0.46",
40
+ "@inquirer/input": "^5.0.4",
41
+ "ai": "^6.0.69",
42
+ "commander": "^14.0.3",
47
43
  "hcat": "^2.2.1"
44
+ },
45
+ "scripts": {
46
+ "test": "ava",
47
+ "lint": "biome check --write"
48
48
  }
49
- }
49
+ }