Skip to content

Commit

Permalink
feat (provider/vertex): support frequencyPenalty setting (#3142)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel authored Sep 27, 2024
1 parent c254a6d commit 33ba542
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-crabs-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ai-sdk/google-vertex': patch
---

feat (provider/vertex): support frequencyPenalty setting
4 changes: 2 additions & 2 deletions packages/google-vertex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
"json-schema": "0.4.0"
},
"devDependencies": {
"@google-cloud/vertexai": "^1.4.0",
"@google-cloud/vertexai": "^1.6.0",
"@types/json-schema": "7.0.15",
"@types/node": "^18",
"@vercel/ai-tsconfig": "workspace:*",
"tsup": "^8",
"typescript": "5.5.4"
},
"peerDependencies": {
"@google-cloud/vertexai": "^1.4.0"
"@google-cloud/vertexai": "^1.6.0"
},
"engines": {
"node": ">=18"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ describe('doGenerate', () => {
expect(mockVertexAI.lastModelParams).toStrictEqual({
model: 'gemini-1.0-pro-002',
generationConfig: {
frequencyPenalty: undefined,
maxOutputTokens: undefined,
responseMimeType: undefined,
temperature: undefined,
Expand Down Expand Up @@ -227,6 +228,7 @@ describe('doGenerate', () => {
maxTokens: 100,
topP: 0.9,
stopSequences: ['abc', 'def'],
frequencyPenalty: 0.15,
});

expect(mockVertexAI.lastModelParams).toStrictEqual({
Expand All @@ -237,6 +239,7 @@ describe('doGenerate', () => {
temperature: 0.5,
topK: 0.1,
topP: 0.9,
frequencyPenalty: 0.15,
stopSequences: ['abc', 'def'],
},
tools: undefined,
Expand All @@ -262,6 +265,7 @@ describe('doGenerate', () => {
expect(mockVertexAI.lastModelParams).toStrictEqual({
model: 'test-model',
generationConfig: {
frequencyPenalty: undefined,
maxOutputTokens: undefined,
responseMimeType: undefined,
stopSequences: undefined,
Expand Down Expand Up @@ -345,6 +349,7 @@ describe('doGenerate', () => {
expect(mockVertexAI.lastModelParams).toStrictEqual({
model: 'test-model',
generationConfig: {
frequencyPenalty: undefined,
maxOutputTokens: undefined,
responseMimeType: 'application/json',
stopSequences: undefined,
Expand Down
8 changes: 1 addition & 7 deletions packages/google-vertex/src/google-vertex-language-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ export class GoogleVertexLanguageModel implements LanguageModelV1 {
}: LanguageModelV1CallOptions) {
const warnings: LanguageModelV1CallWarning[] = [];

if (frequencyPenalty != null) {
warnings.push({
type: 'unsupported-setting',
setting: 'frequencyPenalty',
});
}

if (presencePenalty != null) {
warnings.push({
type: 'unsupported-setting',
Expand Down Expand Up @@ -100,6 +93,7 @@ export class GoogleVertexLanguageModel implements LanguageModelV1 {

// standardized settings:
maxOutputTokens: maxTokens,
frequencyPenalty,
temperature,
topP,
stopSequences,
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 33ba542

Please sign in to comment.