Skip to content

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

@simongcc

Description

@simongcc

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)
# ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions