Skip to content

Commit

Permalink
feat (provider/google): add cachedContent optional setting (#2261)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel authored Jul 12, 2024
1 parent 4dfe0b0 commit 2e59d26
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-donkeys-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ai-sdk/google': patch
---

feat (provider/google): add cachedContent optional setting
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ The following optional settings are available for Google Generative AI models:
Top-k sampling considers the set of topK most probable tokens.
Models running with nucleus sampling don't allow topK setting.

- **cachedContent** _string_

Optional. The name of the cached content used as context to serve the prediction.
Format: cachedContents/{cachedContent}

- **safetySettings** _Array\<\{ category: string; threshold: string \}\>_

Optional. Safety settings for the model.
Expand Down
3 changes: 3 additions & 0 deletions packages/google/src/google-generative-ai-language-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV1 {
systemInstruction,
safetySettings: this.settings.safetySettings,
...prepareToolsAndToolConfig(mode),
cachedContent: this.settings.cachedContent,
},
warnings,
};
Expand All @@ -125,6 +126,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV1 {
contents,
systemInstruction,
safetySettings: this.settings.safetySettings,
cachedContent: this.settings.cachedContent,
},
warnings,
};
Expand All @@ -146,6 +148,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV1 {
},
toolConfig: { functionCallingConfig: { mode: 'ANY' } },
safetySettings: this.settings.safetySettings,
cachedContent: this.settings.cachedContent,
},
warnings,
};
Expand Down
7 changes: 7 additions & 0 deletions packages/google/src/google-generative-ai-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Models running with nucleus sampling don't allow topK setting.
*/
topK?: number;

/**
Optional.
The name of the cached content used as context to serve the prediction.
Format: cachedContents/{cachedContent}
*/
cachedContent?: string;

/**
Optional. A list of unique safety settings for blocking unsafe content.
*/
Expand Down

0 comments on commit 2e59d26

Please sign in to comment.