langchain-ai / langchain-cohere

MIT License
31 stars 20 forks source link

add standard params #52

Closed ccurme closed 3 months ago

ccurme commented 3 months ago

Here we implement a set of parameters that LangChain is standardizing on to simplify integrations with various LLM monitoring platforms (such as Langsmith). These include standard keys for providers, model names, temperature, stop sequences, etc.

ChatCohere is somewhat distinct in that the .model attribute can be None. Because we always require a string for the model name parameter, I also add a property .model_name that will cache the result of ._get_default_model() if .model is None. I took this from the get_num_tokens method and refactored get_num_tokens to use it. I don't actually know if this is the model that is used behind the scenes when model=None!

Note that we will generally now be calling ._get_default_model() (which makes an additional network call) whenever we first invoke ChatCohere after it's instantiated with no value for model.

We also bump langchain-core to 0.2.0. This is needed to support the new parameters. There are no breaking changes in langchain-core from 0.1 to 0.2, but let me know if you think we'd need to update langchain-cohere to 0.2 as well due to this (we have not been doing this in other integration packages).

ccurme commented 3 months ago

Merging as I observe a value for the default model that is consistent with the docs (command-r-plus).

Please let me know if there is an issue with the new model_name property!

cc @harry-cohere