Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-mangos-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/vertexai': patch
---

Pass `GenerativeModel`'s `BaseParams` to created chat sessions. This fixes an issue where `GenerationConfig` would not be inherited from `ChatSession`.
29 changes: 29 additions & 0 deletions packages/vertexai/src/models/generative-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,35 @@ describe('GenerativeModel', () => {
);
restore();
});
it('passes base model params through to ChatSession when there are no startChatParams', async () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
generationConfig: {
topK: 1
}
});
const chatSession = genModel.startChat();
expect(chatSession.params?.generationConfig).to.deep.equal({
topK: 1
});
restore();
});
it('overrides base model params with startChatParams', () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
generationConfig: {
topK: 1
}
});
const chatSession = genModel.startChat({
generationConfig: {
topK: 2
}
});
expect(chatSession.params?.generationConfig).to.deep.equal({
topK: 2
});
});
it('passes params through to chat.sendMessage', async () => {
const genModel = new GenerativeModel(fakeVertexAI, {
model: 'my-model',
Expand Down
7 changes: 7 additions & 0 deletions packages/vertexai/src/models/generative-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ export class GenerativeModel extends VertexAIModel {
tools: this.tools,
toolConfig: this.toolConfig,
systemInstruction: this.systemInstruction,
generationConfig: this.generationConfig,
safetySettings: this.safetySettings,
/**
* Overrides params inherited from GenerativeModel with those explicitly set in the
* StartChatParams. For example, if startChatParams.generationConfig is set, it'll override
* this.generationConfig.
*/
...startChatParams
},
this.requestOptions
Expand Down
Loading