Skip to content

Commit d3daf54

Browse files
committed
fix instruction
1 parent f97f553 commit d3daf54

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/config/modelProviders/vertexai.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const VertexAI: ModelProviderCard = {
1111
name: 'VertexAI',
1212
settings: {
1313
disableBrowserRequest: true,
14+
showModelFetcher: false,
1415
smoothing: {
15-
speed: 2,
1616
text: true,
1717
},
1818
},

src/libs/agent-runtime/google/index.ts

+19-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
SchemaType,
1111
} from '@google/generative-ai';
1212

13-
import { VertexAIStream } from '@/libs/agent-runtime/utils/streams/vertex-ai';
1413
import type { ChatModelCard } from '@/types/llm';
1514
import { imageUrlToBase64 } from '@/utils/imageToBase64';
1615
import { safeParseJSON } from '@/utils/safeParseJSON';
@@ -28,11 +27,24 @@ import { ModelProvider } from '../types/type';
2827
import { AgentRuntimeError } from '../utils/createError';
2928
import { debugStream } from '../utils/debugStream';
3029
import { StreamingResponse } from '../utils/response';
31-
import { GoogleGenerativeAIStream, convertIterableToStream } from '../utils/streams';
30+
import {
31+
GoogleGenerativeAIStream,
32+
VertexAIStream,
33+
convertIterableToStream,
34+
} from '../utils/streams';
3235
import { parseDataUri } from '../utils/uriParser';
3336

3437
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+
]);
3648

3749
export interface GoogleModelCard {
3850
displayName: string;
@@ -97,9 +109,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {
97109
generationConfig: {
98110
maxOutputTokens: payload.max_tokens,
99111
// @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,
103113
temperature: payload.temperature,
104114
topP: payload.top_p,
105115
},
@@ -129,7 +139,9 @@ export class LobeGoogleAI implements LobeRuntimeAI {
129139
)
130140
.generateContentStream({
131141
contents,
132-
systemInstruction: payload.system as string,
142+
systemInstruction: modelsDisableInstuction.has(model)
143+
? undefined
144+
: (payload.system as string),
133145
tools: this.buildGoogleTools(payload.tools, payload),
134146
});
135147

src/libs/agent-runtime/utils/streams/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export * from './openai';
66
export * from './protocol';
77
export * from './qwen';
88
export * from './spark';
9+
export * from './vertex-ai';

0 commit comments

Comments
 (0)