@tpitre/story-ui 4.1.0 → 4.1.2
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/dist/story-generator/llm-providers/claude-provider.d.ts.map +1 -1
- package/dist/story-generator/llm-providers/claude-provider.js +3 -58
- package/dist/story-generator/llm-providers/gemini-provider.d.ts.map +1 -1
- package/dist/story-generator/llm-providers/gemini-provider.js +16 -60
- package/dist/story-generator/llm-providers/openai-provider.d.ts.map +1 -1
- package/dist/story-generator/llm-providers/openai-provider.js +26 -101
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-provider.d.ts","sourceRoot":"","sources":["../../../story-generator/llm-providers/claude-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-provider.d.ts","sourceRoot":"","sources":["../../../story-generator/llm-providers/claude-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAiGrD,qBAAa,cAAe,SAAQ,eAAe;IACjD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAY;IACvC,QAAQ,CAAC,eAAe,cAAiB;gBAE7B,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAUtC,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAkE1E,UAAU,CACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAAC,WAAW,CAAC;IAuGvB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgD/D,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,cAAc;IAgCtB,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,aAAa;IAiBrB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAMrC;AAGD,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAErF"}
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { BaseLLMProvider } from './base-provider.js';
|
|
7
7
|
import { logger } from '../logger.js';
|
|
8
|
-
// Claude model definitions - Updated
|
|
9
|
-
//
|
|
8
|
+
// Claude model definitions - Updated December 2025
|
|
9
|
+
// Top 4 models only - Reference: Anthropic API documentation
|
|
10
10
|
const CLAUDE_MODELS = [
|
|
11
|
-
// Latest Claude 4.x models (Recommended)
|
|
12
11
|
{
|
|
13
12
|
id: 'claude-opus-4-5-20251101',
|
|
14
13
|
name: 'Claude Opus 4.5',
|
|
@@ -48,7 +47,6 @@ const CLAUDE_MODELS = [
|
|
|
48
47
|
inputPricePer1kTokens: 0.0008,
|
|
49
48
|
outputPricePer1kTokens: 0.004,
|
|
50
49
|
},
|
|
51
|
-
// Claude 4.0 models
|
|
52
50
|
{
|
|
53
51
|
id: 'claude-sonnet-4-20250514',
|
|
54
52
|
name: 'Claude Sonnet 4',
|
|
@@ -62,62 +60,9 @@ const CLAUDE_MODELS = [
|
|
|
62
60
|
inputPricePer1kTokens: 0.003,
|
|
63
61
|
outputPricePer1kTokens: 0.015,
|
|
64
62
|
},
|
|
65
|
-
{
|
|
66
|
-
id: 'claude-opus-4-20250514',
|
|
67
|
-
name: 'Claude Opus 4',
|
|
68
|
-
provider: 'claude',
|
|
69
|
-
contextWindow: 200000,
|
|
70
|
-
maxOutputTokens: 32000,
|
|
71
|
-
supportsVision: true,
|
|
72
|
-
supportsDocuments: true,
|
|
73
|
-
supportsFunctionCalling: true,
|
|
74
|
-
supportsStreaming: true,
|
|
75
|
-
inputPricePer1kTokens: 0.015,
|
|
76
|
-
outputPricePer1kTokens: 0.075,
|
|
77
|
-
},
|
|
78
|
-
// Legacy models (deprecated - use newer versions)
|
|
79
|
-
{
|
|
80
|
-
id: 'claude-3-7-sonnet-20250219',
|
|
81
|
-
name: 'Claude 3.7 Sonnet (Legacy)',
|
|
82
|
-
provider: 'claude',
|
|
83
|
-
contextWindow: 200000,
|
|
84
|
-
maxOutputTokens: 16000,
|
|
85
|
-
supportsVision: true,
|
|
86
|
-
supportsDocuments: true,
|
|
87
|
-
supportsFunctionCalling: true,
|
|
88
|
-
supportsStreaming: true,
|
|
89
|
-
inputPricePer1kTokens: 0.003,
|
|
90
|
-
outputPricePer1kTokens: 0.015,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'claude-3-5-sonnet-20241022',
|
|
94
|
-
name: 'Claude 3.5 Sonnet (Deprecated)',
|
|
95
|
-
provider: 'claude',
|
|
96
|
-
contextWindow: 200000,
|
|
97
|
-
maxOutputTokens: 8192,
|
|
98
|
-
supportsVision: true,
|
|
99
|
-
supportsDocuments: true,
|
|
100
|
-
supportsFunctionCalling: true,
|
|
101
|
-
supportsStreaming: true,
|
|
102
|
-
inputPricePer1kTokens: 0.003,
|
|
103
|
-
outputPricePer1kTokens: 0.015,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 'claude-3-5-haiku-20241022',
|
|
107
|
-
name: 'Claude 3.5 Haiku (Deprecated)',
|
|
108
|
-
provider: 'claude',
|
|
109
|
-
contextWindow: 200000,
|
|
110
|
-
maxOutputTokens: 8192,
|
|
111
|
-
supportsVision: true,
|
|
112
|
-
supportsDocuments: false,
|
|
113
|
-
supportsFunctionCalling: true,
|
|
114
|
-
supportsStreaming: true,
|
|
115
|
-
inputPricePer1kTokens: 0.0008,
|
|
116
|
-
outputPricePer1kTokens: 0.004,
|
|
117
|
-
},
|
|
118
63
|
];
|
|
119
64
|
// Default model - Claude Sonnet 4.5 (recommended for agents and coding)
|
|
120
|
-
const DEFAULT_MODEL = 'claude-
|
|
65
|
+
const DEFAULT_MODEL = 'claude-opus-4-5-20251101';
|
|
121
66
|
// API configuration
|
|
122
67
|
const ANTHROPIC_API_URL = 'https://api.anthropic.com/v1/messages';
|
|
123
68
|
const ANTHROPIC_VERSION = '2023-06-01';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-provider.d.ts","sourceRoot":"","sources":["../../../story-generator/llm-providers/gemini-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini-provider.d.ts","sourceRoot":"","sources":["../../../story-generator/llm-providers/gemini-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoGrD,qBAAa,cAAe,SAAQ,eAAe;IACjD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAY;IACvC,QAAQ,CAAC,eAAe,cAAiB;gBAE7B,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAU5C,OAAO,CAAC,SAAS;IAKX,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA6D1E,UAAU,CACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAAC,WAAW,CAAC;IA+GvB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8C/D,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,cAAc;IAqCtB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,eAAe;IAiBvB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAKrC;AAGD,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAErF"}
|
|
@@ -5,53 +5,36 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { BaseLLMProvider } from './base-provider.js';
|
|
7
7
|
import { logger } from '../logger.js';
|
|
8
|
-
// Gemini model definitions - Updated
|
|
9
|
-
// Reference: https://ai.google.dev/gemini-api/docs/
|
|
8
|
+
// Gemini model definitions - Updated December 2025
|
|
9
|
+
// Top 4 models only - Reference: https://ai.google.dev/gemini-api/docs/models
|
|
10
10
|
const GEMINI_MODELS = [
|
|
11
|
-
// Gemini 3 Series - Latest (November 2025)
|
|
12
11
|
{
|
|
13
|
-
id: 'gemini-
|
|
14
|
-
name: 'Gemini
|
|
12
|
+
id: 'gemini-2.5-pro',
|
|
13
|
+
name: 'Gemini 2.5 Pro',
|
|
15
14
|
provider: 'gemini',
|
|
16
|
-
contextWindow:
|
|
17
|
-
maxOutputTokens:
|
|
18
|
-
supportsVision: true,
|
|
19
|
-
supportsDocuments: true,
|
|
20
|
-
supportsFunctionCalling: true,
|
|
21
|
-
supportsStreaming: true,
|
|
22
|
-
supportsReasoning: true, // Native reasoning with thinking_level parameter
|
|
23
|
-
inputPricePer1kTokens: 0.002, // $2/million for <=200k context
|
|
24
|
-
outputPricePer1kTokens: 0.012, // $12/million output
|
|
25
|
-
description: 'Most intelligent Gemini model. PhD-level reasoning, 1501 Elo on LMArena.',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'gemini-3-pro-preview',
|
|
29
|
-
name: 'Gemini 3 Pro (Preview)',
|
|
30
|
-
provider: 'gemini',
|
|
31
|
-
contextWindow: 1000000,
|
|
32
|
-
maxOutputTokens: 64000,
|
|
15
|
+
contextWindow: 1048576,
|
|
16
|
+
maxOutputTokens: 65536,
|
|
33
17
|
supportsVision: true,
|
|
34
18
|
supportsDocuments: true,
|
|
35
19
|
supportsFunctionCalling: true,
|
|
36
20
|
supportsStreaming: true,
|
|
37
21
|
supportsReasoning: true,
|
|
38
|
-
inputPricePer1kTokens: 0.
|
|
39
|
-
outputPricePer1kTokens: 0.
|
|
40
|
-
description: 'Preview version of Gemini 3 Pro with latest experimental features.',
|
|
22
|
+
inputPricePer1kTokens: 0.00125,
|
|
23
|
+
outputPricePer1kTokens: 0.01,
|
|
41
24
|
},
|
|
42
|
-
// Gemini 2.0 Series
|
|
43
25
|
{
|
|
44
|
-
id: 'gemini-2.
|
|
45
|
-
name: 'Gemini 2.
|
|
26
|
+
id: 'gemini-2.5-flash',
|
|
27
|
+
name: 'Gemini 2.5 Flash',
|
|
46
28
|
provider: 'gemini',
|
|
47
29
|
contextWindow: 1048576,
|
|
48
|
-
maxOutputTokens:
|
|
30
|
+
maxOutputTokens: 65536,
|
|
49
31
|
supportsVision: true,
|
|
50
32
|
supportsDocuments: true,
|
|
51
33
|
supportsFunctionCalling: true,
|
|
52
34
|
supportsStreaming: true,
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
supportsReasoning: true,
|
|
36
|
+
inputPricePer1kTokens: 0.00015,
|
|
37
|
+
outputPricePer1kTokens: 0.0006,
|
|
55
38
|
},
|
|
56
39
|
{
|
|
57
40
|
id: 'gemini-2.0-flash',
|
|
@@ -66,7 +49,6 @@ const GEMINI_MODELS = [
|
|
|
66
49
|
inputPricePer1kTokens: 0.00,
|
|
67
50
|
outputPricePer1kTokens: 0.00,
|
|
68
51
|
},
|
|
69
|
-
// Gemini 1.5 Series (Legacy)
|
|
70
52
|
{
|
|
71
53
|
id: 'gemini-1.5-pro',
|
|
72
54
|
name: 'Gemini 1.5 Pro',
|
|
@@ -80,35 +62,9 @@ const GEMINI_MODELS = [
|
|
|
80
62
|
inputPricePer1kTokens: 0.00125,
|
|
81
63
|
outputPricePer1kTokens: 0.005,
|
|
82
64
|
},
|
|
83
|
-
{
|
|
84
|
-
id: 'gemini-1.5-flash',
|
|
85
|
-
name: 'Gemini 1.5 Flash',
|
|
86
|
-
provider: 'gemini',
|
|
87
|
-
contextWindow: 1048576,
|
|
88
|
-
maxOutputTokens: 8192,
|
|
89
|
-
supportsVision: true,
|
|
90
|
-
supportsDocuments: true,
|
|
91
|
-
supportsFunctionCalling: true,
|
|
92
|
-
supportsStreaming: true,
|
|
93
|
-
inputPricePer1kTokens: 0.000075,
|
|
94
|
-
outputPricePer1kTokens: 0.0003,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: 'gemini-1.5-flash-8b',
|
|
98
|
-
name: 'Gemini 1.5 Flash 8B',
|
|
99
|
-
provider: 'gemini',
|
|
100
|
-
contextWindow: 1048576,
|
|
101
|
-
maxOutputTokens: 8192,
|
|
102
|
-
supportsVision: true,
|
|
103
|
-
supportsDocuments: true,
|
|
104
|
-
supportsFunctionCalling: true,
|
|
105
|
-
supportsStreaming: true,
|
|
106
|
-
inputPricePer1kTokens: 0.0000375,
|
|
107
|
-
outputPricePer1kTokens: 0.00015,
|
|
108
|
-
},
|
|
109
65
|
];
|
|
110
|
-
// Default model
|
|
111
|
-
const DEFAULT_MODEL = 'gemini-2.
|
|
66
|
+
// Default model - Gemini 2.5 Pro (recommended)
|
|
67
|
+
const DEFAULT_MODEL = 'gemini-2.5-pro';
|
|
112
68
|
// API configuration
|
|
113
69
|
const GEMINI_API_BASE = 'https://generativelanguage.googleapis.com/v1beta/models';
|
|
114
70
|
export class GeminiProvider extends BaseLLMProvider {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-provider.d.ts","sourceRoot":"","sources":["../../../story-generator/llm-providers/openai-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-provider.d.ts","sourceRoot":"","sources":["../../../story-generator/llm-providers/openai-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAsGrD,qBAAa,cAAe,SAAQ,eAAe;IACjD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAY;IACvC,QAAQ,CAAC,eAAe,cAAiB;gBAE7B,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAUtC,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAmE1E,UAAU,CACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAAC,WAAW,CAAC;IA6GvB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+C/D,OAAO,CAAC,eAAe;IA8BvB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,cAAc;IAiCtB,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,eAAe;IAmBvB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAKrC;AAGD,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAErF"}
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { BaseLLMProvider } from './base-provider.js';
|
|
7
7
|
import { logger } from '../logger.js';
|
|
8
|
-
// OpenAI model definitions - Updated
|
|
9
|
-
// Reference: https://openai.com/
|
|
8
|
+
// OpenAI model definitions - Updated December 2025
|
|
9
|
+
// Reference: https://platform.openai.com/docs/guides/latest-model
|
|
10
10
|
const OPENAI_MODELS = [
|
|
11
|
-
// GPT-5.1 Series - Latest (November 2025)
|
|
12
11
|
{
|
|
13
|
-
id: 'gpt-5.
|
|
14
|
-
name: 'GPT-5.
|
|
12
|
+
id: 'gpt-5.2',
|
|
13
|
+
name: 'GPT-5.2',
|
|
15
14
|
provider: 'openai',
|
|
16
15
|
contextWindow: 256000,
|
|
17
16
|
maxOutputTokens: 32768,
|
|
@@ -19,47 +18,15 @@ const OPENAI_MODELS = [
|
|
|
19
18
|
supportsDocuments: true,
|
|
20
19
|
supportsFunctionCalling: true,
|
|
21
20
|
supportsStreaming: true,
|
|
22
|
-
supportsReasoning: true,
|
|
21
|
+
supportsReasoning: true,
|
|
23
22
|
inputPricePer1kTokens: 0.005,
|
|
24
23
|
outputPricePer1kTokens: 0.015,
|
|
25
|
-
description: 'Latest GPT-5 series. 76.3% on SWE-bench. Adaptive reasoning capability.',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'gpt-5.1-chat-latest',
|
|
29
|
-
name: 'GPT-5.1 Instant',
|
|
30
|
-
provider: 'openai',
|
|
31
|
-
contextWindow: 256000,
|
|
32
|
-
maxOutputTokens: 32768,
|
|
33
|
-
supportsVision: true,
|
|
34
|
-
supportsDocuments: true,
|
|
35
|
-
supportsFunctionCalling: true,
|
|
36
|
-
supportsStreaming: true,
|
|
37
|
-
supportsReasoning: true,
|
|
38
|
-
inputPricePer1kTokens: 0.003,
|
|
39
|
-
outputPricePer1kTokens: 0.012,
|
|
40
|
-
description: 'More conversational GPT-5.1 with improved instruction following.',
|
|
41
24
|
},
|
|
42
25
|
{
|
|
43
|
-
id: 'gpt-5.1
|
|
44
|
-
name: 'GPT-5.1
|
|
26
|
+
id: 'gpt-5.1',
|
|
27
|
+
name: 'GPT-5.1',
|
|
45
28
|
provider: 'openai',
|
|
46
29
|
contextWindow: 256000,
|
|
47
|
-
maxOutputTokens: 65536,
|
|
48
|
-
supportsVision: true,
|
|
49
|
-
supportsDocuments: true,
|
|
50
|
-
supportsFunctionCalling: true,
|
|
51
|
-
supportsStreaming: true,
|
|
52
|
-
supportsReasoning: true,
|
|
53
|
-
inputPricePer1kTokens: 0.008,
|
|
54
|
-
outputPricePer1kTokens: 0.024,
|
|
55
|
-
description: 'Extended thinking mode for complex reasoning tasks.',
|
|
56
|
-
},
|
|
57
|
-
// GPT-5 Original (August 2025)
|
|
58
|
-
{
|
|
59
|
-
id: 'gpt-5',
|
|
60
|
-
name: 'GPT-5',
|
|
61
|
-
provider: 'openai',
|
|
62
|
-
contextWindow: 200000,
|
|
63
30
|
maxOutputTokens: 32768,
|
|
64
31
|
supportsVision: true,
|
|
65
32
|
supportsDocuments: true,
|
|
@@ -68,9 +35,7 @@ const OPENAI_MODELS = [
|
|
|
68
35
|
supportsReasoning: true,
|
|
69
36
|
inputPricePer1kTokens: 0.005,
|
|
70
37
|
outputPricePer1kTokens: 0.015,
|
|
71
|
-
description: 'Multimodal foundation model combining reasoning and general capabilities.',
|
|
72
38
|
},
|
|
73
|
-
// GPT-4o Series
|
|
74
39
|
{
|
|
75
40
|
id: 'gpt-4o',
|
|
76
41
|
name: 'GPT-4o',
|
|
@@ -97,63 +62,9 @@ const OPENAI_MODELS = [
|
|
|
97
62
|
inputPricePer1kTokens: 0.00015,
|
|
98
63
|
outputPricePer1kTokens: 0.0006,
|
|
99
64
|
},
|
|
100
|
-
// o1 Reasoning Series
|
|
101
|
-
{
|
|
102
|
-
id: 'o1',
|
|
103
|
-
name: 'o1 (Reasoning)',
|
|
104
|
-
provider: 'openai',
|
|
105
|
-
contextWindow: 200000,
|
|
106
|
-
maxOutputTokens: 100000,
|
|
107
|
-
supportsVision: true,
|
|
108
|
-
supportsDocuments: false,
|
|
109
|
-
supportsFunctionCalling: true,
|
|
110
|
-
supportsStreaming: true,
|
|
111
|
-
inputPricePer1kTokens: 0.015,
|
|
112
|
-
outputPricePer1kTokens: 0.06,
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
id: 'o1-mini',
|
|
116
|
-
name: 'o1 Mini (Reasoning)',
|
|
117
|
-
provider: 'openai',
|
|
118
|
-
contextWindow: 128000,
|
|
119
|
-
maxOutputTokens: 65536,
|
|
120
|
-
supportsVision: false,
|
|
121
|
-
supportsDocuments: false,
|
|
122
|
-
supportsFunctionCalling: true,
|
|
123
|
-
supportsStreaming: true,
|
|
124
|
-
inputPricePer1kTokens: 0.003,
|
|
125
|
-
outputPricePer1kTokens: 0.012,
|
|
126
|
-
},
|
|
127
|
-
// Legacy GPT-4 Series
|
|
128
|
-
{
|
|
129
|
-
id: 'gpt-4-turbo',
|
|
130
|
-
name: 'GPT-4 Turbo',
|
|
131
|
-
provider: 'openai',
|
|
132
|
-
contextWindow: 128000,
|
|
133
|
-
maxOutputTokens: 4096,
|
|
134
|
-
supportsVision: true,
|
|
135
|
-
supportsDocuments: false,
|
|
136
|
-
supportsFunctionCalling: true,
|
|
137
|
-
supportsStreaming: true,
|
|
138
|
-
inputPricePer1kTokens: 0.01,
|
|
139
|
-
outputPricePer1kTokens: 0.03,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
id: 'gpt-3.5-turbo',
|
|
143
|
-
name: 'GPT-3.5 Turbo (Legacy)',
|
|
144
|
-
provider: 'openai',
|
|
145
|
-
contextWindow: 16385,
|
|
146
|
-
maxOutputTokens: 4096,
|
|
147
|
-
supportsVision: false,
|
|
148
|
-
supportsDocuments: false,
|
|
149
|
-
supportsFunctionCalling: true,
|
|
150
|
-
supportsStreaming: true,
|
|
151
|
-
inputPricePer1kTokens: 0.0005,
|
|
152
|
-
outputPricePer1kTokens: 0.0015,
|
|
153
|
-
},
|
|
154
65
|
];
|
|
155
66
|
// Default model - Updated to latest GPT-5.1 (December 2025)
|
|
156
|
-
const DEFAULT_MODEL = 'gpt-5.
|
|
67
|
+
const DEFAULT_MODEL = 'gpt-5.2';
|
|
157
68
|
// API configuration
|
|
158
69
|
const OPENAI_API_URL = 'https://api.openai.com/v1/chat/completions';
|
|
159
70
|
export class OpenAIProvider extends BaseLLMProvider {
|
|
@@ -178,13 +89,20 @@ export class OpenAIProvider extends BaseLLMProvider {
|
|
|
178
89
|
}
|
|
179
90
|
const model = options?.model || this.config.model;
|
|
180
91
|
const openaiMessages = this.convertMessages(messages, options?.systemPrompt);
|
|
92
|
+
// Determine which token parameter to use based on model
|
|
93
|
+
// Newer models (o1, gpt-5, gpt-5.1) require max_completion_tokens instead of max_tokens
|
|
94
|
+
const maxTokens = options?.maxTokens || this.getSelectedModel()?.maxOutputTokens || 4096;
|
|
95
|
+
const useMaxCompletionTokens = model.startsWith('o1') || model.startsWith('gpt-5');
|
|
181
96
|
const requestBody = {
|
|
182
97
|
model,
|
|
183
98
|
messages: openaiMessages,
|
|
184
|
-
|
|
99
|
+
...(useMaxCompletionTokens
|
|
100
|
+
? { max_completion_tokens: maxTokens }
|
|
101
|
+
: { max_tokens: maxTokens }),
|
|
185
102
|
};
|
|
186
103
|
// Add optional parameters
|
|
187
|
-
|
|
104
|
+
// Note: temperature is not supported for o1 and some gpt-5 models
|
|
105
|
+
if (options?.temperature !== undefined && !model.startsWith('o1')) {
|
|
188
106
|
requestBody.temperature = options.temperature;
|
|
189
107
|
}
|
|
190
108
|
if (options?.topP !== undefined) {
|
|
@@ -231,13 +149,20 @@ export class OpenAIProvider extends BaseLLMProvider {
|
|
|
231
149
|
}
|
|
232
150
|
const model = options?.model || this.config.model;
|
|
233
151
|
const openaiMessages = this.convertMessages(messages, options?.systemPrompt);
|
|
152
|
+
// Determine which token parameter to use based on model
|
|
153
|
+
// Newer models (o1, gpt-5, gpt-5.1) require max_completion_tokens instead of max_tokens
|
|
154
|
+
const maxTokens = options?.maxTokens || this.getSelectedModel()?.maxOutputTokens || 4096;
|
|
155
|
+
const useMaxCompletionTokens = model.startsWith('o1') || model.startsWith('gpt-5');
|
|
234
156
|
const requestBody = {
|
|
235
157
|
model,
|
|
236
158
|
messages: openaiMessages,
|
|
237
|
-
|
|
159
|
+
...(useMaxCompletionTokens
|
|
160
|
+
? { max_completion_tokens: maxTokens }
|
|
161
|
+
: { max_tokens: maxTokens }),
|
|
238
162
|
stream: true,
|
|
239
163
|
};
|
|
240
|
-
|
|
164
|
+
// Note: temperature is not supported for o1 and some gpt-5 models
|
|
165
|
+
if (options?.temperature !== undefined && !model.startsWith('o1')) {
|
|
241
166
|
requestBody.temperature = options.temperature;
|
|
242
167
|
}
|
|
243
168
|
try {
|