Skip to content

Commit 821e265

Browse files
authored
Merge 102fb8c into 080a90d
2 parents 080a90d + 102fb8c commit 821e265

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

.changeset/fast-mangos-chew.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/vertexai': patch
3+
---
4+
5+
Pass `GenerativeModel`'s `BaseParams` to created chat sessions. This fixes an issue where `GenerationConfig` would not be inherited from `ChatSession`.

packages/vertexai/src/models/generative-model.test.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ describe('GenerativeModel', () => {
172172
{ functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] }
173173
],
174174
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
175-
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
175+
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] },
176+
generationConfig: {
177+
topK: 1
178+
}
176179
});
177180
expect(genModel.tools?.length).to.equal(1);
178181
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
@@ -196,7 +199,8 @@ describe('GenerativeModel', () => {
196199
return (
197200
value.includes('myfunc') &&
198201
value.includes(FunctionCallingMode.NONE) &&
199-
value.includes('be friendly')
202+
value.includes('be friendly') &&
203+
value.includes('topK')
200204
);
201205
}),
202206
{}
@@ -236,7 +240,10 @@ describe('GenerativeModel', () => {
236240
{ functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] }
237241
],
238242
toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } },
239-
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] }
243+
systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] },
244+
generationConfig: {
245+
responseMimeType: 'image/jpeg'
246+
}
240247
});
241248
expect(genModel.tools?.length).to.equal(1);
242249
expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal(
@@ -262,7 +269,10 @@ describe('GenerativeModel', () => {
262269
toolConfig: {
263270
functionCallingConfig: { mode: FunctionCallingMode.AUTO }
264271
},
265-
systemInstruction: { role: 'system', parts: [{ text: 'be formal' }] }
272+
systemInstruction: { role: 'system', parts: [{ text: 'be formal' }] },
273+
generationConfig: {
274+
responseMimeType: 'image/png'
275+
}
266276
})
267277
.sendMessage('hello');
268278
expect(makeRequestStub).to.be.calledWith(
@@ -274,7 +284,9 @@ describe('GenerativeModel', () => {
274284
return (
275285
value.includes('otherfunc') &&
276286
value.includes(FunctionCallingMode.AUTO) &&
277-
value.includes('be formal')
287+
value.includes('be formal') &&
288+
value.includes('image/png') &&
289+
!value.includes('image/jpeg')
278290
);
279291
}),
280292
{}

packages/vertexai/src/models/generative-model.ts

+7
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ export class GenerativeModel extends VertexAIModel {
132132
tools: this.tools,
133133
toolConfig: this.toolConfig,
134134
systemInstruction: this.systemInstruction,
135+
generationConfig: this.generationConfig,
136+
safetySettings: this.safetySettings,
137+
/**
138+
* Overrides params inherited from GenerativeModel with those explicitly set in the
139+
* StartChatParams. For example, if startChatParams.generationConfig is set, it'll override
140+
* this.generationConfig.
141+
*/
135142
...startChatParams
136143
},
137144
this.requestOptions

0 commit comments

Comments
 (0)