@jupyterlite/ai 0.17.0 → 0.19.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.
- package/lib/chat-commands/clear.d.ts +1 -0
- package/lib/chat-commands/index.d.ts +1 -0
- package/lib/chat-commands/skills.d.ts +2 -1
- package/lib/chat-model-handler.d.ts +4 -3
- package/lib/chat-model-handler.js +2 -1
- package/lib/chat-model.d.ts +148 -8
- package/lib/chat-model.js +368 -79
- package/lib/completion/completion-provider.d.ts +3 -1
- package/lib/completion/completion-provider.js +1 -2
- package/lib/completion/index.d.ts +1 -0
- package/lib/components/clear-button.d.ts +1 -0
- package/lib/components/clear-button.js +3 -4
- package/lib/components/completion-status.d.ts +1 -0
- package/lib/components/completion-status.js +5 -4
- package/lib/components/index.d.ts +1 -0
- package/lib/components/model-select.d.ts +1 -0
- package/lib/components/model-select.js +62 -67
- package/lib/components/save-button.d.ts +3 -2
- package/lib/components/save-button.js +4 -5
- package/lib/components/stop-button.d.ts +1 -0
- package/lib/components/stop-button.js +3 -4
- package/lib/components/tool-select.d.ts +3 -1
- package/lib/components/tool-select.js +47 -60
- package/lib/components/usage-display.d.ts +4 -2
- package/lib/components/usage-display.js +50 -61
- package/lib/diff-manager.d.ts +3 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +50 -59
- package/lib/models/settings-model.d.ts +3 -1
- package/lib/models/settings-model.js +1 -0
- package/lib/rendered-message-outputarea.d.ts +1 -0
- package/lib/tokens.d.ts +48 -597
- package/lib/tokens.js +2 -31
- package/lib/widgets/ai-settings.d.ts +3 -1
- package/lib/widgets/ai-settings.js +185 -344
- package/lib/widgets/main-area-chat.d.ts +3 -3
- package/lib/widgets/main-area-chat.js +2 -4
- package/lib/widgets/provider-config-dialog.d.ts +2 -1
- package/lib/widgets/provider-config-dialog.js +102 -167
- package/package.json +111 -258
- package/schema/settings-model.json +6 -0
- package/src/chat-commands/skills.ts +2 -2
- package/src/chat-model-handler.ts +10 -6
- package/src/chat-model.ts +488 -96
- package/src/completion/completion-provider.ts +6 -6
- package/src/components/clear-button.tsx +0 -2
- package/src/components/completion-status.tsx +2 -2
- package/src/components/model-select.tsx +1 -1
- package/src/components/save-button.tsx +3 -3
- package/src/components/stop-button.tsx +0 -2
- package/src/components/tool-select.tsx +10 -9
- package/src/components/usage-display.tsx +4 -2
- package/src/diff-manager.ts +4 -3
- package/src/index.ts +103 -107
- package/src/models/settings-model.ts +7 -6
- package/src/tokens.ts +54 -744
- package/src/widgets/ai-settings.tsx +40 -11
- package/src/widgets/main-area-chat.ts +5 -8
- package/src/widgets/provider-config-dialog.tsx +8 -8
- package/LICENSE +0 -30
- package/README.md +0 -49
- package/lib/agent.d.ts +0 -277
- package/lib/agent.js +0 -1116
- package/lib/icons.d.ts +0 -3
- package/lib/icons.js +0 -8
- package/lib/providers/built-in-providers.d.ts +0 -21
- package/lib/providers/built-in-providers.js +0 -233
- package/lib/providers/generated-context-windows.d.ts +0 -8
- package/lib/providers/generated-context-windows.js +0 -96
- package/lib/providers/model-info.d.ts +0 -3
- package/lib/providers/model-info.js +0 -58
- package/lib/providers/models.d.ts +0 -37
- package/lib/providers/models.js +0 -28
- package/lib/providers/provider-registry.d.ts +0 -49
- package/lib/providers/provider-registry.js +0 -72
- package/lib/providers/provider-tools.d.ts +0 -36
- package/lib/providers/provider-tools.js +0 -93
- package/lib/skills/index.d.ts +0 -4
- package/lib/skills/index.js +0 -7
- package/lib/skills/parse-skill.d.ts +0 -25
- package/lib/skills/parse-skill.js +0 -69
- package/lib/skills/skill-loader.d.ts +0 -25
- package/lib/skills/skill-loader.js +0 -133
- package/lib/skills/skill-registry.d.ts +0 -31
- package/lib/skills/skill-registry.js +0 -100
- package/lib/skills/types.d.ts +0 -29
- package/lib/skills/types.js +0 -5
- package/lib/tools/commands.d.ts +0 -11
- package/lib/tools/commands.js +0 -154
- package/lib/tools/skills.d.ts +0 -9
- package/lib/tools/skills.js +0 -73
- package/lib/tools/tool-registry.d.ts +0 -35
- package/lib/tools/tool-registry.js +0 -55
- package/lib/tools/web.d.ts +0 -8
- package/lib/tools/web.js +0 -196
- package/src/agent.ts +0 -1441
- package/src/icons.ts +0 -11
- package/src/providers/built-in-providers.ts +0 -241
- package/src/providers/generated-context-windows.ts +0 -102
- package/src/providers/model-info.ts +0 -88
- package/src/providers/models.ts +0 -76
- package/src/providers/provider-registry.ts +0 -88
- package/src/providers/provider-tools.ts +0 -179
- package/src/skills/index.ts +0 -14
- package/src/skills/parse-skill.ts +0 -91
- package/src/skills/skill-loader.ts +0 -175
- package/src/skills/skill-registry.ts +0 -137
- package/src/skills/types.ts +0 -37
- package/src/tools/commands.ts +0 -210
- package/src/tools/skills.ts +0 -84
- package/src/tools/tool-registry.ts +0 -63
- package/src/tools/web.ts +0 -238
- package/src/types.d.ts +0 -4
- package/style/icons/jupyternaut-lite.svg +0 -7
package/src/icons.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LabIcon } from '@jupyterlab/ui-components';
|
|
2
|
-
|
|
3
|
-
import jupyternautSvg from '../style/icons/jupyternaut-lite.svg';
|
|
4
|
-
|
|
5
|
-
export const jupyternautIcon = new LabIcon({
|
|
6
|
-
name: '@jupyterlite/ai:jupyternaut',
|
|
7
|
-
svgstr: jupyternautSvg
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const AI_AVATAR_BASE64 = btoa(jupyternautIcon.svgstr);
|
|
11
|
-
export const AI_AVATAR = `data:image/svg+xml;base64,${AI_AVATAR_BASE64}`;
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
2
|
-
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
3
|
-
import { createMistral } from '@ai-sdk/mistral';
|
|
4
|
-
import { createOpenAI } from '@ai-sdk/openai';
|
|
5
|
-
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
6
|
-
|
|
7
|
-
import { BUILT_IN_PROVIDER_MODEL_INFO } from './generated-context-windows';
|
|
8
|
-
import type { IProviderInfo } from '../tokens';
|
|
9
|
-
import type { IModelOptions } from './models';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Anthropic provider
|
|
13
|
-
*/
|
|
14
|
-
export const anthropicProvider: IProviderInfo = {
|
|
15
|
-
id: 'anthropic',
|
|
16
|
-
name: 'Anthropic Claude',
|
|
17
|
-
apiKeyRequirement: 'required',
|
|
18
|
-
defaultModels: [
|
|
19
|
-
'claude-opus-4-6',
|
|
20
|
-
'claude-sonnet-4-6',
|
|
21
|
-
'claude-opus-4-5',
|
|
22
|
-
'claude-opus-4-5-20251101',
|
|
23
|
-
'claude-sonnet-4-5',
|
|
24
|
-
'claude-sonnet-4-5-20250929',
|
|
25
|
-
'claude-haiku-4-5',
|
|
26
|
-
'claude-haiku-4-5-20251001',
|
|
27
|
-
'claude-opus-4-1',
|
|
28
|
-
'claude-opus-4-1-20250805',
|
|
29
|
-
'claude-opus-4-0',
|
|
30
|
-
'claude-opus-4-20250514',
|
|
31
|
-
'claude-sonnet-4-0',
|
|
32
|
-
'claude-sonnet-4-20250514'
|
|
33
|
-
],
|
|
34
|
-
modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.anthropic,
|
|
35
|
-
supportsBaseURL: true,
|
|
36
|
-
supportsHeaders: true,
|
|
37
|
-
providerToolCapabilities: {
|
|
38
|
-
webSearch: { implementation: 'anthropic' },
|
|
39
|
-
webFetch: { implementation: 'anthropic' }
|
|
40
|
-
},
|
|
41
|
-
factory: (options: IModelOptions) => {
|
|
42
|
-
if (!options.apiKey) {
|
|
43
|
-
throw new Error('API key required for Anthropic');
|
|
44
|
-
}
|
|
45
|
-
const anthropic = createAnthropic({
|
|
46
|
-
apiKey: options.apiKey,
|
|
47
|
-
headers: {
|
|
48
|
-
'anthropic-dangerous-direct-browser-access': 'true',
|
|
49
|
-
...options.headers
|
|
50
|
-
},
|
|
51
|
-
...(options.baseURL && { baseURL: options.baseURL })
|
|
52
|
-
});
|
|
53
|
-
const modelName = options.model ?? '';
|
|
54
|
-
return anthropic(modelName);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Google Generative AI provider
|
|
60
|
-
*/
|
|
61
|
-
export const googleProvider: IProviderInfo = {
|
|
62
|
-
id: 'google',
|
|
63
|
-
name: 'Google Generative AI',
|
|
64
|
-
apiKeyRequirement: 'required',
|
|
65
|
-
defaultModels: [
|
|
66
|
-
'gemini-3.1-pro-preview',
|
|
67
|
-
'gemini-3.1-pro-preview-customtools',
|
|
68
|
-
'gemini-3.1-flash-image-preview',
|
|
69
|
-
'gemini-3.1-flash-lite-preview',
|
|
70
|
-
'gemini-3-pro-image-preview',
|
|
71
|
-
'gemini-3-flash-preview',
|
|
72
|
-
'gemini-2.5-pro',
|
|
73
|
-
'gemini-2.5-flash',
|
|
74
|
-
'gemini-2.5-flash-image',
|
|
75
|
-
'gemini-2.5-flash-lite',
|
|
76
|
-
'gemini-2.5-computer-use-preview-10-2025',
|
|
77
|
-
'deep-research-pro-preview-12-2025',
|
|
78
|
-
'gemini-pro-latest',
|
|
79
|
-
'gemini-flash-latest',
|
|
80
|
-
'gemini-flash-lite-latest'
|
|
81
|
-
],
|
|
82
|
-
modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.google,
|
|
83
|
-
supportsBaseURL: true,
|
|
84
|
-
factory: (options: IModelOptions) => {
|
|
85
|
-
if (!options.apiKey) {
|
|
86
|
-
throw new Error('API key required for Google Generative AI');
|
|
87
|
-
}
|
|
88
|
-
const google = createGoogleGenerativeAI({
|
|
89
|
-
apiKey: options.apiKey,
|
|
90
|
-
...(options.baseURL && { baseURL: options.baseURL })
|
|
91
|
-
});
|
|
92
|
-
const modelName = options.model || 'gemini-2.5-flash';
|
|
93
|
-
return google(modelName);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Mistral provider
|
|
99
|
-
*/
|
|
100
|
-
export const mistralProvider: IProviderInfo = {
|
|
101
|
-
id: 'mistral',
|
|
102
|
-
name: 'Mistral AI',
|
|
103
|
-
apiKeyRequirement: 'required',
|
|
104
|
-
defaultModels: [
|
|
105
|
-
'mistral-large-latest',
|
|
106
|
-
'mistral-medium-latest',
|
|
107
|
-
'mistral-medium-2508',
|
|
108
|
-
'mistral-small-latest',
|
|
109
|
-
'mistral-small-2506',
|
|
110
|
-
'ministral-3b-latest',
|
|
111
|
-
'ministral-8b-latest',
|
|
112
|
-
'ministral-14b-latest',
|
|
113
|
-
'magistral-small-latest',
|
|
114
|
-
'magistral-medium-latest',
|
|
115
|
-
'pixtral-large-latest',
|
|
116
|
-
'codestral-latest',
|
|
117
|
-
'devstral-latest'
|
|
118
|
-
],
|
|
119
|
-
modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.mistral,
|
|
120
|
-
supportsBaseURL: true,
|
|
121
|
-
factory: (options: IModelOptions) => {
|
|
122
|
-
if (!options.apiKey) {
|
|
123
|
-
throw new Error('API key required for Mistral');
|
|
124
|
-
}
|
|
125
|
-
const mistral = createMistral({
|
|
126
|
-
apiKey: options.apiKey,
|
|
127
|
-
...(options.baseURL && { baseURL: options.baseURL })
|
|
128
|
-
});
|
|
129
|
-
const modelName = options.model || 'mistral-large-latest';
|
|
130
|
-
return mistral(modelName);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* OpenAI provider
|
|
136
|
-
*/
|
|
137
|
-
export const openaiProvider: IProviderInfo = {
|
|
138
|
-
id: 'openai',
|
|
139
|
-
name: 'OpenAI',
|
|
140
|
-
apiKeyRequirement: 'required',
|
|
141
|
-
defaultModels: [
|
|
142
|
-
'gpt-5.4',
|
|
143
|
-
'gpt-5.4-mini',
|
|
144
|
-
'gpt-5.4-nano',
|
|
145
|
-
'gpt-5.2',
|
|
146
|
-
'gpt-5.2-2025-12-11',
|
|
147
|
-
'gpt-5.2-chat-latest',
|
|
148
|
-
'gpt-5.2-pro',
|
|
149
|
-
'gpt-5.2-pro-2025-12-11',
|
|
150
|
-
'gpt-5.2-codex',
|
|
151
|
-
'gpt-5.1',
|
|
152
|
-
'gpt-5.1-2025-11-13',
|
|
153
|
-
'gpt-5.1-chat-latest',
|
|
154
|
-
'gpt-5',
|
|
155
|
-
'gpt-5-2025-08-07',
|
|
156
|
-
'gpt-5-chat-latest',
|
|
157
|
-
'gpt-5-mini',
|
|
158
|
-
'gpt-5-mini-2025-08-07',
|
|
159
|
-
'gpt-5-nano',
|
|
160
|
-
'gpt-5-nano-2025-08-07',
|
|
161
|
-
'o4-mini',
|
|
162
|
-
'o4-mini-2025-04-16',
|
|
163
|
-
'o3-pro',
|
|
164
|
-
'o3',
|
|
165
|
-
'o3-2025-04-16',
|
|
166
|
-
'o3-mini',
|
|
167
|
-
'o3-mini-2025-01-31',
|
|
168
|
-
'o1',
|
|
169
|
-
'o1-2024-12-17',
|
|
170
|
-
'gpt-4.1',
|
|
171
|
-
'gpt-4.1-2025-04-14',
|
|
172
|
-
'gpt-4.1-mini',
|
|
173
|
-
'gpt-4.1-mini-2025-04-14',
|
|
174
|
-
'gpt-4.1-nano',
|
|
175
|
-
'gpt-4.1-nano-2025-04-14',
|
|
176
|
-
'gpt-4o',
|
|
177
|
-
'gpt-4o-2024-05-13',
|
|
178
|
-
'gpt-4o-2024-08-06',
|
|
179
|
-
'gpt-4o-2024-11-20',
|
|
180
|
-
'gpt-4o-mini',
|
|
181
|
-
'gpt-4o-mini-2024-07-18',
|
|
182
|
-
'gpt-4o-search-preview',
|
|
183
|
-
'gpt-4o-search-preview-2025-03-11',
|
|
184
|
-
'gpt-4o-mini-search-preview',
|
|
185
|
-
'gpt-4o-mini-search-preview-2025-03-11',
|
|
186
|
-
'gpt-3.5-turbo',
|
|
187
|
-
'gpt-3.5-turbo-0125'
|
|
188
|
-
],
|
|
189
|
-
modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.openai,
|
|
190
|
-
supportsBaseURL: true,
|
|
191
|
-
supportsHeaders: true,
|
|
192
|
-
providerToolCapabilities: {
|
|
193
|
-
webSearch: { implementation: 'openai' }
|
|
194
|
-
},
|
|
195
|
-
factory: (options: IModelOptions) => {
|
|
196
|
-
if (!options.apiKey) {
|
|
197
|
-
throw new Error('API key required for OpenAI');
|
|
198
|
-
}
|
|
199
|
-
const openai = createOpenAI({
|
|
200
|
-
apiKey: options.apiKey,
|
|
201
|
-
...(options.baseURL && { baseURL: options.baseURL }),
|
|
202
|
-
...(options.headers && { headers: options.headers })
|
|
203
|
-
});
|
|
204
|
-
const modelName = options.model || 'gpt-4o';
|
|
205
|
-
return openai(modelName);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Generic OpenAI-compatible provider
|
|
211
|
-
*/
|
|
212
|
-
export const genericProvider: IProviderInfo = {
|
|
213
|
-
id: 'generic',
|
|
214
|
-
name: 'Generic (OpenAI-compatible)',
|
|
215
|
-
apiKeyRequirement: 'optional',
|
|
216
|
-
defaultModels: [],
|
|
217
|
-
supportsBaseURL: true,
|
|
218
|
-
supportsHeaders: true,
|
|
219
|
-
supportsToolCalling: true,
|
|
220
|
-
description: 'Uses /chat/completions endpoint',
|
|
221
|
-
baseUrls: [
|
|
222
|
-
{
|
|
223
|
-
url: 'http://localhost:4000',
|
|
224
|
-
description: 'Default for local LiteLLM server'
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
url: 'http://localhost:11434/v1',
|
|
228
|
-
description: 'Default for local Ollama server'
|
|
229
|
-
}
|
|
230
|
-
],
|
|
231
|
-
factory: (options: IModelOptions) => {
|
|
232
|
-
const openaiCompatible = createOpenAICompatible({
|
|
233
|
-
name: options.provider,
|
|
234
|
-
apiKey: options.apiKey || 'dummy',
|
|
235
|
-
baseURL: options.baseURL ?? '',
|
|
236
|
-
...(options.headers && { headers: options.headers })
|
|
237
|
-
});
|
|
238
|
-
const modelName = options.model || 'gpt-4o';
|
|
239
|
-
return openaiCompatible(modelName);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is generated by `jlpm sync:model-context-windows`.
|
|
3
|
-
* Source: https://models.dev/api.json
|
|
4
|
-
* Backed by: https://github.com/anomalyco/models.dev
|
|
5
|
-
* Generated: 2026-04-08T16:23:34.080Z
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { IProviderModelInfo } from '../tokens';
|
|
9
|
-
|
|
10
|
-
export const BUILT_IN_PROVIDER_MODEL_INFO: Record<
|
|
11
|
-
string,
|
|
12
|
-
Record<string, IProviderModelInfo>
|
|
13
|
-
> = {
|
|
14
|
-
anthropic: {
|
|
15
|
-
'claude-opus-4-6': { contextWindow: 1000000 },
|
|
16
|
-
'claude-sonnet-4-6': { contextWindow: 1000000 },
|
|
17
|
-
'claude-opus-4-5': { contextWindow: 200000 },
|
|
18
|
-
'claude-opus-4-5-20251101': { contextWindow: 200000 },
|
|
19
|
-
'claude-sonnet-4-5': { contextWindow: 200000 },
|
|
20
|
-
'claude-sonnet-4-5-20250929': { contextWindow: 200000 },
|
|
21
|
-
'claude-haiku-4-5': { contextWindow: 200000 },
|
|
22
|
-
'claude-haiku-4-5-20251001': { contextWindow: 200000 },
|
|
23
|
-
'claude-opus-4-1': { contextWindow: 200000 },
|
|
24
|
-
'claude-opus-4-1-20250805': { contextWindow: 200000 },
|
|
25
|
-
'claude-opus-4-0': { contextWindow: 200000 },
|
|
26
|
-
'claude-opus-4-20250514': { contextWindow: 200000 },
|
|
27
|
-
'claude-sonnet-4-0': { contextWindow: 200000 },
|
|
28
|
-
'claude-sonnet-4-20250514': { contextWindow: 200000 }
|
|
29
|
-
},
|
|
30
|
-
google: {
|
|
31
|
-
'gemini-3.1-pro-preview': { contextWindow: 1048576 },
|
|
32
|
-
'gemini-3.1-pro-preview-customtools': { contextWindow: 1048576 },
|
|
33
|
-
'gemini-3.1-flash-image-preview': { contextWindow: 131072 },
|
|
34
|
-
'gemini-3.1-flash-lite-preview': { contextWindow: 1048576 },
|
|
35
|
-
'gemini-3-flash-preview': { contextWindow: 1048576 },
|
|
36
|
-
'gemini-2.5-pro': { contextWindow: 1048576 },
|
|
37
|
-
'gemini-2.5-flash': { contextWindow: 1048576 },
|
|
38
|
-
'gemini-2.5-flash-image': { contextWindow: 32768 },
|
|
39
|
-
'gemini-2.5-flash-lite': { contextWindow: 1048576 },
|
|
40
|
-
'gemini-flash-latest': { contextWindow: 1048576 },
|
|
41
|
-
'gemini-flash-lite-latest': { contextWindow: 1048576 }
|
|
42
|
-
},
|
|
43
|
-
mistral: {
|
|
44
|
-
'mistral-large-latest': { contextWindow: 262144 },
|
|
45
|
-
'mistral-medium-latest': { contextWindow: 128000 },
|
|
46
|
-
'mistral-medium-2508': { contextWindow: 262144 },
|
|
47
|
-
'mistral-small-latest': { contextWindow: 256000 },
|
|
48
|
-
'mistral-small-2506': { contextWindow: 128000 },
|
|
49
|
-
'ministral-3b-latest': { contextWindow: 128000 },
|
|
50
|
-
'ministral-8b-latest': { contextWindow: 128000 },
|
|
51
|
-
'magistral-small-latest': { contextWindow: 128000 },
|
|
52
|
-
'magistral-medium-latest': { contextWindow: 128000 },
|
|
53
|
-
'pixtral-large-latest': { contextWindow: 128000 },
|
|
54
|
-
'codestral-latest': { contextWindow: 256000 },
|
|
55
|
-
'devstral-latest': { contextWindow: 262144 },
|
|
56
|
-
'devstral-2512': { contextWindow: 262144 }
|
|
57
|
-
},
|
|
58
|
-
openai: {
|
|
59
|
-
'gpt-5.4': { contextWindow: 1050000 },
|
|
60
|
-
'gpt-5.4-mini': { contextWindow: 400000 },
|
|
61
|
-
'gpt-5.4-nano': { contextWindow: 400000 },
|
|
62
|
-
'gpt-5.2': { contextWindow: 400000 },
|
|
63
|
-
'gpt-5.2-2025-12-11': { contextWindow: 400000 },
|
|
64
|
-
'gpt-5.2-chat-latest': { contextWindow: 128000 },
|
|
65
|
-
'gpt-5.2-pro': { contextWindow: 400000 },
|
|
66
|
-
'gpt-5.2-pro-2025-12-11': { contextWindow: 400000 },
|
|
67
|
-
'gpt-5.2-codex': { contextWindow: 400000 },
|
|
68
|
-
'gpt-5.1': { contextWindow: 400000 },
|
|
69
|
-
'gpt-5.1-2025-11-13': { contextWindow: 400000 },
|
|
70
|
-
'gpt-5.1-chat-latest': { contextWindow: 128000 },
|
|
71
|
-
'gpt-5': { contextWindow: 400000 },
|
|
72
|
-
'gpt-5-2025-08-07': { contextWindow: 400000 },
|
|
73
|
-
'gpt-5-chat-latest': { contextWindow: 400000 },
|
|
74
|
-
'gpt-5-mini': { contextWindow: 400000 },
|
|
75
|
-
'gpt-5-mini-2025-08-07': { contextWindow: 400000 },
|
|
76
|
-
'gpt-5-nano': { contextWindow: 400000 },
|
|
77
|
-
'gpt-5-nano-2025-08-07': { contextWindow: 400000 },
|
|
78
|
-
'o4-mini': { contextWindow: 200000 },
|
|
79
|
-
'o4-mini-2025-04-16': { contextWindow: 200000 },
|
|
80
|
-
'o3-pro': { contextWindow: 200000 },
|
|
81
|
-
o3: { contextWindow: 200000 },
|
|
82
|
-
'o3-2025-04-16': { contextWindow: 200000 },
|
|
83
|
-
'o3-mini': { contextWindow: 200000 },
|
|
84
|
-
'o3-mini-2025-01-31': { contextWindow: 200000 },
|
|
85
|
-
o1: { contextWindow: 200000 },
|
|
86
|
-
'o1-2024-12-17': { contextWindow: 200000 },
|
|
87
|
-
'gpt-4.1': { contextWindow: 1047576 },
|
|
88
|
-
'gpt-4.1-2025-04-14': { contextWindow: 1047576 },
|
|
89
|
-
'gpt-4.1-mini': { contextWindow: 1047576 },
|
|
90
|
-
'gpt-4.1-mini-2025-04-14': { contextWindow: 1047576 },
|
|
91
|
-
'gpt-4.1-nano': { contextWindow: 1047576 },
|
|
92
|
-
'gpt-4.1-nano-2025-04-14': { contextWindow: 1047576 },
|
|
93
|
-
'gpt-4o': { contextWindow: 128000 },
|
|
94
|
-
'gpt-4o-2024-05-13': { contextWindow: 128000 },
|
|
95
|
-
'gpt-4o-2024-08-06': { contextWindow: 128000 },
|
|
96
|
-
'gpt-4o-2024-11-20': { contextWindow: 128000 },
|
|
97
|
-
'gpt-4o-mini': { contextWindow: 128000 },
|
|
98
|
-
'gpt-4o-mini-2024-07-18': { contextWindow: 128000 },
|
|
99
|
-
'gpt-3.5-turbo': { contextWindow: 16385 },
|
|
100
|
-
'gpt-3.5-turbo-0125': { contextWindow: 16385 }
|
|
101
|
-
}
|
|
102
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IProviderConfig,
|
|
3
|
-
IProviderInfo,
|
|
4
|
-
IProviderModelInfo,
|
|
5
|
-
IProviderRegistry
|
|
6
|
-
} from '../tokens';
|
|
7
|
-
|
|
8
|
-
const DATE_SUFFIX = /^(.*)-\d{4}-\d{2}-\d{2}$/;
|
|
9
|
-
const SHORT_VERSION_SUFFIX = /^(.*)-\d{4}$/;
|
|
10
|
-
|
|
11
|
-
// Treat rolling aliases and dated releases as the same model family so they
|
|
12
|
-
// can share provider metadata such as context windows.
|
|
13
|
-
function normalizeModelId(modelId: string): string {
|
|
14
|
-
if (modelId.endsWith('-latest')) {
|
|
15
|
-
return modelId.slice(0, -7);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const dateSuffixMatch = modelId.match(DATE_SUFFIX);
|
|
19
|
-
if (dateSuffixMatch) {
|
|
20
|
-
return dateSuffixMatch[1];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const shortVersionSuffixMatch = modelId.match(SHORT_VERSION_SUFFIX);
|
|
24
|
-
if (shortVersionSuffixMatch) {
|
|
25
|
-
return shortVersionSuffixMatch[1];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return modelId;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getCandidateModelIds(modelId: string): string[] {
|
|
32
|
-
const candidates = [modelId];
|
|
33
|
-
const normalizedModelId = normalizeModelId(modelId);
|
|
34
|
-
|
|
35
|
-
candidates.push(normalizedModelId);
|
|
36
|
-
|
|
37
|
-
if (normalizedModelId !== modelId) {
|
|
38
|
-
candidates.push(`${normalizedModelId}-latest`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return [...new Set(candidates)];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getProviderModelInfo(
|
|
45
|
-
providerInfo: IProviderInfo | null | undefined,
|
|
46
|
-
model: string | undefined
|
|
47
|
-
): IProviderModelInfo | undefined {
|
|
48
|
-
if (!providerInfo || !model) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const modelInfo = providerInfo.modelInfo;
|
|
53
|
-
if (!modelInfo) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
for (const candidateId of getCandidateModelIds(model)) {
|
|
58
|
-
if (modelInfo[candidateId]) {
|
|
59
|
-
return modelInfo[candidateId];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const normalizedModelId = normalizeModelId(model);
|
|
64
|
-
// As a last resort, match any known model entry that normalizes to the same
|
|
65
|
-
// base ID, even if the exact alias/version string differs.
|
|
66
|
-
return Object.entries(modelInfo).find(([candidateId]) => {
|
|
67
|
-
return normalizeModelId(candidateId) === normalizedModelId;
|
|
68
|
-
})?.[1];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function getEffectiveContextWindow(
|
|
72
|
-
providerConfig: IProviderConfig | undefined,
|
|
73
|
-
providerRegistry?: IProviderRegistry
|
|
74
|
-
): number | undefined {
|
|
75
|
-
if (!providerConfig) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (providerConfig.parameters?.contextWindow !== undefined) {
|
|
80
|
-
return providerConfig.parameters.contextWindow;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const providerInfo = providerRegistry?.getProviderInfo(
|
|
84
|
-
providerConfig.provider
|
|
85
|
-
);
|
|
86
|
-
return getProviderModelInfo(providerInfo, providerConfig.model)
|
|
87
|
-
?.contextWindow;
|
|
88
|
-
}
|
package/src/providers/models.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { LanguageModel } from 'ai';
|
|
2
|
-
import type { IProviderRegistry } from '../tokens';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for creating language models.
|
|
6
|
-
*/
|
|
7
|
-
export interface IModelOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The provider name (e.g., 'openai', 'anthropic', 'huggingface')
|
|
10
|
-
*/
|
|
11
|
-
provider: string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The specific model name. If not provided, uses provider's default model
|
|
15
|
-
*/
|
|
16
|
-
model?: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* API key for authentication with the provider
|
|
20
|
-
*/
|
|
21
|
-
apiKey?: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Additional HTTP headers to send with requests
|
|
25
|
-
*/
|
|
26
|
-
headers?: Record<string, string>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Custom base URL for the provider's API endpoint
|
|
30
|
-
*/
|
|
31
|
-
baseURL?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Create a completion model using the provider registry.
|
|
36
|
-
* Built-in providers are automatically registered during extension initialization.
|
|
37
|
-
*/
|
|
38
|
-
export function createCompletionModel(
|
|
39
|
-
options: IModelOptions,
|
|
40
|
-
registry?: IProviderRegistry
|
|
41
|
-
): LanguageModel {
|
|
42
|
-
if (!registry) {
|
|
43
|
-
throw new Error('Provider registry not available');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const model = registry.createCompletionModel(options.provider, options);
|
|
47
|
-
if (!model) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Provider ${options.provider} not found or failed to create model`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return model;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Create a chat model using the provider registry.
|
|
58
|
-
* Built-in providers are automatically registered during extension initialization.
|
|
59
|
-
*/
|
|
60
|
-
export function createModel(
|
|
61
|
-
options: IModelOptions,
|
|
62
|
-
registry?: IProviderRegistry
|
|
63
|
-
): LanguageModel {
|
|
64
|
-
if (!registry) {
|
|
65
|
-
throw new Error('Provider registry not available');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const model = registry.createChatModel(options.provider, options);
|
|
69
|
-
if (!model) {
|
|
70
|
-
throw new Error(
|
|
71
|
-
`Provider ${options.provider} not found or failed to create model`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return model;
|
|
76
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ISignal, Signal } from '@lumino/signaling';
|
|
2
|
-
import type { LanguageModel } from 'ai';
|
|
3
|
-
import type { IModelOptions } from './models';
|
|
4
|
-
import { IProviderInfo, IProviderRegistry } from '../tokens';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Implementation of the provider registry
|
|
8
|
-
*/
|
|
9
|
-
export class ProviderRegistry implements IProviderRegistry {
|
|
10
|
-
/**
|
|
11
|
-
* Get a copy of all registered providers
|
|
12
|
-
*/
|
|
13
|
-
get providers(): Record<string, IProviderInfo> {
|
|
14
|
-
return { ...this._providers };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Signal emitted when providers are added or removed
|
|
19
|
-
*/
|
|
20
|
-
get providersChanged(): ISignal<IProviderRegistry, void> {
|
|
21
|
-
return this._providersChanged;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Register a new provider
|
|
26
|
-
* @param info Provider information with factories for chat and completion
|
|
27
|
-
*/
|
|
28
|
-
registerProvider(info: IProviderInfo): void {
|
|
29
|
-
if (info.id in this._providers) {
|
|
30
|
-
throw new Error(`Provider with id "${info.id}" is already registered`);
|
|
31
|
-
}
|
|
32
|
-
this._providers[info.id] = { ...info };
|
|
33
|
-
this._providersChanged.emit();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get provider information by ID
|
|
38
|
-
* @param id Provider ID
|
|
39
|
-
* @returns Provider info or null if not found
|
|
40
|
-
*/
|
|
41
|
-
getProviderInfo(id: string): IProviderInfo | null {
|
|
42
|
-
return this._providers[id] || null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Create a chat model instance using the specified provider
|
|
47
|
-
* @param id Provider ID
|
|
48
|
-
* @param options Model configuration options
|
|
49
|
-
* @returns Chat model instance or null if creation fails
|
|
50
|
-
*/
|
|
51
|
-
createChatModel(id: string, options: IModelOptions): LanguageModel | null {
|
|
52
|
-
const provider = this._providers[id];
|
|
53
|
-
if (!provider) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return provider.factory(options);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Create a completion model instance using the specified provider
|
|
62
|
-
* @param id Provider ID
|
|
63
|
-
* @param options Model configuration options
|
|
64
|
-
* @returns Language model instance or null if creation fails
|
|
65
|
-
*/
|
|
66
|
-
createCompletionModel(
|
|
67
|
-
id: string,
|
|
68
|
-
options: IModelOptions
|
|
69
|
-
): LanguageModel | null {
|
|
70
|
-
const provider = this._providers[id];
|
|
71
|
-
if (!provider) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return provider.factory(options);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get list of all available provider IDs
|
|
80
|
-
* @returns Array of provider IDs
|
|
81
|
-
*/
|
|
82
|
-
getAvailableProviders(): string[] {
|
|
83
|
-
return Object.keys(this._providers);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private _providers: Record<string, IProviderInfo> = {};
|
|
87
|
-
private _providersChanged = new Signal<IProviderRegistry, void>(this);
|
|
88
|
-
}
|