@@ -10,7 +10,6 @@ import {
10
10
SchemaType ,
11
11
} from '@google/generative-ai' ;
12
12
13
- import { VertexAIStream } from '@/libs/agent-runtime/utils/streams/vertex-ai' ;
14
13
import type { ChatModelCard } from '@/types/llm' ;
15
14
import { imageUrlToBase64 } from '@/utils/imageToBase64' ;
16
15
import { safeParseJSON } from '@/utils/safeParseJSON' ;
@@ -28,11 +27,24 @@ import { ModelProvider } from '../types/type';
28
27
import { AgentRuntimeError } from '../utils/createError' ;
29
28
import { debugStream } from '../utils/debugStream' ;
30
29
import { StreamingResponse } from '../utils/response' ;
31
- import { GoogleGenerativeAIStream , convertIterableToStream } from '../utils/streams' ;
30
+ import {
31
+ GoogleGenerativeAIStream ,
32
+ VertexAIStream ,
33
+ convertIterableToStream ,
34
+ } from '../utils/streams' ;
32
35
import { parseDataUri } from '../utils/uriParser' ;
33
36
34
37
const modelsOffSafetySettings = new Set ( [ 'gemini-2.0-flash-exp' ] ) ;
35
- const modelsWithModalities = new Set ( [ 'gemini-2.0-flash-exp' ] ) ;
38
+
39
+ const modelsWithModalities = new Set ( [
40
+ 'gemini-2.0-flash-exp' ,
41
+ 'gemini-2.0-flash-exp-image-generation' ,
42
+ ] ) ;
43
+
44
+ const modelsDisableInstuction = new Set ( [
45
+ 'gemini-2.0-flash-exp' ,
46
+ 'gemini-2.0-flash-exp-image-generation' ,
47
+ ] ) ;
36
48
37
49
export interface GoogleModelCard {
38
50
displayName : string ;
@@ -97,9 +109,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {
97
109
generationConfig : {
98
110
maxOutputTokens : payload . max_tokens ,
99
111
// @ts -expect-error - Google SDK 0.24.0 doesn't have this property for now with
100
- response_modalities : modelsWithModalities . has ( model )
101
- ? [ 'Text' , 'Image' ]
102
- : undefined ,
112
+ response_modalities : modelsWithModalities . has ( model ) ? [ 'Text' , 'Image' ] : undefined ,
103
113
temperature : payload . temperature ,
104
114
topP : payload . top_p ,
105
115
} ,
@@ -129,7 +139,9 @@ export class LobeGoogleAI implements LobeRuntimeAI {
129
139
)
130
140
. generateContentStream ( {
131
141
contents,
132
- systemInstruction : payload . system as string ,
142
+ systemInstruction : modelsDisableInstuction . has ( model )
143
+ ? undefined
144
+ : ( payload . system as string ) ,
133
145
tools : this . buildGoogleTools ( payload . tools , payload ) ,
134
146
} ) ;
135
147
0 commit comments