mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +03:00
Feat/add thinking budget to gemini (#5395)
add thinking budget to gemini
This commit is contained in:
+16
@@ -174,6 +174,9 @@ export interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick<G
|
||||
* - Gemini 1.0 Pro version gemini-1.0-pro-002
|
||||
*/
|
||||
convertSystemMessageToHumanContent?: boolean | undefined
|
||||
|
||||
/** Thinking budget for Gemini 2.5 thinking models. Supports -1 (dynamic), 0 (off), or positive integers. */
|
||||
thinkingBudget?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -599,6 +602,8 @@ export class LangchainChatGoogleGenerativeAI
|
||||
|
||||
convertSystemMessageToHumanContent: boolean | undefined
|
||||
|
||||
thinkingBudget?: number
|
||||
|
||||
private client: GenerativeModel
|
||||
|
||||
get _isMultimodalModel() {
|
||||
@@ -657,6 +662,7 @@ export class LangchainChatGoogleGenerativeAI
|
||||
|
||||
this.streaming = fields.streaming ?? this.streaming
|
||||
this.json = fields.json
|
||||
this.thinkingBudget = fields.thinkingBudget
|
||||
|
||||
this.client = new GenerativeAI(this.apiKey).getGenerativeModel(
|
||||
{
|
||||
@@ -676,12 +682,22 @@ export class LangchainChatGoogleGenerativeAI
|
||||
baseUrl: fields.baseUrl
|
||||
}
|
||||
)
|
||||
if (this.thinkingBudget !== undefined) {
|
||||
;(this.client.generationConfig as any).thinkingConfig = {
|
||||
...(this.thinkingBudget !== undefined ? { thinkingBudget: this.thinkingBudget } : {})
|
||||
}
|
||||
}
|
||||
this.streamUsage = fields.streamUsage ?? this.streamUsage
|
||||
}
|
||||
|
||||
useCachedContent(cachedContent: CachedContent, modelParams?: ModelParams, requestOptions?: RequestOptions): void {
|
||||
if (!this.apiKey) return
|
||||
this.client = new GenerativeAI(this.apiKey).getGenerativeModelFromCachedContent(cachedContent, modelParams, requestOptions)
|
||||
if (this.thinkingBudget !== undefined) {
|
||||
;(this.client.generationConfig as any).thinkingConfig = {
|
||||
...(this.thinkingBudget !== undefined ? { thinkingBudget: this.thinkingBudget } : {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get useSystemInstruction(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user