From ce32fd32b6d28357977cc40ff781126e50e3c4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E7=94=B1=E7=9A=84=E4=B8=96=E7=95=8C=E4=BA=BA?= <3196812536@qq.com> Date: Mon, 16 Jun 2025 12:04:45 +0800 Subject: [PATCH 1/3] fix: include image files in block retrieval for improved file handling (#7231) --- src/renderer/src/store/thunk/messageThunk.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/store/thunk/messageThunk.ts b/src/renderer/src/store/thunk/messageThunk.ts index 17487ad69..afab87619 100644 --- a/src/renderer/src/store/thunk/messageThunk.ts +++ b/src/renderer/src/store/thunk/messageThunk.ts @@ -196,7 +196,10 @@ export const cleanupMultipleBlocks = (dispatch: AppDispatch, blockIds: string[]) const getBlocksFiles = async (blockIds: string[]) => { const blocks = await db.message_blocks.where('id').anyOf(blockIds).toArray() - const files = blocks.filter((block) => block.type === MessageBlockType.FILE).map((block) => block.file) + const files = blocks + .filter((block) => block.type === MessageBlockType.FILE || block.type === MessageBlockType.IMAGE) + .map((block) => block.file) + .filter((file): file is FileType => file !== undefined) return isEmpty(files) ? [] : files } From eb650aa586500465f64ff70afca3f19889cf8f44 Mon Sep 17 00:00:00 2001 From: SuYao Date: Mon, 16 Jun 2025 12:51:09 +0800 Subject: [PATCH 2/3] fix: enable stream output in assistant settings for chat completion (#7240) --- src/renderer/src/windows/mini/home/HomeWindow.tsx | 2 +- .../src/windows/selection/action/components/ActionUtils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/windows/mini/home/HomeWindow.tsx b/src/renderer/src/windows/mini/home/HomeWindow.tsx index 998264746..1b1b7b6db 100644 --- a/src/renderer/src/windows/mini/home/HomeWindow.tsx +++ b/src/renderer/src/windows/mini/home/HomeWindow.tsx @@ -187,7 +187,7 @@ const HomeWindow: FC = () => { fetchChatCompletion({ messages: [userMessage], - assistant: { ...assistant, model: quickAssistantModel || getDefaultModel() }, + assistant: { ...assistant, model: quickAssistantModel || getDefaultModel(), settings: { streamOutput: true } }, onChunkReceived: (chunk: Chunk) => { if (chunk.type === ChunkType.TEXT_DELTA) { blockContent += chunk.text diff --git a/src/renderer/src/windows/selection/action/components/ActionUtils.ts b/src/renderer/src/windows/selection/action/components/ActionUtils.ts index 8ee77f673..d6b77cec4 100644 --- a/src/renderer/src/windows/selection/action/components/ActionUtils.ts +++ b/src/renderer/src/windows/selection/action/components/ActionUtils.ts @@ -51,7 +51,7 @@ export const processMessages = async ( await fetchChatCompletion({ messages: [userMessage], - assistant, + assistant: { ...assistant, settings: { streamOutput: true } }, onChunkReceived: (chunk: Chunk) => { switch (chunk.type) { case ChunkType.THINKING_DELTA: From eb89ca54154c03894175e6d5008346a4a5f3dfa4 Mon Sep 17 00:00:00 2001 From: one Date: Mon, 16 Jun 2025 13:06:52 +0800 Subject: [PATCH 3/3] fix: gemini generateImage model detection (#7241) * fix: gemini generateImage model detection * refactor: use base name for websearch model detection --- src/renderer/src/config/models.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index 3c849cc85..679511f9c 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -2594,9 +2594,11 @@ export function isWebSearchModel(model: Model): boolean { return false } + const baseName = getBaseModelName(model.id, '/').toLowerCase() + // 不管哪个供应商都判断了 if (model.id.includes('claude')) { - return CLAUDE_SUPPORTED_WEBSEARCH_REGEX.test(model.id) + return CLAUDE_SUPPORTED_WEBSEARCH_REGEX.test(baseName) } if (provider.type === 'openai-response') { @@ -2608,7 +2610,7 @@ export function isWebSearchModel(model: Model): boolean { } if (provider.id === 'perplexity') { - return PERPLEXITY_SEARCH_MODELS.includes(model?.id) + return PERPLEXITY_SEARCH_MODELS.includes(baseName) } if (provider.id === 'aihubmix') { @@ -2617,31 +2619,31 @@ export function isWebSearchModel(model: Model): boolean { } const models = ['gemini-2.0-flash-search', 'gemini-2.0-flash-exp-search', 'gemini-2.0-pro-exp-02-05-search'] - return models.includes(model?.id) + return models.includes(baseName) } if (provider?.type === 'openai') { - if (GEMINI_SEARCH_MODELS.includes(model?.id) || isOpenAIWebSearchModel(model)) { + if (GEMINI_SEARCH_MODELS.includes(baseName) || isOpenAIWebSearchModel(model)) { return true } } if (provider.id === 'gemini' || provider?.type === 'gemini') { - return GEMINI_SEARCH_MODELS.includes(model?.id) + return GEMINI_SEARCH_MODELS.includes(baseName) } if (provider.id === 'hunyuan') { - return model?.id !== 'hunyuan-lite' + return baseName !== 'hunyuan-lite' } if (provider.id === 'zhipu') { - return model?.id?.startsWith('glm-4-') + return baseName?.startsWith('glm-4-') } if (provider.id === 'dashscope') { const models = ['qwen-turbo', 'qwen-max', 'qwen-plus', 'qwq'] // matches id like qwen-max-0919, qwen-max-latest - return models.some((i) => model.id.startsWith(i)) + return models.some((i) => baseName.startsWith(i)) } if (provider.id === 'openrouter') { @@ -2685,7 +2687,9 @@ export function isGenerateImageModel(model: Model): boolean { if (isEmbedding) { return false } - if (GENERATE_IMAGE_MODELS.includes(model.id)) { + + const baseName = getBaseModelName(model.id, '/').toLowerCase() + if (GENERATE_IMAGE_MODELS.includes(baseName)) { return true } return false