Skip to content

The agent engineering platform.

community[patch]: Replace positional argument with text=text for cohere>=5 compatibility (#19407)

billytrend-coheref6bcd424211b
diff --git a/libs/community/langchain_community/chat_models/cohere.py b/libs/community/langchain_community/chat_models/cohere.py
index e3f20ad9c4..7682f1d4ca 100644
--- a/libs/community/langchain_community/chat_models/cohere.py
+++ b/libs/community/langchain_community/chat_models/cohere.py
@@ -244,4 +244,4 @@ class ChatCohere(BaseChatModel, BaseCohere):
def get_num_tokens(self, text: str) -> int:
"""Calculate number of tokens."""
- return len(self.client.tokenize(text).tokens)
+ return len(self.client.tokenize(text=text).tokens)