Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export default defineConfig({
},
build: {
rollupOptions: {
external: ['sharp']
external: ['sharp'],
output: {
inlineDynamicImports: true,
manualChunks: undefined, // Disable automatic chunk splitting
}
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"tailwindcss-animate": "^1.0.7",
"tippy.js": "^6.3.7",
"typescript": "^5.8.3",
"vite": "npm:rolldown-vite@latest",
"vite": "npm:rolldown-vite@7.0.12",
"vite-plugin-monaco-editor-esm": "^2.0.2",
"vite-plugin-vue-devtools": "^8.0.0",
"vite-svg-loader": "^5.1.0",
Expand Down Expand Up @@ -178,7 +178,7 @@
},
"pnpm": {
"overrides": {
"vite": "npm:rolldown-vite@latest"
"vite": "npm:rolldown-vite@7.0.12"
},
"onlyBuiltDependencies": [
"@tailwindcss/oxide",
Expand Down
10 changes: 8 additions & 2 deletions src/main/presenter/configPresenter/modelConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ export class ModelConfigHelper {
functionCall: config.functionCall || false,
reasoning: config.reasoning || false,
type: config.type || ModelType.Chat,
thinkingBudget: config.thinkingBudget
thinkingBudget: config.thinkingBudget,
reasoningEffort: config.reasoningEffort,
verbosity: config.verbosity,
maxCompletionTokens: config.maxCompletionTokens
}
break
}
Expand All @@ -160,7 +163,10 @@ export class ModelConfigHelper {
functionCall: false,
reasoning: false,
type: ModelType.Chat,
thinkingBudget: undefined
thinkingBudget: undefined,
reasoningEffort: undefined,
verbosity: undefined,
maxCompletionTokens: undefined
}
}
}
Expand Down
52 changes: 52 additions & 0 deletions src/main/presenter/configPresenter/modelDefaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,58 @@ export const defaultModelsSettings: DefaultModelSetting[] = [
functionCall: false,
reasoning: true
},
{
id: 'gpt-5-chat',
name: 'GPT-5 Chat',
maxTokens: 16384,
contextLength: 272000,
match: ['gpt-5-chat', 'gpt-5-chat-latest'],
vision: true,
functionCall: false,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 16384
},
{
id: 'gpt-5-mini',
name: 'GPT-5 Mini',
maxTokens: 128000,
contextLength: 272000,
match: ['gpt-5-mini', 'gpt-5-mini-2025-08-07'],
vision: true,
functionCall: true,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 128000
},
{
id: 'gpt-5-nano',
name: 'GPT-5 Nano',
maxTokens: 128000,
contextLength: 272000,
match: ['gpt-5-nano', 'gpt-5-nano-2025-08-07'],
vision: true,
functionCall: true,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 128000
},
{
id: 'gpt-5',
name: 'GPT-5',
maxTokens: 128000,
contextLength: 272000,
match: ['gpt-5', 'gpt-5-2025-08-07'],
vision: true,
functionCall: true,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 128000
},
{
id: 'gpt-4.5-preview',
name: 'GPT-4.5 Preview',
Expand Down
66 changes: 63 additions & 3 deletions src/main/presenter/configPresenter/providerModelSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,70 @@ export interface ProviderModelSetting {
functionCall?: boolean // 是否支持函数调用
reasoning?: boolean // 是否支持推理能力
type?: ModelType // 模型类型,默认为Chat
// GPT-5 系列新参数
reasoningEffort?: 'minimal' | 'low' | 'medium' | 'high'
verbosity?: 'low' | 'medium' | 'high'
maxCompletionTokens?: number // GPT-5 系列使用此参数替代 maxTokens
}

// 为每个提供商创建映射对象,使用models数组包装模型配置
export const providerModelSettings: Record<string, { models: ProviderModelSetting[] }> = {
// OpenAI提供商特定模型配置
openai: {
models: []
models: [
{
id: 'gpt-5-chat',
name: 'GPT-5 Chat',
maxTokens: 16384,
contextLength: 272000,
match: ['gpt-5-chat', 'gpt-5-chat-latest'],
vision: true,
functionCall: false,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 16384
},
{
id: 'gpt-5-mini',
name: 'GPT-5 Mini',
maxTokens: 128000,
contextLength: 272000,
match: ['gpt-5-mini', 'gpt-5-mini-2025-08-07'],
vision: true,
functionCall: true,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 128000
},
{
id: 'gpt-5-nano',
name: 'GPT-5 Nano',
maxTokens: 128000,
contextLength: 272000,
match: ['gpt-5-nano', 'gpt-5-nano-2025-08-07'],
vision: true,
functionCall: true,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 128000
},
{
id: 'gpt-5',
name: 'GPT-5',
maxTokens: 128000,
contextLength: 272000,
match: ['gpt-5', 'gpt-5-2025-08-07'],
vision: true,
functionCall: true,
reasoning: true,
reasoningEffort: 'medium',
verbosity: 'medium',
maxCompletionTokens: 128000
}
]
},

// 火山引擎(Doubao)提供商特定模型配置
Expand Down Expand Up @@ -2390,11 +2447,14 @@ export function getProviderSpecificModelConfig(
return {
maxTokens: config.maxTokens,
contextLength: config.contextLength,
temperature: config.temperature || 0.7,
temperature: config.temperature, // 保持可选,某些模型不支持
vision: config.vision || false,
functionCall: config.functionCall || false,
reasoning: config.reasoning || false,
type: config.type || ModelType.Chat
type: config.type || ModelType.Chat,
reasoningEffort: config.reasoningEffort,
verbosity: config.verbosity,
maxCompletionTokens: config.maxCompletionTokens
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/presenter/configPresenter/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export const DEFAULT_PROVIDERS: LLM_PROVIDER_BASE[] = [
websites: {
official: 'https://open.bigmodel.cn/',
apiKey: 'https://open.bigmodel.cn/usercenter/apikeys',
docs: 'https://open.bigmodel.cn/dev/howuse/introduction',
docs: 'https://docs.bigmodel.cn',
models: 'https://open.bigmodel.cn/modelcenter/square',
defaultBaseUrl: 'https://open.bigmodel.cn/api/paas/v4/'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ const OPENAI_REASONING_MODELS = [
'o1-mini',
'o1-pro',
'o1-preview',
'o1'
'o1',
'gpt-5',
'gpt-5-mini',
'gpt-5-nano',
'gpt-5-chat'
]
const OPENAI_IMAGE_GENERATION_MODELS = [
'gpt-4o-all',
Expand Down Expand Up @@ -210,7 +214,10 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
model: modelId,
stream: false,
temperature: temperature,
...(modelId.startsWith('o1') || modelId.startsWith('o3') || modelId.startsWith('o4')
...(modelId.startsWith('o1') ||
modelId.startsWith('o3') ||
modelId.startsWith('o4') ||
modelId.startsWith('gpt-5')
? { max_completion_tokens: maxTokens }
: { max_tokens: maxTokens })
}
Expand Down Expand Up @@ -528,7 +535,10 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
model: modelId,
stream: true,
temperature,
...(modelId.startsWith('o1') || modelId.startsWith('o3') || modelId.startsWith('o4')
...(modelId.startsWith('o1') ||
modelId.startsWith('o3') ||
modelId.startsWith('o4') ||
modelId.startsWith('gpt-5')
? { max_completion_tokens: maxTokens }
: { max_tokens: maxTokens })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const OPENAI_REASONING_MODELS = [
'o1-mini',
'o1-pro',
'o1-preview',
'o1'
'o1',
'gpt-5',
'gpt-5-mini',
'gpt-5-nano',
'gpt-5-chat'
]
const OPENAI_IMAGE_GENERATION_MODELS = [
'gpt-4o-all',
Expand Down Expand Up @@ -224,6 +228,20 @@ export class OpenAIResponsesProvider extends BaseLLMProvider {
stream: false
}

if (modelId.startsWith('gpt-5')) {
const modelConfig = this.configPresenter.getModelConfig(modelId, this.provider.id)
if (modelConfig.reasoningEffort) {
;(requestParams as any).reasoning = {
effort: modelConfig.reasoningEffort
}
}
if (modelConfig.verbosity) {
;(requestParams as any).text = {
verbosity: modelConfig.verbosity
}
}
}

OPENAI_REASONING_MODELS.forEach((noTempId) => {
if (modelId.startsWith(noTempId)) {
delete requestParams.temperature
Expand Down Expand Up @@ -554,6 +572,19 @@ export class OpenAIResponsesProvider extends BaseLLMProvider {
requestParams.tools = apiTools
}

if (modelId.startsWith('gpt-5')) {
if (modelConfig.reasoningEffort) {
;(requestParams as any).reasoning = {
effort: modelConfig.reasoningEffort
}
}
if (modelConfig.verbosity) {
;(requestParams as any).text = {
verbosity: modelConfig.verbosity
}
}
}

OPENAI_REASONING_MODELS.forEach((noTempId) => {
if (modelId.startsWith(noTempId)) delete requestParams.temperature
})
Expand Down
8 changes: 7 additions & 1 deletion src/main/presenter/tabPresenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getContextMenuLabels } from '@shared/i18n'
import { app } from 'electron'
import { addWatermarkToNativeImage } from '@/lib/watermark'
import { stitchImagesVertically } from '@/lib/scrollCapture'
import { presenter } from '.'
import { presenter } from './'

export class TabPresenter implements ITabPresenter {
// 全局标签页实例存储
Expand Down Expand Up @@ -534,6 +534,12 @@ export class TabPresenter implements ITabPresenter {
// Once did-finish-load happens, emit first content loaded
webContents.once('did-finish-load', () => {
eventBus.sendToMain(WINDOW_EVENTS.FIRST_CONTENT_LOADED, windowId)
setTimeout(() => {
const windowPresenter = presenter.windowPresenter as any
if (windowPresenter && typeof windowPresenter.focusActiveTab === 'function') {
windowPresenter.focusActiveTab(windowId, 'initial')
}
}, 300)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/presenter/threadPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ export class ThreadPresenter implements IThreadPresenter {
if (defaultModelsSettings) {
mergedSettings.maxTokens = defaultModelsSettings.maxTokens
mergedSettings.contextLength = defaultModelsSettings.contextLength
mergedSettings.temperature = defaultModelsSettings.temperature
mergedSettings.temperature = defaultModelsSettings.temperature ?? 0.7
// 重置 thinkingBudget 为模型默认配置,如果模型配置中没有则设为 undefined
mergedSettings.thinkingBudget = defaultModelsSettings.thinkingBudget
}
Expand Down
Loading