Skip to content

The agent engineering platform.

Update cohere.py (#795)

bair82ae5695ad3210
diff --git a/langchain/llms/cohere.py b/langchain/llms/cohere.py
index fd7b91067d..adb50ad3cd 100644
--- a/langchain/llms/cohere.py
+++ b/langchain/llms/cohere.py
@@ -122,6 +122,6 @@ class Cohere(LLM, BaseModel):
text = response.generations[0].text
# If stop tokens are provided, Cohere's endpoint returns them.
# In order to make this consistent with other endpoints, we strip them.
- if stop is not None:
- text = enforce_stop_tokens(text, stop)
+ if stop is not None or self.stop is not None:
+ text = enforce_stop_tokens(text, params["stop_sequences"])
return text