Skip to content

The agent engineering platform.

VertexAI LLM count_tokens method requires list of prompts (#13451)

Stijn Tratsaertb6f70d776b5b
diff --git a/libs/langchain/langchain/llms/vertexai.py b/libs/langchain/langchain/llms/vertexai.py
index f2f95035ac..fd6b31f40e 100644
--- a/libs/langchain/langchain/llms/vertexai.py
+++ b/libs/langchain/langchain/llms/vertexai.py
@@ -288,7 +288,7 @@ class VertexAI(_VertexAICommon, BaseLLM):
The integer number of tokens in the text.
"""
try:
- result = self.client.count_tokens(text)
+ result = self.client.count_tokens([text])
except AttributeError:
raise NotImplementedError(
"Your google-cloud-aiplatform version didn't implement count_tokens."