langchain-ai / langchain-cohere

MIT License
16 stars 15 forks source link

The usage shown in the source code and docs is invalid and the completion_with_retry have argument bug in llms.py (tested 0.14) #44

Open simongcc opened 2 months ago

simongcc commented 2 months ago

According to the Document in LangChain - Cohere The usage for LLM is

from langchain_cohere import Cohere

It is same as stated in the source code's comment. However, if use accordingly, the error will be

# ImportError: cannot import name 'Cohere' from 'langchain_cohere' (/Users/user-cloaked/miniforge3/envs/langchain/lib/python3.11/site-packages/langchain_cohere/__init__.py)

According to the structure of the source code, the actual working method seems to be:

from langchain_cohere.llms import Cohere

Assume that this usage is the actual way. There is a bug inside the llms.py

If calling the Cohere according to manual, should be something like this

model = Cohere(model="command", max_tokens=256, temperature=0.75)

However, it will generate error like this

# TypeError: langchain_cohere.llms.completion_with_retry() got multiple values for keyword argument 'model'

Because when running completion_with_retry(), self.model is provided instead of model i.e. it didn't allow to specify any model in other words I am not sure if it is intended to do so or just a copy and paste error, the async also have to same problem by reading the source code without running.

So the final working writing at the moment is

from langchain_cohere.llms import Cohere
model = Cohere(max_tokens=256, temperature=0.75)
# ...
julfr commented 1 month ago

I have the same problem. Are any news here?