We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
getNumTokens
1 parent c318fc5 commit 654bd48Copy full SHA for 654bd48
packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts
@@ -209,6 +209,12 @@ class LangchainChatGoogleGenerativeAI
209
}
210
211
212
+ async getNumTokens(prompt: BaseMessage[]) {
213
+ const contents = convertBaseMessagesToContent(prompt, this._isMultimodalModel)
214
+ const { totalTokens } = await this.client.countTokens({ contents })
215
+ return totalTokens
216
+ }
217
+
218
async _generateNonStreaming(
219
prompt: Content[],
220
options: this['ParsedCallOptions'],
0 commit comments