nolo-cli 0.1.7 → 0.1.9
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/README.md +107 -5
- package/agentRuntimeCommands.ts +464 -0
- package/ai/agent/_executeModel.ts +118 -0
- package/ai/agent/agentSlice.ts +525 -0
- package/ai/agent/appWorkingMemory.ts +126 -0
- package/ai/agent/avatarUtils.ts +24 -0
- package/ai/agent/buildEditingContext.ts +373 -0
- package/ai/agent/buildSystemPrompt.ts +532 -0
- package/ai/agent/cleanAgentMessages.ts +140 -0
- package/ai/agent/cliChatClient.ts +119 -0
- package/ai/agent/cliExecutor.ts +733 -0
- package/ai/agent/cliPrompt.ts +10 -0
- package/ai/agent/contextCompiler.ts +107 -0
- package/ai/agent/contextLayerContract.ts +44 -0
- package/ai/agent/createAgentSchema.ts +234 -0
- package/ai/agent/executeToolCall.ts +58 -0
- package/ai/agent/fetchAgentContexts.ts +42 -0
- package/ai/agent/generatePrompt.ts +3 -0
- package/ai/agent/getFullChatContextKeys.ts +168 -0
- package/ai/agent/hooks/fetchPublicAgents.ts +133 -0
- package/ai/agent/hooks/useAgentConfig.ts +61 -0
- package/ai/agent/hooks/useAgentDialog.ts +35 -0
- package/ai/agent/hooks/useAgentFormValidation.ts +202 -0
- package/ai/agent/hooks/usePublicAgents.ts +473 -0
- package/ai/agent/machineRunPermissions.ts +95 -0
- package/ai/agent/persistMessageWithFixedId.ts +37 -0
- package/ai/agent/planSlice.ts +259 -0
- package/ai/agent/referenceUtils.ts +229 -0
- package/ai/agent/runAgentBackground.ts +238 -0
- package/ai/agent/runAgentClientLoop.ts +138 -0
- package/ai/agent/runtimeGuidance.ts +97 -0
- package/ai/agent/runtimeServerBase.ts +37 -0
- package/ai/agent/server/fetchPublicAgents.ts +128 -0
- package/ai/agent/startParallelAgentStreams.ts +424 -0
- package/ai/agent/startupProtocol.ts +53 -0
- package/ai/agent/streamAgentChatTurn.ts +1278 -0
- package/ai/agent/streamAgentChatTurnUtils.ts +738 -0
- package/ai/agent/types.ts +71 -0
- package/ai/agent/utils/imageOutput.ts +33 -0
- package/ai/agent/utils/sortUtils.ts +250 -0
- package/ai/agent/web/referencePickerUtils.ts +146 -0
- package/ai/ai.locale.ts +1075 -0
- package/ai/chat/accumulateToolCallChunks.ts +95 -0
- package/ai/chat/fetchUtils.native.ts +276 -0
- package/ai/chat/fetchUtils.ts +153 -0
- package/ai/chat/parseApiError.ts +64 -0
- package/ai/chat/parseMultilineSSE.ts +95 -0
- package/ai/chat/sendOpenAICompletionsRequest.native.ts +682 -0
- package/ai/chat/sendOpenAICompletionsRequest.ts +703 -0
- package/ai/chat/sendOpenAIResponseRequest.ts +491 -0
- package/ai/chat/shouldUseServerProxy.ts +18 -0
- package/ai/chat/sseClient.native.ts +91 -0
- package/ai/chat/sseClient.ts +67 -0
- package/ai/chat/streamReader.native.ts +31 -0
- package/ai/chat/streamReader.ts +62 -0
- package/ai/chat/updateTotalUsage.ts +72 -0
- package/ai/context/buildReferenceContext.ts +437 -0
- package/ai/context/calculateContextUsage.ts +133 -0
- package/ai/context/retention.ts +165 -0
- package/ai/context/tokenUtils.ts +78 -0
- package/ai/index.ts +1 -0
- package/ai/llm/calculateGeminiImageTokens.ts +57 -0
- package/ai/llm/deepinfra.ts +28 -0
- package/ai/llm/fireworks.ts +50 -0
- package/ai/llm/generateRequestBody.ts +165 -0
- package/ai/llm/getModelContextWindow.ts +84 -0
- package/ai/llm/getNoloKey.ts +31 -0
- package/ai/llm/getPricing.ts +199 -0
- package/ai/llm/hooks/useModelPricing.ts +75 -0
- package/ai/llm/imagePricing.ts +40 -0
- package/ai/llm/isResponseAPIModel.ts +13 -0
- package/ai/llm/mimo.ts +71 -0
- package/ai/llm/mistral.ts +22 -0
- package/ai/llm/modelAvatar.ts +427 -0
- package/ai/llm/models.ts +45 -0
- package/ai/llm/openrouterModels.ts +269 -0
- package/ai/llm/providers.ts +306 -0
- package/ai/llm/reasoningModels.ts +28 -0
- package/ai/llm/types.ts +59 -0
- package/ai/llm/usageRequestOptions.ts +59 -0
- package/ai/memory/capture.ts +148 -0
- package/ai/memory/consolidate.ts +104 -0
- package/ai/memory/delete.ts +147 -0
- package/ai/memory/overlay.ts +84 -0
- package/ai/memory/query.ts +38 -0
- package/ai/memory/queryShared.ts +160 -0
- package/ai/memory/rank.ts +105 -0
- package/ai/memory/recentRelationshipRecap.ts +249 -0
- package/ai/memory/remember.ts +167 -0
- package/ai/memory/runtime.ts +76 -0
- package/ai/memory/store.ts +20 -0
- package/ai/memory/storeShared.ts +76 -0
- package/ai/memory/types.ts +46 -0
- package/ai/memory/understanding.ts +349 -0
- package/ai/memory/understandingGreeting.ts +264 -0
- package/ai/messages/type.ts +20 -0
- package/ai/policy/personalizationDialog.ts +333 -0
- package/ai/policy/runtimePolicy.ts +440 -0
- package/ai/policy/selfUpdateFields.ts +48 -0
- package/ai/policy/types.ts +64 -0
- package/ai/skills/referenceRuntime.ts +274 -0
- package/ai/skills/skillDiagnostics.ts +251 -0
- package/ai/skills/skillDocBuilder.ts +139 -0
- package/ai/skills/skillDocProtocol.ts +434 -0
- package/ai/skills/skillReferenceSummary.ts +63 -0
- package/ai/skills/skillSummaryMarker.ts +26 -0
- package/ai/token/calculatePrice.ts +544 -0
- package/ai/token/db.ts +98 -0
- package/ai/token/externalToolCost.ts +330 -0
- package/ai/token/hooks/useRecords.ts +65 -0
- package/ai/token/missingUsageEstimate.ts +42 -0
- package/ai/token/modelUsageQuery.ts +252 -0
- package/ai/token/normalizeUsage.ts +84 -0
- package/ai/token/openaiImageGenerationUsage.ts +56 -0
- package/ai/token/prepareTokenUsageData.ts +88 -0
- package/ai/token/query.ts +88 -0
- package/ai/token/queryUserTokens.ts +59 -0
- package/ai/token/resolveBillingTarget.ts +52 -0
- package/ai/token/saveTokenRecord.ts +53 -0
- package/ai/token/serverDialogProjection.ts +78 -0
- package/ai/token/serverTokenWriter.ts +143 -0
- package/ai/token/stats.ts +21 -0
- package/ai/token/tokenThunks.ts +24 -0
- package/ai/token/types.ts +93 -0
- package/ai/tools/agent/agentTools.ts +176 -0
- package/ai/tools/agent/agentUpdateShared.ts +311 -0
- package/ai/tools/agent/callAgentTool.ts +139 -0
- package/ai/tools/agent/createAgentTool.ts +512 -0
- package/ai/tools/agent/createDialogTool.ts +69 -0
- package/ai/tools/agent/createSkillAgentTool.ts +62 -0
- package/ai/tools/agent/parallelBudget.ts +221 -0
- package/ai/tools/agent/presets/appBuilderPreset.ts +145 -0
- package/ai/tools/agent/runLlmTool.ts +96 -0
- package/ai/tools/agent/runStreamingAgentTool.ts +73 -0
- package/ai/tools/agent/skillAgentArgs.ts +106 -0
- package/ai/tools/agent/skillAgentPreset.ts +89 -0
- package/ai/tools/agent/streamParallelAgentsTool.ts +122 -0
- package/ai/tools/agent/updateAgentTool.ts +96 -0
- package/ai/tools/agent/updateSelfTool.ts +113 -0
- package/ai/tools/amazonProductScraperTool.ts +86 -0
- package/ai/tools/apifyActorClient.ts +45 -0
- package/ai/tools/appEditGuard.ts +372 -0
- package/ai/tools/appReadSnapshot.ts +153 -0
- package/ai/tools/appTools.ts +1549 -0
- package/ai/tools/applyEditTool.ts +256 -0
- package/ai/tools/applyLineEditsTool.ts +312 -0
- package/ai/tools/browserTools/click.ts +33 -0
- package/ai/tools/browserTools/closeSession.ts +29 -0
- package/ai/tools/browserTools/common.ts +27 -0
- package/ai/tools/browserTools/openSession.ts +48 -0
- package/ai/tools/browserTools/readContent.ts +38 -0
- package/ai/tools/browserTools/selectOption.ts +46 -0
- package/ai/tools/browserTools/typeText.ts +42 -0
- package/ai/tools/category/createCategoryTool.ts +66 -0
- package/ai/tools/category/queryContentsByCategoryTool.ts +69 -0
- package/ai/tools/category/updateContentCategoryTool.ts +75 -0
- package/ai/tools/cfBrowserTools.ts +319 -0
- package/ai/tools/cfSpeechToTextTool.ts +49 -0
- package/ai/tools/checkEnvTool.ts +65 -0
- package/ai/tools/cloudflareCrawlTool.ts +289 -0
- package/ai/tools/codeSearchTool.ts +111 -0
- package/ai/tools/codeTools.ts +101 -0
- package/ai/tools/createDocTool.ts +132 -0
- package/ai/tools/createPlanTool.ts +999 -0
- package/ai/tools/createSkillDocTool.ts +155 -0
- package/ai/tools/createWorkflowTool.ts +154 -0
- package/ai/tools/deepseekOcrTool.ts +34 -0
- package/ai/tools/delayTool.ts +31 -0
- package/ai/tools/deleteSpacesTool.ts +325 -0
- package/ai/tools/deleteSpacesToolModel.ts +159 -0
- package/ai/tools/devReloadUtils.ts +29 -0
- package/ai/tools/dialogMessageSearch.ts +137 -0
- package/ai/tools/doctorSkillTool.ts +72 -0
- package/ai/tools/ecommerceScraperTool.ts +86 -0
- package/ai/tools/emailTools.ts +549 -0
- package/ai/tools/evalSkillTool.ts +92 -0
- package/ai/tools/exaSearchTool.ts +64 -0
- package/ai/tools/execBashTool.ts +379 -0
- package/ai/tools/executeSqlTool.ts +192 -0
- package/ai/tools/fetchWebpageSupport.ts +309 -0
- package/ai/tools/fetchWebpageTool.ts +84 -0
- package/ai/tools/geminiImagePreviewTool.ts +361 -0
- package/ai/tools/generateDocxTool.ts +215 -0
- package/ai/tools/googleSearchScraperTool.ts +106 -0
- package/ai/tools/importDataTool.ts +133 -0
- package/ai/tools/importSkillTool.ts +162 -0
- package/ai/tools/index.ts +1858 -0
- package/ai/tools/listFilesTool.ts +82 -0
- package/ai/tools/listUserSpacesTool.ts +113 -0
- package/ai/tools/modelUsageTools.ts +142 -0
- package/ai/tools/olmOcrTool.ts +34 -0
- package/ai/tools/openaiImageTool.ts +218 -0
- package/ai/tools/paddleOcrTool.ts +34 -0
- package/ai/tools/prepareTools.ts +23 -0
- package/ai/tools/readDocTool.ts +84 -0
- package/ai/tools/readFileTool.ts +211 -0
- package/ai/tools/readTool.ts +163 -0
- package/ai/tools/readXPostTool.ts +233 -0
- package/ai/tools/rememberMemoryTool.ts +84 -0
- package/ai/tools/remotionVideoTool.ts +151 -0
- package/ai/tools/searchDialogMessagesTool.ts +222 -0
- package/ai/tools/searchRepoTool.ts +115 -0
- package/ai/tools/searchWorkspaceTool.ts +259 -0
- package/ai/tools/skillFollowup.ts +86 -0
- package/ai/tools/surfWeatherTool.ts +169 -0
- package/ai/tools/table/addTableRowTool.ts +217 -0
- package/ai/tools/table/createTableTool.ts +315 -0
- package/ai/tools/table/rowTools.ts +366 -0
- package/ai/tools/table/schemaTools.ts +244 -0
- package/ai/tools/table/shareTableTool.ts +148 -0
- package/ai/tools/table/toolShared.ts +129 -0
- package/ai/tools/toolApiClient.ts +198 -0
- package/ai/tools/toolNameAliases.ts +57 -0
- package/ai/tools/toolResultError.ts +42 -0
- package/ai/tools/toolRunSlice.ts +303 -0
- package/ai/tools/toolSchemaCompatibility.ts +53 -0
- package/ai/tools/toolVisibility.ts +4 -0
- package/ai/tools/types.ts +20 -0
- package/ai/tools/uiAskChoiceTool.ts +104 -0
- package/ai/tools/updateContentTitleTool.ts +84 -0
- package/ai/tools/updateDocTool.ts +105 -0
- package/ai/tools/updateUserPreferenceProfileTool.ts +145 -0
- package/ai/tools/whisperTool.ts +77 -0
- package/ai/tools/writeFileTool.ts +210 -0
- package/ai/tools/youtubeScraperTool.ts +116 -0
- package/ai/tools/ziweiChartTool.ts +678 -0
- package/ai/types.ts +55 -0
- package/ai/workflow/workflowExecutor.ts +323 -0
- package/ai/workflow/workflowSlice.ts +73 -0
- package/ai/workflow/workflowTypes.ts +106 -0
- package/client/agentRun.ts +198 -167
- package/client/compactDialog.ts +222 -0
- package/commandRegistry.ts +14 -0
- package/connector-experimental/capabilities.ts +73 -0
- package/connector-experimental/codexBinary.ts +41 -0
- package/connector-experimental/heartbeatLoop.ts +22 -0
- package/connector-experimental/index.ts +5 -0
- package/connector-experimental/machineInfo.ts +46 -0
- package/connector-experimental/protocol.ts +54 -0
- package/connectorWebSocketTarget.ts +29 -0
- package/defaultServer.ts +1 -0
- package/index.ts +158 -104
- package/machineCommands.ts +382 -0
- package/package.json +12 -2
- package/tui/readlineWorkspace.ts +50 -0
- package/tui/session.ts +40 -2
- package/updateCommands.ts +70 -5
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { ModelDefinition } from '../types';
|
|
2
|
+
|
|
3
|
+
export const OPENROUTER_MODELS: ModelDefinition[] = [
|
|
4
|
+
// ==================== anthropic ====================
|
|
5
|
+
{
|
|
6
|
+
id: 'anthropic/claude-opus-4.7',
|
|
7
|
+
name: 'Claude Opus 4.7',
|
|
8
|
+
provider: 'anthropic',
|
|
9
|
+
description: 'Claude Opus 4.7 是 Anthropic 新一代 Opus 家族模型,专为长时运行异步 Agent 设计,擅长复杂多步任务和大型代码库',
|
|
10
|
+
contextWindow: 1000000,
|
|
11
|
+
maxTokens: 8192,
|
|
12
|
+
supportVision: false,
|
|
13
|
+
supportTool: false,
|
|
14
|
+
supportReasoning: true,
|
|
15
|
+
supportStreaming: true,
|
|
16
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
17
|
+
pricing: { input: 5, output: 25 },
|
|
18
|
+
capabilities: ['文本生成', '代码编写', '复杂推理', 'Agent 执行', '长上下文'],
|
|
19
|
+
group: 'anthropic',
|
|
20
|
+
recommended: false,
|
|
21
|
+
deprecated: false,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'anthropic/claude-opus-4.6',
|
|
25
|
+
name: 'Claude Opus 4.6',
|
|
26
|
+
provider: 'anthropic',
|
|
27
|
+
description: 'Claude Opus 4.6 是 Anthropic 的高性能 Opus 模型,适合复杂推理与高难度任务',
|
|
28
|
+
contextWindow: 200000,
|
|
29
|
+
maxTokens: 8192,
|
|
30
|
+
supportVision: true,
|
|
31
|
+
supportTool: true,
|
|
32
|
+
supportReasoning: true,
|
|
33
|
+
supportStreaming: true,
|
|
34
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
35
|
+
pricing: { input: 15, output: 75 },
|
|
36
|
+
capabilities: ['文本生成', '代码编写', '复杂推理', '多模态理解'],
|
|
37
|
+
group: 'anthropic',
|
|
38
|
+
recommended: false,
|
|
39
|
+
deprecated: false,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'anthropic/claude-sonnet-4.6',
|
|
43
|
+
name: 'Claude Sonnet 4.6',
|
|
44
|
+
provider: 'anthropic',
|
|
45
|
+
description: 'Claude Sonnet 4.6 是 Anthropic 的通用高性价比模型,适合日常编码和复杂分析',
|
|
46
|
+
contextWindow: 200000,
|
|
47
|
+
maxTokens: 8192,
|
|
48
|
+
supportVision: true,
|
|
49
|
+
supportTool: true,
|
|
50
|
+
supportReasoning: true,
|
|
51
|
+
supportStreaming: true,
|
|
52
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
53
|
+
pricing: { input: 3, output: 15 },
|
|
54
|
+
capabilities: ['文本生成', '代码编写', '推理', '多模态理解'],
|
|
55
|
+
group: 'anthropic',
|
|
56
|
+
recommended: false,
|
|
57
|
+
deprecated: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'anthropic/claude-3.5-sonnet',
|
|
61
|
+
name: 'Claude 3.5 Sonnet',
|
|
62
|
+
provider: 'anthropic',
|
|
63
|
+
description: 'Claude 3.5 Sonnet 是 Anthropic 的中端模型,适合日常任务',
|
|
64
|
+
contextWindow: 200000,
|
|
65
|
+
maxTokens: 4096,
|
|
66
|
+
supportVision: true,
|
|
67
|
+
supportTool: true,
|
|
68
|
+
supportReasoning: false,
|
|
69
|
+
supportStreaming: true,
|
|
70
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
71
|
+
pricing: { input: 3, output: 15 },
|
|
72
|
+
capabilities: ['文本生成', '代码编写', '推理', '多模态理解'],
|
|
73
|
+
group: 'anthropic',
|
|
74
|
+
recommended: false,
|
|
75
|
+
deprecated: false,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'anthropic/claude-haiku-4.6',
|
|
79
|
+
name: 'Claude Haiku 4.6',
|
|
80
|
+
provider: 'anthropic',
|
|
81
|
+
description: 'Claude Haiku 4.6 是 Anthropic 的轻量高速模型,适合低延迟与轻量任务',
|
|
82
|
+
contextWindow: 200000,
|
|
83
|
+
maxTokens: 4096,
|
|
84
|
+
supportVision: false,
|
|
85
|
+
supportTool: true,
|
|
86
|
+
supportReasoning: true,
|
|
87
|
+
supportStreaming: true,
|
|
88
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
89
|
+
pricing: { input: 0.25, output: 1.25 },
|
|
90
|
+
capabilities: ['快速响应', '简单任务', '代码辅助'],
|
|
91
|
+
group: 'anthropic',
|
|
92
|
+
recommended: false,
|
|
93
|
+
deprecated: false,
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
// ==================== openai ====================
|
|
97
|
+
{
|
|
98
|
+
id: 'openai/o3-mini-high',
|
|
99
|
+
name: 'o3-mini-high',
|
|
100
|
+
provider: 'openai',
|
|
101
|
+
description: 'OpenAI o3-mini-high 推理模型,适合高难度的分析、数学、编程',
|
|
102
|
+
contextWindow: 200000,
|
|
103
|
+
maxTokens: 100000,
|
|
104
|
+
supportVision: false,
|
|
105
|
+
supportTool: false,
|
|
106
|
+
supportReasoning: true,
|
|
107
|
+
supportStreaming: true,
|
|
108
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
109
|
+
pricing: { input: 1.1, output: 4.4 },
|
|
110
|
+
capabilities: ['推理', '复杂分析', '数学', '编程'],
|
|
111
|
+
group: 'openai',
|
|
112
|
+
recommended: false,
|
|
113
|
+
deprecated: false,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'openai/o3-mini',
|
|
117
|
+
name: 'o3-mini',
|
|
118
|
+
provider: 'openai',
|
|
119
|
+
description: 'OpenAI o3-mini 推理模型,平衡性能和成本',
|
|
120
|
+
contextWindow: 200000,
|
|
121
|
+
maxTokens: 100000,
|
|
122
|
+
supportVision: false,
|
|
123
|
+
supportTool: true,
|
|
124
|
+
supportReasoning: true,
|
|
125
|
+
supportStreaming: true,
|
|
126
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
127
|
+
pricing: { input: 1.1, output: 4.4 },
|
|
128
|
+
capabilities: ['推理', '分析', '编程'],
|
|
129
|
+
group: 'openai',
|
|
130
|
+
recommended: false,
|
|
131
|
+
deprecated: false,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'openai/o1-mini',
|
|
135
|
+
name: 'o1-mini',
|
|
136
|
+
provider: 'openai',
|
|
137
|
+
description: 'OpenAI o1-mini 推理模型,适合数学和编程',
|
|
138
|
+
contextWindow: 128000,
|
|
139
|
+
maxTokens: 65536,
|
|
140
|
+
supportVision: false,
|
|
141
|
+
supportTool: true,
|
|
142
|
+
supportReasoning: true,
|
|
143
|
+
supportStreaming: true,
|
|
144
|
+
temperatureRange: { min: 0, max: 1, default: 0.7 },
|
|
145
|
+
pricing: { input: 1.1, output: 4.4 },
|
|
146
|
+
capabilities: ['推理', '数学', '编程'],
|
|
147
|
+
group: 'openai',
|
|
148
|
+
recommended: false,
|
|
149
|
+
deprecated: false,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'openai/gpt-4o',
|
|
153
|
+
name: 'GPT-4o',
|
|
154
|
+
provider: 'openai',
|
|
155
|
+
description: 'GPT-4o 是 OpenAI 最新的多模态旗舰模型',
|
|
156
|
+
contextWindow: 128000,
|
|
157
|
+
maxTokens: 16384,
|
|
158
|
+
supportVision: true,
|
|
159
|
+
supportTool: true,
|
|
160
|
+
supportReasoning: false,
|
|
161
|
+
supportStreaming: true,
|
|
162
|
+
temperatureRange: { min: 0, max: 2, default: 0.7 },
|
|
163
|
+
pricing: { input: 2.5, output: 10 },
|
|
164
|
+
capabilities: ['文本生成', '多模态理解', '代码编写', '推理'],
|
|
165
|
+
group: 'openai',
|
|
166
|
+
recommended: true,
|
|
167
|
+
deprecated: false,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'openai/gpt-4o-mini',
|
|
171
|
+
name: 'GPT-4o Mini',
|
|
172
|
+
provider: 'openai',
|
|
173
|
+
description: 'GPT-4o Mini 是 OpenAI 的高效轻量模型',
|
|
174
|
+
contextWindow: 128000,
|
|
175
|
+
maxTokens: 16384,
|
|
176
|
+
supportVision: true,
|
|
177
|
+
supportTool: true,
|
|
178
|
+
supportReasoning: false,
|
|
179
|
+
supportStreaming: true,
|
|
180
|
+
temperatureRange: { min: 0, max: 2, default: 0.7 },
|
|
181
|
+
pricing: { input: 0.15, output: 0.6 },
|
|
182
|
+
capabilities: ['快速响应', '多模态理解', '简单任务'],
|
|
183
|
+
group: 'openai',
|
|
184
|
+
recommended: true,
|
|
185
|
+
deprecated: false,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 'openai/gpt-4-turbo',
|
|
189
|
+
name: 'GPT-4 Turbo',
|
|
190
|
+
provider: 'openai',
|
|
191
|
+
description: 'GPT-4 Turbo 是 OpenAI 上一代旗舰模型',
|
|
192
|
+
contextWindow: 128000,
|
|
193
|
+
maxTokens: 4096,
|
|
194
|
+
supportVision: true,
|
|
195
|
+
supportTool: true,
|
|
196
|
+
supportReasoning: false,
|
|
197
|
+
supportStreaming: true,
|
|
198
|
+
temperatureRange: { min: 0, max: 2, default: 0.7 },
|
|
199
|
+
pricing: { input: 10, output: 30 },
|
|
200
|
+
capabilities: ['文本生成', '代码编写', '推理'],
|
|
201
|
+
group: 'openai',
|
|
202
|
+
recommended: false,
|
|
203
|
+
deprecated: false,
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
// ==================== gemini ====================
|
|
207
|
+
{
|
|
208
|
+
id: 'google/gemini-2.5-pro-preview-03-25',
|
|
209
|
+
name: 'Gemini 2.5 Pro',
|
|
210
|
+
provider: 'google',
|
|
211
|
+
description: 'Gemini 2.5 Pro 是 Google 最新的多模态大模型,支持超长上下文',
|
|
212
|
+
contextWindow: 1048576,
|
|
213
|
+
maxTokens: 65536,
|
|
214
|
+
supportVision: true,
|
|
215
|
+
supportTool: true,
|
|
216
|
+
supportReasoning: false,
|
|
217
|
+
supportStreaming: true,
|
|
218
|
+
temperatureRange: { min: 0, max: 2, default: 0.7 },
|
|
219
|
+
pricing: { input: 1.25, output: 10 },
|
|
220
|
+
capabilities: ['超长上下文', '文本生成', '多模态理解', '代码编写'],
|
|
221
|
+
group: 'google',
|
|
222
|
+
recommended: true,
|
|
223
|
+
deprecated: false,
|
|
224
|
+
},
|
|
225
|
+
// ==================== fireworks ====================
|
|
226
|
+
// ==================== moonshotai ====================
|
|
227
|
+
{
|
|
228
|
+
id: 'moonshotai/kimi-k2.6',
|
|
229
|
+
name: 'Kimi K2.6',
|
|
230
|
+
provider: 'moonshotai',
|
|
231
|
+
description: 'Kimi K2.6 是 Moonshot AI 的下一代多模态模型,专为长时程编程、UI/UX 生成和多 Agent 编排设计',
|
|
232
|
+
contextWindow: 262144,
|
|
233
|
+
maxTokens: 8192,
|
|
234
|
+
supportVision: true,
|
|
235
|
+
supportTool: true,
|
|
236
|
+
supportReasoning: true,
|
|
237
|
+
supportStreaming: true,
|
|
238
|
+
temperatureRange: { min: 0, max: 2, default: 0.7 },
|
|
239
|
+
pricing: { input: 0.6, output: 2.8 },
|
|
240
|
+
capabilities: ['文本生成', '代码编写', '多模态理解', 'Agent 编排', 'UI/UX 生成'],
|
|
241
|
+
group: 'moonshotai',
|
|
242
|
+
recommended: false,
|
|
243
|
+
deprecated: false,
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
// ==================== xiaomi ====================
|
|
247
|
+
{
|
|
248
|
+
id: 'xiaomi/mimo-v2.5-pro',
|
|
249
|
+
name: 'xiaomi/mimo-v2.5-pro',
|
|
250
|
+
displayName: 'Xiaomi: MiMo V2.5 Pro',
|
|
251
|
+
provider: 'xiaomi',
|
|
252
|
+
description: 'MiMo V2.5 Pro 是 Xiaomi 的长上下文 agentic/code 模型,适合复杂软件工程和工具调用工作流',
|
|
253
|
+
contextWindow: 1048576,
|
|
254
|
+
maxTokens: 131072,
|
|
255
|
+
supportVision: true,
|
|
256
|
+
supportTool: true,
|
|
257
|
+
supportReasoning: true,
|
|
258
|
+
supportStreaming: true,
|
|
259
|
+
temperatureRange: { min: 0, max: 2, default: 0.7 },
|
|
260
|
+
pricing: { input: 1, output: 3 },
|
|
261
|
+
capabilities: ['文本生成', '代码编写', '复杂推理', '长上下文', '工具调用'],
|
|
262
|
+
group: 'xiaomi',
|
|
263
|
+
recommended: true,
|
|
264
|
+
deprecated: false,
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
];
|
|
268
|
+
|
|
269
|
+
export const openrouterModels = OPENROUTER_MODELS;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// ai/llm/providers.ts
|
|
2
|
+
import { anthropicModels } from "integrations/anthropic/anthropicModels";
|
|
3
|
+
import { deepSeekModels } from "integrations/deepseek/models";
|
|
4
|
+
import { googleModels } from "integrations/google/models";
|
|
5
|
+
import { openAIModels } from "integrations/openai/models";
|
|
6
|
+
import { openrouterModels } from "ai/llm/openrouterModels";
|
|
7
|
+
import { deepinfraModels } from "ai/llm/deepinfra";
|
|
8
|
+
// import { xaiModels } from "integrations/xai/models";
|
|
9
|
+
import './fireworks'
|
|
10
|
+
import type { Model } from "./types";
|
|
11
|
+
import type { Agent } from "app/types";
|
|
12
|
+
import { fireworksModels } from "./fireworks";
|
|
13
|
+
import { mistralModels } from "./mistral";
|
|
14
|
+
import { mimoModels } from "./mimo";
|
|
15
|
+
import type { ModelPrice } from "./types";
|
|
16
|
+
export { supportedReasoningModels } from "./reasoningModels";
|
|
17
|
+
|
|
18
|
+
/* ──────────────────────────────────────────
|
|
19
|
+
* 所有模型(仅用于功能过滤)
|
|
20
|
+
* ────────────────────────────────────────── */
|
|
21
|
+
|
|
22
|
+
/* ──────────────────────────────────────────
|
|
23
|
+
* Provider → 模型列表
|
|
24
|
+
* ────────────────────────────────────────── */
|
|
25
|
+
const MODEL_MAP = {
|
|
26
|
+
// anthropic: anthropicModels,
|
|
27
|
+
deepseek: deepSeekModels,
|
|
28
|
+
google: googleModels,
|
|
29
|
+
openai: openAIModels,
|
|
30
|
+
deepinfra: deepinfraModels,
|
|
31
|
+
openrouter: openrouterModels,
|
|
32
|
+
fireworks: fireworksModels,
|
|
33
|
+
mistral: mistralModels,
|
|
34
|
+
mimo: mimoModels,
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
const MODEL_LOOKUP_MAP = {
|
|
38
|
+
anthropic: anthropicModels,
|
|
39
|
+
...MODEL_MAP,
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
type LookupProvider = keyof typeof MODEL_LOOKUP_MAP;
|
|
43
|
+
|
|
44
|
+
type ModelLookupCandidate = Model & {
|
|
45
|
+
id?: string;
|
|
46
|
+
pricing?: ModelPrice;
|
|
47
|
+
supportVision?: boolean;
|
|
48
|
+
supportTool?: boolean;
|
|
49
|
+
supportReasoning?: boolean;
|
|
50
|
+
maxTokens?: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const ANTHROPIC_MODEL_ALIASES: Record<string, string> = {
|
|
54
|
+
"claude-sonnet-4.6": "claude-3-7-sonnet-latest",
|
|
55
|
+
"claude-sonnet-4.5": "claude-3-5-sonnet-latest",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const normalizeLookupProvider = (provider?: string | null): LookupProvider | null => {
|
|
59
|
+
if (!provider) return null;
|
|
60
|
+
const normalized = provider.toLowerCase();
|
|
61
|
+
if (normalized in MODEL_LOOKUP_MAP) {
|
|
62
|
+
return normalized as LookupProvider;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const normalizeLookupModelName = (
|
|
68
|
+
provider: LookupProvider,
|
|
69
|
+
name: string
|
|
70
|
+
): string => {
|
|
71
|
+
if (provider === "anthropic") {
|
|
72
|
+
return ANTHROPIC_MODEL_ALIASES[name] ?? name;
|
|
73
|
+
}
|
|
74
|
+
return name;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const toModel = (candidate: ModelLookupCandidate): Model => ({
|
|
78
|
+
name:
|
|
79
|
+
typeof candidate.id === "string" && candidate.id.trim()
|
|
80
|
+
? candidate.id
|
|
81
|
+
: candidate.name,
|
|
82
|
+
displayName:
|
|
83
|
+
candidate.displayName ??
|
|
84
|
+
(typeof candidate.id === "string" && candidate.id !== candidate.name
|
|
85
|
+
? candidate.name
|
|
86
|
+
: undefined),
|
|
87
|
+
hasVision:
|
|
88
|
+
typeof candidate.hasVision === "boolean"
|
|
89
|
+
? candidate.hasVision
|
|
90
|
+
: !!candidate.supportVision,
|
|
91
|
+
contextWindow: candidate.contextWindow,
|
|
92
|
+
price: candidate.price ?? candidate.pricing ?? { input: 0, output: 0 },
|
|
93
|
+
pricingStrategy: candidate.pricingStrategy,
|
|
94
|
+
maxOutputTokens: candidate.maxOutputTokens ?? candidate.maxTokens,
|
|
95
|
+
jsonOutput: candidate.jsonOutput,
|
|
96
|
+
fnCall:
|
|
97
|
+
typeof candidate.fnCall === "boolean"
|
|
98
|
+
? candidate.fnCall
|
|
99
|
+
: candidate.supportTool,
|
|
100
|
+
provider: candidate.provider,
|
|
101
|
+
description: candidate.description,
|
|
102
|
+
hasAudio: candidate.hasAudio,
|
|
103
|
+
maxImageResolution: candidate.maxImageResolution,
|
|
104
|
+
canFineTune: candidate.canFineTune,
|
|
105
|
+
hasImageOutput: candidate.hasImageOutput,
|
|
106
|
+
supportsImageOutput: candidate.supportsImageOutput,
|
|
107
|
+
supportsTool:
|
|
108
|
+
typeof candidate.supportsTool === "boolean"
|
|
109
|
+
? candidate.supportsTool
|
|
110
|
+
: candidate.supportTool,
|
|
111
|
+
supportsImageConfig: candidate.supportsImageConfig,
|
|
112
|
+
requiresImageModalities: candidate.requiresImageModalities,
|
|
113
|
+
defaultModalities: candidate.defaultModalities,
|
|
114
|
+
supportedAspectRatios: candidate.supportedAspectRatios,
|
|
115
|
+
supportedImageSizes: candidate.supportedImageSizes,
|
|
116
|
+
pricePerImage: candidate.pricePerImage,
|
|
117
|
+
imagePricingNote: candidate.imagePricingNote,
|
|
118
|
+
imageTokenPricePerMillion: candidate.imageTokenPricePerMillion,
|
|
119
|
+
imageOutputTokenEstimateBySize: candidate.imageOutputTokenEstimateBySize,
|
|
120
|
+
supportsReasoningEffort:
|
|
121
|
+
typeof candidate.supportsReasoningEffort === "boolean"
|
|
122
|
+
? candidate.supportsReasoningEffort
|
|
123
|
+
: candidate.supportReasoning,
|
|
124
|
+
endpointKey: candidate.endpointKey,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const findCandidateInProvider = (
|
|
128
|
+
provider: LookupProvider,
|
|
129
|
+
name: string
|
|
130
|
+
): Model | null => {
|
|
131
|
+
const normalizedName = normalizeLookupModelName(provider, name);
|
|
132
|
+
const list = MODEL_LOOKUP_MAP[provider] as readonly ModelLookupCandidate[];
|
|
133
|
+
const candidate = list.find(
|
|
134
|
+
(item) =>
|
|
135
|
+
item.name === normalizedName ||
|
|
136
|
+
item.displayName === normalizedName ||
|
|
137
|
+
item.id === normalizedName
|
|
138
|
+
);
|
|
139
|
+
return candidate ? toModel(candidate) : null;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const findOpenRouterUpstreamModel = (name: string): Model | null => {
|
|
143
|
+
const slash = name.indexOf("/");
|
|
144
|
+
if (slash <= 0) return null;
|
|
145
|
+
const upstreamProvider = normalizeLookupProvider(name.slice(0, slash));
|
|
146
|
+
if (!upstreamProvider) return null;
|
|
147
|
+
const upstreamModelName = name.slice(slash + 1);
|
|
148
|
+
return findCandidateInProvider(upstreamProvider, upstreamModelName);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export function findModelConfig(provider: string, name: string): Model | null {
|
|
152
|
+
const normalizedProvider = normalizeLookupProvider(provider);
|
|
153
|
+
if (!normalizedProvider) return null;
|
|
154
|
+
|
|
155
|
+
const direct = findCandidateInProvider(normalizedProvider, name);
|
|
156
|
+
if (direct) return direct;
|
|
157
|
+
|
|
158
|
+
if (normalizedProvider === "openrouter") {
|
|
159
|
+
return findOpenRouterUpstreamModel(name);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* 自动推断 Provider 字面量类型 */
|
|
166
|
+
export const availableProviderOptions = Object.keys(MODEL_MAP) as Array<
|
|
167
|
+
keyof typeof MODEL_MAP
|
|
168
|
+
>;
|
|
169
|
+
export type Provider = (typeof availableProviderOptions)[number];
|
|
170
|
+
|
|
171
|
+
/* ──────────────────────────────────────────
|
|
172
|
+
* Provider → 命名端点
|
|
173
|
+
* 统一用 endpointKey 提高可读性
|
|
174
|
+
* ────────────────────────────────────────── */
|
|
175
|
+
type ProviderEndpointMap = Record<string, string>; // endpointKey → URL
|
|
176
|
+
|
|
177
|
+
const API_ENDPOINTS: Record<string, ProviderEndpointMap> = {
|
|
178
|
+
openai: {
|
|
179
|
+
completions: "https://api.openai.com/v1/chat/completions",
|
|
180
|
+
responses: "https://api.openai.com/v1/responses",
|
|
181
|
+
},
|
|
182
|
+
xai: {
|
|
183
|
+
default: "https://api.x.ai/v1/chat/completions",
|
|
184
|
+
},
|
|
185
|
+
deepseek: {
|
|
186
|
+
default: "https://api.deepseek.com/chat/completions",
|
|
187
|
+
},
|
|
188
|
+
deepinfra: {
|
|
189
|
+
default: "https://api.deepinfra.com/v1/openai/chat/completions",
|
|
190
|
+
},
|
|
191
|
+
mistral: {
|
|
192
|
+
default: "https://api.mistral.ai/v1/chat/completions",
|
|
193
|
+
},
|
|
194
|
+
google: {
|
|
195
|
+
default:
|
|
196
|
+
"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",
|
|
197
|
+
},
|
|
198
|
+
openrouter: {
|
|
199
|
+
default: "https://openrouter.ai/api/v1/chat/completions",
|
|
200
|
+
},
|
|
201
|
+
fireworks: {
|
|
202
|
+
default: "https://api.fireworks.ai/inference/v1/chat/completions"
|
|
203
|
+
},
|
|
204
|
+
mimo: {
|
|
205
|
+
default: "https://token-plan-cn.xiaomimimo.com/v1/chat/completions",
|
|
206
|
+
}
|
|
207
|
+
} as const;
|
|
208
|
+
|
|
209
|
+
/* ──────────────────────────────────────────
|
|
210
|
+
* 工具函数
|
|
211
|
+
* ────────────────────────────────────────── */
|
|
212
|
+
|
|
213
|
+
/** 根据 provider & name 获取模型配置 */
|
|
214
|
+
export function getModelConfig(provider: Provider | "anthropic", name: string): Model {
|
|
215
|
+
const model = findModelConfig(provider, name);
|
|
216
|
+
if (!model) {
|
|
217
|
+
throw new Error(`Model ${name} not found for provider ${provider}`);
|
|
218
|
+
}
|
|
219
|
+
return model;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** 获取某 provider 全量模型 */
|
|
223
|
+
export function getModelsByProvider(provider: Provider): Model[] {
|
|
224
|
+
return MODEL_MAP[provider] ?? [];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** 通过模型名反查 provider(跨所有 provider 搜索) */
|
|
228
|
+
export function getProviderByModelName(modelName: string): Provider | undefined {
|
|
229
|
+
for (const [provider, models] of Object.entries(MODEL_MAP)) {
|
|
230
|
+
if (models.some((m) => m.name === modelName)) {
|
|
231
|
+
return provider as Provider;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** 默认模型配置(provider + model 成对出现,避免分散硬编码) */
|
|
238
|
+
export const DEFAULT_MODEL = {
|
|
239
|
+
provider: "openrouter" as Provider,
|
|
240
|
+
name: "xiaomi/mimo-v2.5-pro",
|
|
241
|
+
} as const;
|
|
242
|
+
|
|
243
|
+
/** 统一获取 ChatCompletion / Responses 等端点 */
|
|
244
|
+
export function getApiEndpoint(agent: Agent): string {
|
|
245
|
+
const { provider, customProviderUrl, endpointKey, model } = agent;
|
|
246
|
+
const effectiveProvider = provider;
|
|
247
|
+
const effectiveModel = model;
|
|
248
|
+
|
|
249
|
+
// CLI agents don't use HTTP API endpoints - should never reach here
|
|
250
|
+
if ((agent as any).apiSource === "cli") {
|
|
251
|
+
throw new Error(
|
|
252
|
+
"Routing error: CLI agent should not call getApiEndpoint. Check streamAgentChatTurn."
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* 手动覆盖:有自定义 URL 时直接用,但对只填了 base URL 的情况做兜底补全 */
|
|
257
|
+
if (customProviderUrl) {
|
|
258
|
+
const url = customProviderUrl.trim().replace(/\/$/, ""); // 去掉末尾斜杠
|
|
259
|
+
// 如果 URL 末尾是 /v1 /v2 /v1beta /v3 等版本路径(典型 base URL),
|
|
260
|
+
// 说明用户可能漏填了 /chat/completions,自动补全
|
|
261
|
+
if (/\/v\d+(beta\d*)?$/.test(url)) {
|
|
262
|
+
return `${url}/chat/completions`;
|
|
263
|
+
}
|
|
264
|
+
return url;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* custom provider / apiSource=custom 但未给 URL 的兜底
|
|
268
|
+
* 注意:apiSource="custom" 的 agent(如 kimi-k2.5)不需要 provider 字段,
|
|
269
|
+
* 使用 customProviderUrl + 自己的 apiKey,上面已经 return 了。
|
|
270
|
+
* 只有 customProviderUrl 为空时才会走到这里报错。
|
|
271
|
+
*/
|
|
272
|
+
if (
|
|
273
|
+
!effectiveProvider ||
|
|
274
|
+
effectiveProvider.toLowerCase() === "custom" ||
|
|
275
|
+
(agent as any).apiSource === "custom"
|
|
276
|
+
) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
"Custom provider URL is required when apiSource is 'custom'."
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* Provider 端点表 */
|
|
283
|
+
const endpoints = API_ENDPOINTS[effectiveProvider];
|
|
284
|
+
if (!endpoints) throw new Error(`Unsupported provider: ${provider}`);
|
|
285
|
+
|
|
286
|
+
/* 1. Agent 显式 endpointKey 优先 */
|
|
287
|
+
let key = endpointKey;
|
|
288
|
+
|
|
289
|
+
/* 2. 未指定时,读取模型默认 endpointKey */
|
|
290
|
+
if (!key && effectiveModel) {
|
|
291
|
+
try {
|
|
292
|
+
key = getModelConfig(effectiveProvider as Provider, effectiveModel).endpointKey;
|
|
293
|
+
} catch {
|
|
294
|
+
/* ignore */
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* 3. 取 URL 顺序:指定 key → default → 第一个 */
|
|
299
|
+
if (key && endpoints[key]) return endpoints[key];
|
|
300
|
+
if (endpoints.default) return endpoints.default;
|
|
301
|
+
|
|
302
|
+
const first = Object.values(endpoints)[0];
|
|
303
|
+
if (first) return first;
|
|
304
|
+
|
|
305
|
+
throw new Error(`No endpoint found for provider ${provider}`);
|
|
306
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const REASONING_MODEL_NAMES = new Set([
|
|
2
|
+
"deepseek-v4-flash",
|
|
3
|
+
"deepseek-v4-pro",
|
|
4
|
+
"deepseek-reasoner",
|
|
5
|
+
"gemini-2.5-pro",
|
|
6
|
+
"gemini-2.5-flash",
|
|
7
|
+
"gemini-3-flash-preview",
|
|
8
|
+
"gemini-3-pro-preview",
|
|
9
|
+
"gemini-3.1-pro-preview",
|
|
10
|
+
"gpt-5.5",
|
|
11
|
+
"gpt-5.5-flex",
|
|
12
|
+
"gpt-5.5-pro",
|
|
13
|
+
"gpt-5.5-pro-flex",
|
|
14
|
+
"gpt-5.4",
|
|
15
|
+
"gpt-5.4-flex",
|
|
16
|
+
"gpt-5.4-mini",
|
|
17
|
+
"gpt-5.4-nano",
|
|
18
|
+
"gpt-5.4-pro",
|
|
19
|
+
"gpt-5.4-pro-flex",
|
|
20
|
+
"gpt-5",
|
|
21
|
+
"gpt-5-mini",
|
|
22
|
+
"o3-pro",
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
export const isModelSupportReasoningEffort = (model: string): boolean =>
|
|
26
|
+
REASONING_MODEL_NAMES.has(model);
|
|
27
|
+
|
|
28
|
+
export const supportedReasoningModels = Array.from(REASONING_MODEL_NAMES);
|
package/ai/llm/types.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// ai/llm/types.ts
|
|
2
|
+
|
|
3
|
+
export interface ModelPrice {
|
|
4
|
+
input: number;
|
|
5
|
+
output: number;
|
|
6
|
+
cachingWrite?: number;
|
|
7
|
+
cachingRead?: number;
|
|
8
|
+
inputCacheHit?: number; // 为DeepSeek模型保留
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 新增:定价阶梯定义
|
|
12
|
+
export interface PricingTier {
|
|
13
|
+
minContext: number; // 触发此价格的最小 Token 数 (例如 200001)
|
|
14
|
+
price: ModelPrice; // 此阶梯对应的完整价格表
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 新增:定价策略定义
|
|
18
|
+
export interface PricingStrategy {
|
|
19
|
+
type: "tiered_context"; // 目前支持基于上下文长度的阶梯定价
|
|
20
|
+
tiers: PricingTier[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Model {
|
|
24
|
+
name: string;
|
|
25
|
+
displayName?: string; // 可选的 displayName 字段
|
|
26
|
+
hasVision: boolean;
|
|
27
|
+
contextWindow?: any; // 建议改为 number,但保持你原有的 any 兼容
|
|
28
|
+
price: ModelPrice; // 基础/默认价格
|
|
29
|
+
|
|
30
|
+
// 新增字段:支持高级定价策略
|
|
31
|
+
pricingStrategy?: PricingStrategy;
|
|
32
|
+
|
|
33
|
+
maxOutputTokens?: any; // 最大输出令牌数,建议改为 number
|
|
34
|
+
jsonOutput?: boolean; // 是否支持 JSON 结构化输出
|
|
35
|
+
fnCall?: boolean; // 是否支持函数调用
|
|
36
|
+
provider?: string; // 供应商
|
|
37
|
+
description?: string; // 描述
|
|
38
|
+
hasAudio?: boolean; // 是否支持音频输入
|
|
39
|
+
maxImageResolution?: string; // 最大图像分辨率
|
|
40
|
+
canFineTune?: boolean; // 是否可以微调
|
|
41
|
+
|
|
42
|
+
hasImageOutput?: boolean; // 是否支持图片输出
|
|
43
|
+
supportsImageOutput?: boolean; // 兼容旧字段名
|
|
44
|
+
supportsTool?: boolean; // 是否支持工具调用
|
|
45
|
+
|
|
46
|
+
// ✅ 新增:图像生成相关能力
|
|
47
|
+
supportsImageConfig?: boolean; // 是否支持 image_config(aspect_ratio / image_size)
|
|
48
|
+
requiresImageModalities?: boolean; // 是否需要显式设置 modalities 才能出图
|
|
49
|
+
defaultModalities?: Array<"text" | "image">; // 模型推荐的默认输出模态组合
|
|
50
|
+
supportedAspectRatios?: string[];
|
|
51
|
+
supportedImageSizes?: string[];
|
|
52
|
+
pricePerImage?: number;
|
|
53
|
+
imagePricingNote?: string;
|
|
54
|
+
imageTokenPricePerMillion?: number;
|
|
55
|
+
imageOutputTokenEstimateBySize?: Partial<Record<"1K" | "2K" | "4K", number>>;
|
|
56
|
+
|
|
57
|
+
supportsReasoningEffort?: boolean; // 是否支持推理功能
|
|
58
|
+
endpointKey?: string;
|
|
59
|
+
}
|