File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import {
1313 ChatMessageTool ,
1414 usePluginStore ,
1515} from "@/app/store" ;
16- import { streamWithThink } from "@/app/utils/chat" ;
16+ import { preProcessImageContent , streamWithThink } from "@/app/utils/chat" ;
1717import {
1818 ChatOptions ,
1919 getHeaders ,
@@ -25,6 +25,7 @@ import { getClientConfig } from "@/app/config/client";
2525import {
2626 getMessageTextContent ,
2727 getMessageTextContentWithoutThinking ,
28+ isVisionModel ,
2829} from "@/app/utils" ;
2930import { RequestPayload } from "./openai" ;
3031import { fetch } from "@/app/utils/stream" ;
@@ -71,13 +72,16 @@ export class SiliconflowApi implements LLMApi {
7172 }
7273
7374 async chat ( options : ChatOptions ) {
75+ const visionModel = isVisionModel ( options . config . model ) ;
7476 const messages : ChatOptions [ "messages" ] = [ ] ;
7577 for ( const v of options . messages ) {
7678 if ( v . role === "assistant" ) {
7779 const content = getMessageTextContentWithoutThinking ( v ) ;
7880 messages . push ( { role : v . role , content } ) ;
7981 } else {
80- const content = getMessageTextContent ( v ) ;
82+ const content = visionModel
83+ ? await preProcessImageContent ( v . content )
84+ : getMessageTextContent ( v ) ;
8185 messages . push ( { role : v . role , content } ) ;
8286 }
8387 }
Original file line number Diff line number Diff line change @@ -462,6 +462,7 @@ export const VISION_MODEL_REGEXES = [
462462 / g p t - 4 - t u r b o (? ! .* p r e v i e w ) / , // Matches "gpt-4-turbo" but not "gpt-4-turbo-preview"
463463 / ^ d a l l - e - 3 $ / , // Matches exactly "dall-e-3"
464464 / g l m - 4 v / ,
465+ / v l / i,
465466] ;
466467
467468export const EXCLUDE_VISION_MODEL_REGEXES = [ / c l a u d e - 3 - 5 - h a i k u - 2 0 2 4 1 0 2 2 / ] ;
You can’t perform that action at this time.
0 commit comments