mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-21 13:50:18 +08:00
fix: 第三方/本地服务编辑弹窗丢失多个自定义模型
This commit is contained in:
@@ -58,6 +58,7 @@ export interface LLMConnectionConfig {
|
||||
export interface LLMConnectionConfigCompat extends LLMConnectionConfig {
|
||||
disableThinking?: boolean
|
||||
isReasoningModel?: boolean
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
}
|
||||
|
||||
// ==================== 用途选择(预留) ====================
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface AIServiceConfig {
|
||||
maxTokens?: number
|
||||
disableThinking?: boolean
|
||||
isReasoningModel?: boolean
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
}
|
||||
|
||||
@@ -403,6 +403,7 @@ export function registerAIHandlers({ win }: IpcContext): void {
|
||||
model?: string
|
||||
baseUrl?: string
|
||||
maxTokens?: number
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
}
|
||||
) => {
|
||||
try {
|
||||
@@ -439,6 +440,7 @@ export function registerAIHandlers({ win }: IpcContext): void {
|
||||
model?: string
|
||||
baseUrl?: string
|
||||
maxTokens?: number
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
}
|
||||
) => {
|
||||
try {
|
||||
|
||||
@@ -172,6 +172,7 @@ export interface AIServiceConfigDisplay {
|
||||
maxTokens?: number
|
||||
disableThinking?: boolean
|
||||
isReasoningModel?: boolean
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
}
|
||||
@@ -608,6 +609,7 @@ export const llmApi = {
|
||||
maxTokens?: number
|
||||
disableThinking?: boolean
|
||||
isReasoningModel?: boolean
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
}): Promise<{ success: boolean; config?: AIServiceConfigDisplay; error?: string }> => {
|
||||
return ipcRenderer.invoke('llm:addConfig', config)
|
||||
},
|
||||
@@ -626,6 +628,7 @@ export const llmApi = {
|
||||
maxTokens?: number
|
||||
disableThinking?: boolean
|
||||
isReasoningModel?: boolean
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
}
|
||||
): Promise<{ success: boolean; error?: string }> => {
|
||||
return ipcRenderer.invoke('llm:updateConfig', id, updates)
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface AIServiceConfig {
|
||||
baseUrl?: string
|
||||
disableThinking?: boolean
|
||||
isReasoningModel?: boolean
|
||||
customModels?: Array<{ id: string; name: string }>
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
}
|
||||
@@ -188,7 +189,11 @@ export function useAIConfigForm(props: {
|
||||
if (isCompat) {
|
||||
const looksLocal = !config.apiKeySet || (config.baseUrl?.includes('localhost') ?? false)
|
||||
connectionMode.value = looksLocal ? 'local' : 'openai-compat'
|
||||
compatModels.value = config.model ? [{ id: config.model, name: config.model }] : []
|
||||
if (config.customModels && config.customModels.length > 0) {
|
||||
compatModels.value = [...config.customModels]
|
||||
} else {
|
||||
compatModels.value = config.model ? [{ id: config.model, name: config.model }] : []
|
||||
}
|
||||
} else {
|
||||
connectionMode.value = 'preset'
|
||||
compatModels.value = []
|
||||
@@ -387,6 +392,9 @@ export function useAIConfigForm(props: {
|
||||
const finalName = generateName()
|
||||
|
||||
const isReasoning = formData.value.isReasoningModel
|
||||
const persistCustomModels = isCompatMode.value && compatModels.value.length > 0
|
||||
? compatModels.value.map((m) => ({ id: m.id, name: m.name }))
|
||||
: undefined
|
||||
if (props.mode.value === 'add') {
|
||||
const result = await window.llmApi.addConfig({
|
||||
name: finalName,
|
||||
@@ -396,6 +404,7 @@ export function useAIConfigForm(props: {
|
||||
baseUrl: formData.value.baseUrl.trim() || undefined,
|
||||
disableThinking: isReasoning ? formData.value.disableThinking : undefined,
|
||||
isReasoningModel: isReasoning || undefined,
|
||||
customModels: persistCustomModels,
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
@@ -412,6 +421,7 @@ export function useAIConfigForm(props: {
|
||||
baseUrl: formData.value.baseUrl.trim() || undefined,
|
||||
disableThinking: isReasoning ? formData.value.disableThinking : undefined,
|
||||
isReasoningModel: isReasoning || undefined,
|
||||
customModels: persistCustomModels,
|
||||
}
|
||||
|
||||
if (formData.value.apiKey.trim()) {
|
||||
|
||||
Reference in New Issue
Block a user