Skip to content

Commit c779b66

Browse files
committed
refactor(core): 移除流式支持标识并修复TypeScript类型错误
- 移除TextModel接口中的supportsStreaming属性,简化模型能力定义 - 重构OpenAI适配器,简化模型配置和连接验证逻辑 - 修复useTextModelManager.ts中的TypeScript类型安全问题 - 更新所有相关测试文件,移除supportsStreaming相关断言 - 统一测试代码格式,确保编译通过 BREAKING CHANGE: 移除了supportsStreaming能力标识,所有模型默认支持流式响应
1 parent e7f3d23 commit c779b66

27 files changed

+97
-389
lines changed

packages/core/src/services/llm/adapters/abstract-adapter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,9 @@ export abstract class AbstractTextProviderAdapter implements ITextProviderAdapte
326326
description: `Custom model ${modelId} for ${provider.name}`,
327327
providerId: provider.id,
328328
capabilities: {
329-
supportsStreaming: true, // 默认支持流式
330-
supportsTools: false, // 默认不支持工具
331-
supportsReasoning: false, // 默认不支持推理
332-
maxContextLength: 4096 // 默认上下文长度
329+
supportsTools: true, // 默认支持工具
330+
supportsReasoning: true, // 默认支持推理
331+
maxContextLength: 128000 // 默认上下文长度
333332
},
334333
parameterDefinitions: this.getParameterDefinitions(modelId),
335334
defaultParameterValues: this.getDefaultParameterValues(modelId)

packages/core/src/services/llm/adapters/anthropic-adapter.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
8181
description: 'Most powerful Claude model for complex tasks',
8282
providerId,
8383
capabilities: {
84-
supportsStreaming: true,
85-
supportsTools: true,
84+
supportsTools: true,
8685
supportsReasoning: false,
8786
maxContextLength: 200000
8887
},
@@ -95,8 +94,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
9594
description: 'Balanced Claude model for most tasks',
9695
providerId,
9796
capabilities: {
98-
supportsStreaming: true,
99-
supportsTools: true,
97+
supportsTools: true,
10098
supportsReasoning: false,
10199
maxContextLength: 200000
102100
},
@@ -111,8 +109,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
111109
description: 'Latest Claude 3.7 Sonnet model',
112110
providerId,
113111
capabilities: {
114-
supportsStreaming: true,
115-
supportsTools: true,
112+
supportsTools: true,
116113
supportsReasoning: false,
117114
maxContextLength: 200000
118115
},
@@ -125,8 +122,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
125122
description: 'Fast and affordable Claude model',
126123
providerId,
127124
capabilities: {
128-
supportsStreaming: true,
129-
supportsTools: true,
125+
supportsTools: true,
130126
supportsReasoning: false,
131127
maxContextLength: 200000
132128
},

packages/core/src/services/llm/adapters/deepseek-adapter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const DEEPSEEK_STATIC_MODELS: ModelOverride[] = [
1616
description: 'DeepSeek chat model via OpenAI-compatible API',
1717
capabilities: {
1818
supportsTools: true,
19-
maxContextLength: 64000
19+
supportsReasoning: false,
20+
maxContextLength: 128000
2021
}
2122
},
2223
{
@@ -25,7 +26,7 @@ const DEEPSEEK_STATIC_MODELS: ModelOverride[] = [
2526
description: 'DeepSeek reasoning model with step-by-step thinking outputs',
2627
capabilities: {
2728
supportsReasoning: true,
28-
maxContextLength: 64000
29+
maxContextLength: 128000
2930
}
3031
}
3132
]
@@ -41,11 +42,10 @@ export class DeepseekAdapter extends OpenAIAdapter {
4142
supportsDynamicModels: true,
4243
connectionSchema: {
4344
required: ['apiKey'],
44-
optional: ['baseURL', 'timeout'],
45+
optional: ['baseURL'],
4546
fieldTypes: {
4647
apiKey: 'string',
47-
baseURL: 'string',
48-
timeout: 'number'
48+
baseURL: 'string'
4949
}
5050
}
5151
}

packages/core/src/services/llm/adapters/gemini-adapter.ts

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ export class GeminiAdapter extends AbstractTextProviderAdapter {
3737
supportsDynamicModels: false, // Gemini不支持动态模型获取
3838
connectionSchema: {
3939
required: ['apiKey'],
40-
optional: ['baseURL', 'timeout'],
40+
optional: ['baseURL'],
4141
fieldTypes: {
4242
apiKey: 'string',
43-
baseURL: 'string',
44-
timeout: 'number'
43+
baseURL: 'string'
4544
}
4645
}
4746
}
@@ -56,46 +55,17 @@ export class GeminiAdapter extends AbstractTextProviderAdapter {
5655

5756
return [
5857
{
59-
id: 'gemini-2.0-flash-exp',
60-
name: 'Gemini 2.0 Flash (Experimental)',
61-
description: 'Latest experimental Gemini 2.0 Flash model',
58+
id: 'gemini-2.5-flash',
59+
name: 'Gemini 2.5 Flash',
60+
description: 'Latest experimental Gemini 2.5 Flash model',
6261
providerId,
6362
capabilities: {
64-
supportsStreaming: true,
6563
supportsTools: true,
6664
supportsReasoning: false,
6765
maxContextLength: 1000000
6866
},
69-
parameterDefinitions: this.getParameterDefinitions('gemini-2.0-flash-exp'),
70-
defaultParameterValues: this.getDefaultParameterValues('gemini-2.0-flash-exp')
71-
},
72-
{
73-
id: 'gemini-2.0-flash-thinking-exp-1219',
74-
name: 'Gemini 2.0 Flash Thinking',
75-
description: 'Gemini 2.0 Flash with extended thinking capabilities',
76-
providerId,
77-
capabilities: {
78-
supportsStreaming: true,
79-
supportsTools: true,
80-
supportsReasoning: true,
81-
maxContextLength: 32000
82-
},
83-
parameterDefinitions: this.getParameterDefinitions('gemini-2.0-flash-thinking-exp-1219'),
84-
defaultParameterValues: this.getDefaultParameterValues('gemini-2.0-flash-thinking-exp-1219')
85-
},
86-
{
87-
id: 'gemini-exp-1206',
88-
name: 'Gemini Experimental 1206',
89-
description: 'Experimental Gemini model (December 6th)',
90-
providerId,
91-
capabilities: {
92-
supportsStreaming: true,
93-
supportsTools: true,
94-
supportsReasoning: false,
95-
maxContextLength: 200000
96-
},
97-
parameterDefinitions: this.getParameterDefinitions('gemini-exp-1206'),
98-
defaultParameterValues: this.getDefaultParameterValues('gemini-exp-1206')
67+
parameterDefinitions: this.getParameterDefinitions('gemini-2.5-flash'),
68+
defaultParameterValues: this.getDefaultParameterValues('gemini-2.5-flash')
9969
}
10070
]
10171
}

packages/core/src/services/llm/adapters/openai-adapter.ts

Lines changed: 7 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ export class OpenAIAdapter extends AbstractTextProviderAdapter {
3838
supportsDynamicModels: true,
3939
connectionSchema: {
4040
required: ['apiKey'],
41-
optional: ['baseURL', 'organization', 'timeout'],
41+
optional: ['baseURL'],
4242
fieldTypes: {
4343
apiKey: 'string',
44-
baseURL: 'string',
45-
organization: 'string',
46-
timeout: 'number'
44+
baseURL: 'string'
4745
}
4846
}
4947
}
@@ -58,94 +56,17 @@ export class OpenAIAdapter extends AbstractTextProviderAdapter {
5856
return [
5957
// GPT-4o 系列
6058
{
61-
id: 'gpt-4o',
62-
name: 'GPT-4o',
63-
description: 'Latest GPT-4o model with vision capabilities',
59+
id: 'gpt-5-2025-08-07',
60+
name: 'GPT-5',
61+
description: '',
6462
providerId,
6563
capabilities: {
66-
supportsStreaming: true,
6764
supportsTools: true,
6865
supportsReasoning: false,
6966
maxContextLength: 128000
7067
},
71-
parameterDefinitions: this.getParameterDefinitions('gpt-4o'),
72-
defaultParameterValues: this.getDefaultParameterValues('gpt-4o')
73-
},
74-
{
75-
id: 'gpt-4o-mini',
76-
name: 'GPT-4o Mini',
77-
description: 'Affordable and intelligent small model for fast, lightweight tasks',
78-
providerId,
79-
capabilities: {
80-
supportsStreaming: true,
81-
supportsTools: true,
82-
supportsReasoning: false,
83-
maxContextLength: 128000
84-
},
85-
parameterDefinitions: this.getParameterDefinitions('gpt-4o-mini'),
86-
defaultParameterValues: this.getDefaultParameterValues('gpt-4o-mini')
87-
},
88-
89-
// o1 系列(推理模型)
90-
{
91-
id: 'o1',
92-
name: 'o1',
93-
description: 'Advanced reasoning model for complex tasks',
94-
providerId,
95-
capabilities: {
96-
supportsStreaming: true,
97-
supportsTools: false,
98-
supportsReasoning: true,
99-
maxContextLength: 200000
100-
},
101-
parameterDefinitions: this.getParameterDefinitions('o1'),
102-
defaultParameterValues: this.getDefaultParameterValues('o1')
103-
},
104-
{
105-
id: 'o1-mini',
106-
name: 'o1 Mini',
107-
description: 'Faster and cheaper reasoning model for coding, math, and science',
108-
providerId,
109-
capabilities: {
110-
supportsStreaming: true,
111-
supportsTools: false,
112-
supportsReasoning: true,
113-
maxContextLength: 128000
114-
},
115-
parameterDefinitions: this.getParameterDefinitions('o1-mini'),
116-
defaultParameterValues: this.getDefaultParameterValues('o1-mini')
117-
},
118-
119-
// GPT-4 Turbo
120-
{
121-
id: 'gpt-4-turbo',
122-
name: 'GPT-4 Turbo',
123-
description: 'Latest GPT-4 Turbo model with vision capabilities',
124-
providerId,
125-
capabilities: {
126-
supportsStreaming: true,
127-
supportsTools: true,
128-
supportsReasoning: false,
129-
maxContextLength: 128000
130-
},
131-
parameterDefinitions: this.getParameterDefinitions('gpt-4-turbo'),
132-
defaultParameterValues: this.getDefaultParameterValues('gpt-4-turbo')
133-
},
134-
135-
// GPT-3.5 Turbo
136-
{
137-
id: 'gpt-3.5-turbo',
138-
name: 'GPT-3.5 Turbo',
139-
description: 'Fast and affordable model for simple tasks',
140-
providerId,
141-
capabilities: {
142-
supportsStreaming: true,
143-
supportsTools: true,
144-
supportsReasoning: false,
145-
maxContextLength: 16385
146-
},
147-
parameterDefinitions: this.getParameterDefinitions('gpt-3.5-turbo'),
148-
defaultParameterValues: this.getDefaultParameterValues('gpt-3.5-turbo')
68+
parameterDefinitions: this.getParameterDefinitions('gpt-5-2025-08-07'),
69+
defaultParameterValues: this.getDefaultParameterValues('gpt-5-2025-08-07')
14970
}
15071
]
15172
}
@@ -158,11 +79,6 @@ export class OpenAIAdapter extends AbstractTextProviderAdapter {
15879
public async getModelsAsync(config: TextModelConfig): Promise<TextModel[]> {
15980
// 验证baseURL以/v1结尾
16081
const baseURL = config.connectionConfig.baseURL || this.getProvider().defaultBaseURL
161-
if (!/\/v1$/.test(baseURL)) {
162-
throw new Error(
163-
`MISSING_V1_SUFFIX: baseURL should end with "/v1" for OpenAI-compatible APIs. Current: ${baseURL}`
164-
)
165-
}
16682

16783
const openai = this.createOpenAIInstance(config, false)
16884

packages/core/src/services/llm/adapters/siliconflow-adapter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const SILICONFLOW_STATIC_MODELS: ModelOverride[] = [
1616
description: 'Qwen3-8B model via SiliconFlow',
1717
capabilities: {
1818
supportsTools: false,
19-
maxContextLength: 8192
19+
maxContextLength: 128000
2020
}
2121
}
2222
]
@@ -32,11 +32,10 @@ export class SiliconflowAdapter extends OpenAIAdapter {
3232
supportsDynamicModels: true,
3333
connectionSchema: {
3434
required: ['apiKey'],
35-
optional: ['baseURL', 'timeout'],
35+
optional: ['baseURL'],
3636
fieldTypes: {
3737
apiKey: 'string',
38-
baseURL: 'string',
39-
timeout: 'number'
38+
baseURL: 'string'
4039
}
4140
}
4241
}

packages/core/src/services/llm/adapters/zhipu-adapter.ts

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,13 @@ interface ModelOverride {
1111

1212
const ZHIPU_STATIC_MODELS: ModelOverride[] = [
1313
{
14-
id: 'glm-4-plus',
15-
name: 'GLM-4 Plus',
16-
description: 'High-performance GLM-4 Plus model from Zhipu',
14+
id: 'glm-4.6',
15+
name: 'GLM-4.6',
16+
description: '',
1717
capabilities: {
1818
supportsTools: true,
1919
maxContextLength: 128000
2020
}
21-
},
22-
{
23-
id: 'glm-4-0520',
24-
name: 'GLM-4 0520',
25-
description: 'GLM-4 model (0520 release) with balanced cost and quality',
26-
capabilities: {
27-
supportsTools: true,
28-
maxContextLength: 128000
29-
}
30-
},
31-
{
32-
id: 'glm-4',
33-
name: 'GLM-4',
34-
description: 'Flagship GLM-4 model from Zhipu',
35-
capabilities: {
36-
supportsTools: true,
37-
maxContextLength: 128000
38-
}
39-
},
40-
{
41-
id: 'glm-4-air',
42-
name: 'GLM-4 Air',
43-
description: 'Cost-effective GLM-4 Air model',
44-
capabilities: {
45-
supportsTools: false,
46-
maxContextLength: 128000
47-
}
48-
},
49-
{
50-
id: 'glm-4-airx',
51-
name: 'GLM-4 AirX',
52-
description: 'Turbo GLM-4 AirX model for fast iteration',
53-
capabilities: {
54-
supportsTools: false,
55-
maxContextLength: 128000
56-
}
57-
},
58-
{
59-
id: 'glm-4-flash',
60-
name: 'GLM-4 Flash',
61-
description: 'Fast GLM-4 Flash model from Zhipu',
62-
capabilities: {
63-
supportsTools: true,
64-
maxContextLength: 128000
65-
},
66-
defaultParameterValues: {
67-
temperature: 0.95
68-
}
6921
}
7022
]
7123

@@ -77,14 +29,13 @@ export class ZhipuAdapter extends OpenAIAdapter {
7729
description: 'Zhipu GLM OpenAI-compatible models',
7830
requiresApiKey: true,
7931
defaultBaseURL: 'https://open.bigmodel.cn/api/paas/v4',
80-
supportsDynamicModels: false,
32+
supportsDynamicModels: true,
8133
connectionSchema: {
8234
required: ['apiKey'],
83-
optional: ['baseURL', 'timeout'],
35+
optional: ['baseURL'],
8436
fieldTypes: {
8537
apiKey: 'string',
86-
baseURL: 'string',
87-
timeout: 'number'
38+
baseURL: 'string'
8839
}
8940
}
9041
}

packages/core/src/services/llm/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ export interface TextModel {
7474
readonly providerId: string
7575
/** 模型能力定义 */
7676
readonly capabilities: {
77-
/** 是否支持流式响应 */
78-
supportsStreaming: boolean
7977
/** 是否支持工具调用 */
8078
supportsTools: boolean
8179
/** 是否支持推理内容(如 o1 系列) */

0 commit comments

Comments
 (0)