Support `getNumTokens` for ChatGoogleGenerativeAI (#4149)
This commit is contained in:
parent
c318fc57e9
commit
654bd48849
|
|
@ -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(
|
async _generateNonStreaming(
|
||||||
prompt: Content[],
|
prompt: Content[],
|
||||||
options: this['ParsedCallOptions'],
|
options: this['ParsedCallOptions'],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue