From caa57fc4bfd9b64f552130c0830428fa4d1f93c2 Mon Sep 17 00:00:00 2001 From: junyanxu Date: Wed, 25 Sep 2024 22:41:02 +0000 Subject: [PATCH 1/5] Add frequencePenalty and presencePenalty parameters support for generate content. --- .changeset/cyan-pants-move.md | 5 +++++ common/api-review/generative-ai.api.md | 8 ++++++++ .../generative-ai.baseparams.frequencepenalty.md | 11 +++++++++++ docs/reference/main/generative-ai.baseparams.md | 2 ++ .../generative-ai.baseparams.presencepenalty.md | 11 +++++++++++ ...nerative-ai.generativemodel.frequencypenalty.md | 11 +++++++++++ .../main/generative-ai.generativemodel.md | 2 ++ ...enerative-ai.generativemodel.presencepenalty.md | 11 +++++++++++ src/methods/generate-content.test.ts | 2 ++ src/models/generative-model.test.ts | 14 ++++++++++++-- src/models/generative-model.ts | 10 ++++++++++ types/requests.ts | 6 ++++++ 12 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 .changeset/cyan-pants-move.md create mode 100644 docs/reference/main/generative-ai.baseparams.frequencepenalty.md create mode 100644 docs/reference/main/generative-ai.baseparams.presencepenalty.md create mode 100644 docs/reference/main/generative-ai.generativemodel.frequencypenalty.md create mode 100644 docs/reference/main/generative-ai.generativemodel.presencepenalty.md diff --git a/.changeset/cyan-pants-move.md b/.changeset/cyan-pants-move.md new file mode 100644 index 00000000..d6cf9710 --- /dev/null +++ b/.changeset/cyan-pants-move.md @@ -0,0 +1,5 @@ +--- +"@google/generative-ai": minor +--- + +Add frequencePenalty and presencePenalty parameters support for generate content. diff --git a/common/api-review/generative-ai.api.md b/common/api-review/generative-ai.api.md index b9cea757..3effc378 100644 --- a/common/api-review/generative-ai.api.md +++ b/common/api-review/generative-ai.api.md @@ -6,9 +6,13 @@ // @public export interface BaseParams { + // (undocumented) + frequencePenalty?: number; // (undocumented) generationConfig?: GenerationConfig; // (undocumented) + presencePenalty?: number; + // (undocumented) safetySettings?: SafetySetting[]; } @@ -458,6 +462,8 @@ export class GenerativeModel { cachedContent: CachedContent; countTokens(request: CountTokensRequest | string | Array, requestOptions?: SingleRequestOptions): Promise; embedContent(request: EmbedContentRequest | string | Array, requestOptions?: SingleRequestOptions): Promise; + // (undocumented) + frequencyPenalty?: number; generateContent(request: GenerateContentRequest | string | Array, requestOptions?: SingleRequestOptions): Promise; generateContentStream(request: GenerateContentRequest | string | Array, requestOptions?: SingleRequestOptions): Promise; // (undocumented) @@ -465,6 +471,8 @@ export class GenerativeModel { // (undocumented) model: string; // (undocumented) + presencePenalty?: number; + // (undocumented) safetySettings: SafetySetting[]; startChat(startChatParams?: StartChatParams): ChatSession; // (undocumented) diff --git a/docs/reference/main/generative-ai.baseparams.frequencepenalty.md b/docs/reference/main/generative-ai.baseparams.frequencepenalty.md new file mode 100644 index 00000000..402d7671 --- /dev/null +++ b/docs/reference/main/generative-ai.baseparams.frequencepenalty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [BaseParams](./generative-ai.baseparams.md) > [frequencePenalty](./generative-ai.baseparams.frequencepenalty.md) + +## BaseParams.frequencePenalty property + +**Signature:** + +```typescript +frequencePenalty?: number; +``` diff --git a/docs/reference/main/generative-ai.baseparams.md b/docs/reference/main/generative-ai.baseparams.md index ea3fb2be..e5404a9a 100644 --- a/docs/reference/main/generative-ai.baseparams.md +++ b/docs/reference/main/generative-ai.baseparams.md @@ -16,6 +16,8 @@ export interface BaseParams | Property | Modifiers | Type | Description | | --- | --- | --- | --- | +| [frequencePenalty?](./generative-ai.baseparams.frequencepenalty.md) | | number | _(Optional)_ | | [generationConfig?](./generative-ai.baseparams.generationconfig.md) | | [GenerationConfig](./generative-ai.generationconfig.md) | _(Optional)_ | +| [presencePenalty?](./generative-ai.baseparams.presencepenalty.md) | | number | _(Optional)_ | | [safetySettings?](./generative-ai.baseparams.safetysettings.md) | | [SafetySetting](./generative-ai.safetysetting.md)\[\] | _(Optional)_ | diff --git a/docs/reference/main/generative-ai.baseparams.presencepenalty.md b/docs/reference/main/generative-ai.baseparams.presencepenalty.md new file mode 100644 index 00000000..b12c5c67 --- /dev/null +++ b/docs/reference/main/generative-ai.baseparams.presencepenalty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [BaseParams](./generative-ai.baseparams.md) > [presencePenalty](./generative-ai.baseparams.presencepenalty.md) + +## BaseParams.presencePenalty property + +**Signature:** + +```typescript +presencePenalty?: number; +``` diff --git a/docs/reference/main/generative-ai.generativemodel.frequencypenalty.md b/docs/reference/main/generative-ai.generativemodel.frequencypenalty.md new file mode 100644 index 00000000..72b29ae5 --- /dev/null +++ b/docs/reference/main/generative-ai.generativemodel.frequencypenalty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [GenerativeModel](./generative-ai.generativemodel.md) > [frequencyPenalty](./generative-ai.generativemodel.frequencypenalty.md) + +## GenerativeModel.frequencyPenalty property + +**Signature:** + +```typescript +frequencyPenalty?: number; +``` diff --git a/docs/reference/main/generative-ai.generativemodel.md b/docs/reference/main/generative-ai.generativemodel.md index 546e68d6..0b6e5500 100644 --- a/docs/reference/main/generative-ai.generativemodel.md +++ b/docs/reference/main/generative-ai.generativemodel.md @@ -24,8 +24,10 @@ export declare class GenerativeModel | --- | --- | --- | --- | | [apiKey](./generative-ai.generativemodel.apikey.md) | | string | | | [cachedContent](./generative-ai.generativemodel.cachedcontent.md) | | [CachedContent](./generative-ai.cachedcontent.md) | | +| [frequencyPenalty?](./generative-ai.generativemodel.frequencypenalty.md) | | number | _(Optional)_ | | [generationConfig](./generative-ai.generativemodel.generationconfig.md) | | [GenerationConfig](./generative-ai.generationconfig.md) | | | [model](./generative-ai.generativemodel.model.md) | | string | | +| [presencePenalty?](./generative-ai.generativemodel.presencepenalty.md) | | number | _(Optional)_ | | [safetySettings](./generative-ai.generativemodel.safetysettings.md) | | [SafetySetting](./generative-ai.safetysetting.md)\[\] | | | [systemInstruction?](./generative-ai.generativemodel.systeminstruction.md) | | [Content](./generative-ai.content.md) | _(Optional)_ | | [toolConfig?](./generative-ai.generativemodel.toolconfig.md) | | [ToolConfig](./generative-ai.toolconfig.md) | _(Optional)_ | diff --git a/docs/reference/main/generative-ai.generativemodel.presencepenalty.md b/docs/reference/main/generative-ai.generativemodel.presencepenalty.md new file mode 100644 index 00000000..746b79da --- /dev/null +++ b/docs/reference/main/generative-ai.generativemodel.presencepenalty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [GenerativeModel](./generative-ai.generativemodel.md) > [presencePenalty](./generative-ai.generativemodel.presencepenalty.md) + +## GenerativeModel.presencePenalty property + +**Signature:** + +```typescript +presencePenalty?: number; +``` diff --git a/src/methods/generate-content.test.ts b/src/methods/generate-content.test.ts index 5f49dc15..12b74b2b 100644 --- a/src/methods/generate-content.test.ts +++ b/src/methods/generate-content.test.ts @@ -42,6 +42,8 @@ const fakeRequestParams: GenerateContentRequest = { threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, }, ], + presencePenalty: 0.5, + frequencePenalty: 0.1, }; describe("generateContent()", () => { diff --git a/src/models/generative-model.test.ts b/src/models/generative-model.test.ts index 6e82ba8c..5a48bbba 100644 --- a/src/models/generative-model.test.ts +++ b/src/models/generative-model.test.ts @@ -71,6 +71,8 @@ describe("GenerativeModel", () => { threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, }, ], + presencePenalty: 0.6, + frequencePenalty: 0.5, tools: [{ functionDeclarations: [{ name: "myfunc" }] }], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE }, @@ -92,6 +94,8 @@ describe("GenerativeModel", () => { genModel.generationConfig?.responseSchema.properties.testField.type, ).to.equal(SchemaType.STRING); expect(genModel.safetySettings?.length).to.equal(1); + expect(genModel.presencePenalty).to.equal(0.6); + expect(genModel.frequencyPenalty).to.equal(0.5); expect(genModel.tools?.length).to.equal(1); expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal( FunctionCallingMode.NONE, @@ -116,7 +120,9 @@ describe("GenerativeModel", () => { value.includes("be friendly") && value.includes("temperature") && value.includes("testField") && - value.includes(HarmBlockThreshold.BLOCK_LOW_AND_ABOVE) + value.includes(HarmBlockThreshold.BLOCK_LOW_AND_ABOVE) && + value.includes("presencePenalty") && + value.includes("frequencePenalty") ); }), match((value) => { @@ -210,6 +216,8 @@ describe("GenerativeModel", () => { threshold: HarmBlockThreshold.BLOCK_NONE, }, ], + presencePenalty: 0.6, + frequencePenalty: 0.5, contents: [{ role: "user", parts: [{ text: "hello" }] }], tools: [{ functionDeclarations: [{ name: "otherfunc" }] }], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.AUTO } }, @@ -228,7 +236,9 @@ describe("GenerativeModel", () => { value.includes("topK") && value.includes("newTestField") && !value.includes("testField") && - value.includes(HarmCategory.HARM_CATEGORY_HARASSMENT) + value.includes(HarmCategory.HARM_CATEGORY_HARASSMENT) && + value.includes("presencePenalty") && + value.includes("frequencePenalty") ); }), {}, diff --git a/src/models/generative-model.ts b/src/models/generative-model.ts index 7cd3fe62..a08ef401 100644 --- a/src/models/generative-model.ts +++ b/src/models/generative-model.ts @@ -63,6 +63,8 @@ export class GenerativeModel { toolConfig?: ToolConfig; systemInstruction?: Content; cachedContent: CachedContent; + presencePenalty?: number; + frequencyPenalty?: number; constructor( public apiKey: string, @@ -84,6 +86,8 @@ export class GenerativeModel { modelParams.systemInstruction, ); this.cachedContent = modelParams.cachedContent; + this.presencePenalty = modelParams.presencePenalty; + this.frequencyPenalty = modelParams.frequencePenalty; } /** @@ -113,6 +117,8 @@ export class GenerativeModel { toolConfig: this.toolConfig, systemInstruction: this.systemInstruction, cachedContent: this.cachedContent?.name, + presencePenalty: this.presencePenalty, + frequencePenalty: this.frequencyPenalty, ...formattedParams, }, generativeModelRequestOptions, @@ -148,6 +154,8 @@ export class GenerativeModel { toolConfig: this.toolConfig, systemInstruction: this.systemInstruction, cachedContent: this.cachedContent?.name, + presencePenalty: this.presencePenalty, + frequencePenalty: this.frequencyPenalty, ...formattedParams, }, generativeModelRequestOptions, @@ -194,6 +202,8 @@ export class GenerativeModel { toolConfig: this.toolConfig, systemInstruction: this.systemInstruction, cachedContent: this.cachedContent, + presencePenalty: this.presencePenalty, + frequencePenalty: this.frequencyPenalty, }); const generativeModelRequestOptions: SingleRequestOptions = { ...this._requestOptions, diff --git a/types/requests.ts b/types/requests.ts index 4eec1e9c..321f3fab 100644 --- a/types/requests.ts +++ b/types/requests.ts @@ -31,6 +31,12 @@ import { export interface BaseParams { safetySettings?: SafetySetting[]; generationConfig?: GenerationConfig; + // Presence penalty applied to the next token's logprobs if the token has + // already been seen in the response. + presencePenalty?: number + // Frequency penalty applied to the next token's logprobs, multiplied by the + // number of times each token has been seen in the respponse so far. + frequencePenalty?: number } /** From 75be7c36eae16d40c64c15e6ec049cc2f304305d Mon Sep 17 00:00:00 2001 From: junyanxu Date: Wed, 25 Sep 2024 23:36:39 +0000 Subject: [PATCH 2/5] Change frequence to frequency --- .changeset/cyan-pants-move.md | 2 +- common/api-review/generative-ai.api.md | 2 +- ...ty.md => generative-ai.baseparams.frequencypenalty.md} | 6 +++--- docs/reference/main/generative-ai.baseparams.md | 2 +- src/models/generative-model.test.ts | 8 ++++---- src/models/generative-model.ts | 8 ++++---- types/requests.ts | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) rename docs/reference/main/{generative-ai.baseparams.frequencepenalty.md => generative-ai.baseparams.frequencypenalty.md} (63%) diff --git a/.changeset/cyan-pants-move.md b/.changeset/cyan-pants-move.md index d6cf9710..b15819bb 100644 --- a/.changeset/cyan-pants-move.md +++ b/.changeset/cyan-pants-move.md @@ -2,4 +2,4 @@ "@google/generative-ai": minor --- -Add frequencePenalty and presencePenalty parameters support for generate content. +Add frequencyPenalty and presencePenalty parameters support for generate content. diff --git a/common/api-review/generative-ai.api.md b/common/api-review/generative-ai.api.md index 3effc378..29800860 100644 --- a/common/api-review/generative-ai.api.md +++ b/common/api-review/generative-ai.api.md @@ -7,7 +7,7 @@ // @public export interface BaseParams { // (undocumented) - frequencePenalty?: number; + frequencyPenalty?: number; // (undocumented) generationConfig?: GenerationConfig; // (undocumented) diff --git a/docs/reference/main/generative-ai.baseparams.frequencepenalty.md b/docs/reference/main/generative-ai.baseparams.frequencypenalty.md similarity index 63% rename from docs/reference/main/generative-ai.baseparams.frequencepenalty.md rename to docs/reference/main/generative-ai.baseparams.frequencypenalty.md index 402d7671..10115b0e 100644 --- a/docs/reference/main/generative-ai.baseparams.frequencepenalty.md +++ b/docs/reference/main/generative-ai.baseparams.frequencypenalty.md @@ -1,11 +1,11 @@ -[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [BaseParams](./generative-ai.baseparams.md) > [frequencePenalty](./generative-ai.baseparams.frequencepenalty.md) +[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [BaseParams](./generative-ai.baseparams.md) > [frequencyPenalty](./generative-ai.baseparams.frequencypenalty.md) -## BaseParams.frequencePenalty property +## BaseParams.frequencyPenalty property **Signature:** ```typescript -frequencePenalty?: number; +frequencyPenalty?: number; ``` diff --git a/docs/reference/main/generative-ai.baseparams.md b/docs/reference/main/generative-ai.baseparams.md index e5404a9a..ee567d98 100644 --- a/docs/reference/main/generative-ai.baseparams.md +++ b/docs/reference/main/generative-ai.baseparams.md @@ -16,7 +16,7 @@ export interface BaseParams | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [frequencePenalty?](./generative-ai.baseparams.frequencepenalty.md) | | number | _(Optional)_ | +| [frequencyPenalty?](./generative-ai.baseparams.frequencypenalty.md) | | number | _(Optional)_ | | [generationConfig?](./generative-ai.baseparams.generationconfig.md) | | [GenerationConfig](./generative-ai.generationconfig.md) | _(Optional)_ | | [presencePenalty?](./generative-ai.baseparams.presencepenalty.md) | | number | _(Optional)_ | | [safetySettings?](./generative-ai.baseparams.safetysettings.md) | | [SafetySetting](./generative-ai.safetysetting.md)\[\] | _(Optional)_ | diff --git a/src/models/generative-model.test.ts b/src/models/generative-model.test.ts index 5a48bbba..3ab03872 100644 --- a/src/models/generative-model.test.ts +++ b/src/models/generative-model.test.ts @@ -72,7 +72,7 @@ describe("GenerativeModel", () => { }, ], presencePenalty: 0.6, - frequencePenalty: 0.5, + frequencyPenalty: 0.5, tools: [{ functionDeclarations: [{ name: "myfunc" }] }], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE }, @@ -122,7 +122,7 @@ describe("GenerativeModel", () => { value.includes("testField") && value.includes(HarmBlockThreshold.BLOCK_LOW_AND_ABOVE) && value.includes("presencePenalty") && - value.includes("frequencePenalty") + value.includes("frequencyPenalty") ); }), match((value) => { @@ -217,7 +217,7 @@ describe("GenerativeModel", () => { }, ], presencePenalty: 0.6, - frequencePenalty: 0.5, + frequencyPenalty: 0.5, contents: [{ role: "user", parts: [{ text: "hello" }] }], tools: [{ functionDeclarations: [{ name: "otherfunc" }] }], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.AUTO } }, @@ -238,7 +238,7 @@ describe("GenerativeModel", () => { !value.includes("testField") && value.includes(HarmCategory.HARM_CATEGORY_HARASSMENT) && value.includes("presencePenalty") && - value.includes("frequencePenalty") + value.includes("frequencyPenalty") ); }), {}, diff --git a/src/models/generative-model.ts b/src/models/generative-model.ts index a08ef401..2c584b42 100644 --- a/src/models/generative-model.ts +++ b/src/models/generative-model.ts @@ -87,7 +87,7 @@ export class GenerativeModel { ); this.cachedContent = modelParams.cachedContent; this.presencePenalty = modelParams.presencePenalty; - this.frequencyPenalty = modelParams.frequencePenalty; + this.frequencyPenalty = modelParams.frequencyPenalty; } /** @@ -118,7 +118,7 @@ export class GenerativeModel { systemInstruction: this.systemInstruction, cachedContent: this.cachedContent?.name, presencePenalty: this.presencePenalty, - frequencePenalty: this.frequencyPenalty, + frequencyPenalty: this.frequencyPenalty, ...formattedParams, }, generativeModelRequestOptions, @@ -155,7 +155,7 @@ export class GenerativeModel { systemInstruction: this.systemInstruction, cachedContent: this.cachedContent?.name, presencePenalty: this.presencePenalty, - frequencePenalty: this.frequencyPenalty, + frequencyPenalty: this.frequencyPenalty, ...formattedParams, }, generativeModelRequestOptions, @@ -203,7 +203,7 @@ export class GenerativeModel { systemInstruction: this.systemInstruction, cachedContent: this.cachedContent, presencePenalty: this.presencePenalty, - frequencePenalty: this.frequencyPenalty, + frequencyPenalty: this.frequencyPenalty, }); const generativeModelRequestOptions: SingleRequestOptions = { ...this._requestOptions, diff --git a/types/requests.ts b/types/requests.ts index 321f3fab..6e3fcdf2 100644 --- a/types/requests.ts +++ b/types/requests.ts @@ -36,7 +36,7 @@ export interface BaseParams { presencePenalty?: number // Frequency penalty applied to the next token's logprobs, multiplied by the // number of times each token has been seen in the respponse so far. - frequencePenalty?: number + frequencyPenalty?: number } /** From ef688bd034cab5896f44fbe23a10d80e7e57cb64 Mon Sep 17 00:00:00 2001 From: junyanxu Date: Wed, 25 Sep 2024 23:41:21 +0000 Subject: [PATCH 3/5] Update format --- .changeset/cyan-pants-move.md | 2 +- src/methods/generate-content.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/cyan-pants-move.md b/.changeset/cyan-pants-move.md index b15819bb..e12e83b1 100644 --- a/.changeset/cyan-pants-move.md +++ b/.changeset/cyan-pants-move.md @@ -2,4 +2,4 @@ "@google/generative-ai": minor --- -Add frequencyPenalty and presencePenalty parameters support for generate content. +Add `frequencyPenalty` and `presencePenalty` parameters support for `generateContent()` diff --git a/src/methods/generate-content.test.ts b/src/methods/generate-content.test.ts index 12b74b2b..964ce8f8 100644 --- a/src/methods/generate-content.test.ts +++ b/src/methods/generate-content.test.ts @@ -43,7 +43,7 @@ const fakeRequestParams: GenerateContentRequest = { }, ], presencePenalty: 0.5, - frequencePenalty: 0.1, + frequencyPenalty: 0.1, }; describe("generateContent()", () => { From 8be7537c2c3df54241679aef43b138c16602e689 Mon Sep 17 00:00:00 2001 From: junyanxu Date: Wed, 25 Sep 2024 23:44:34 +0000 Subject: [PATCH 4/5] Update parameter description --- common/api-review/generative-ai.api.md | 2 -- .../generative-ai.baseparams.frequencypenalty.md | 2 ++ docs/reference/main/generative-ai.baseparams.md | 4 ++-- .../main/generative-ai.baseparams.presencepenalty.md | 2 ++ types/requests.ts | 12 ++++++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/api-review/generative-ai.api.md b/common/api-review/generative-ai.api.md index 29800860..0a3e8470 100644 --- a/common/api-review/generative-ai.api.md +++ b/common/api-review/generative-ai.api.md @@ -6,11 +6,9 @@ // @public export interface BaseParams { - // (undocumented) frequencyPenalty?: number; // (undocumented) generationConfig?: GenerationConfig; - // (undocumented) presencePenalty?: number; // (undocumented) safetySettings?: SafetySetting[]; diff --git a/docs/reference/main/generative-ai.baseparams.frequencypenalty.md b/docs/reference/main/generative-ai.baseparams.frequencypenalty.md index 10115b0e..2eeb1048 100644 --- a/docs/reference/main/generative-ai.baseparams.frequencypenalty.md +++ b/docs/reference/main/generative-ai.baseparams.frequencypenalty.md @@ -4,6 +4,8 @@ ## BaseParams.frequencyPenalty property +Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far. + **Signature:** ```typescript diff --git a/docs/reference/main/generative-ai.baseparams.md b/docs/reference/main/generative-ai.baseparams.md index ee567d98..ed893b38 100644 --- a/docs/reference/main/generative-ai.baseparams.md +++ b/docs/reference/main/generative-ai.baseparams.md @@ -16,8 +16,8 @@ export interface BaseParams | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [frequencyPenalty?](./generative-ai.baseparams.frequencypenalty.md) | | number | _(Optional)_ | +| [frequencyPenalty?](./generative-ai.baseparams.frequencypenalty.md) | | number | _(Optional)_ Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far. | | [generationConfig?](./generative-ai.baseparams.generationconfig.md) | | [GenerationConfig](./generative-ai.generationconfig.md) | _(Optional)_ | -| [presencePenalty?](./generative-ai.baseparams.presencepenalty.md) | | number | _(Optional)_ | +| [presencePenalty?](./generative-ai.baseparams.presencepenalty.md) | | number | _(Optional)_ Presence penalty applied to the next token's logprobs if the token has already been seen in the response. | | [safetySettings?](./generative-ai.baseparams.safetysettings.md) | | [SafetySetting](./generative-ai.safetysetting.md)\[\] | _(Optional)_ | diff --git a/docs/reference/main/generative-ai.baseparams.presencepenalty.md b/docs/reference/main/generative-ai.baseparams.presencepenalty.md index b12c5c67..8e212786 100644 --- a/docs/reference/main/generative-ai.baseparams.presencepenalty.md +++ b/docs/reference/main/generative-ai.baseparams.presencepenalty.md @@ -4,6 +4,8 @@ ## BaseParams.presencePenalty property +Presence penalty applied to the next token's logprobs if the token has already been seen in the response. + **Signature:** ```typescript diff --git a/types/requests.ts b/types/requests.ts index 6e3fcdf2..4f99b553 100644 --- a/types/requests.ts +++ b/types/requests.ts @@ -31,11 +31,15 @@ import { export interface BaseParams { safetySettings?: SafetySetting[]; generationConfig?: GenerationConfig; - // Presence penalty applied to the next token's logprobs if the token has - // already been seen in the response. + /** + * Presence penalty applied to the next token's logprobs if the token has + * already been seen in the response. + */ presencePenalty?: number - // Frequency penalty applied to the next token's logprobs, multiplied by the - // number of times each token has been seen in the respponse so far. + /** + * Frequency penalty applied to the next token's logprobs, multiplied by the + * number of times each token has been seen in the respponse so far. + */ frequencyPenalty?: number } From 00216ce8a7872783809b8ada504f4b02b81367e3 Mon Sep 17 00:00:00 2001 From: junyanxu Date: Wed, 25 Sep 2024 23:47:22 +0000 Subject: [PATCH 5/5] Update the parameter doc. --- types/requests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/requests.ts b/types/requests.ts index 4f99b553..4b8068d4 100644 --- a/types/requests.ts +++ b/types/requests.ts @@ -34,12 +34,12 @@ export interface BaseParams { /** * Presence penalty applied to the next token's logprobs if the token has * already been seen in the response. - */ + */ presencePenalty?: number /** * Frequency penalty applied to the next token's logprobs, multiplied by the * number of times each token has been seen in the respponse so far. - */ + */ frequencyPenalty?: number }