mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 11:01:22 +03:00
Support getNumTokens for ChatGoogleGenerativeAI (#4149)
This commit is contained in:
+6
@@ -209,6 +209,12 @@ class LangchainChatGoogleGenerativeAI
|
||||
}
|
||||
}
|
||||
|
||||
async getNumTokens(prompt: BaseMessage[]) {
|
||||
const contents = convertBaseMessagesToContent(prompt, this._isMultimodalModel)
|
||||
const { totalTokens } = await this.client.countTokens({ contents })
|
||||
return totalTokens
|
||||
}
|
||||
|
||||
async _generateNonStreaming(
|
||||
prompt: Content[],
|
||||
options: this['ParsedCallOptions'],
|
||||
|
||||
Reference in New Issue
Block a user