langchain.ChatCohereDataset
kedro_datasets.langchain.ChatCohereDataset ¶
ChatCohereDataset(credentials={}, kwargs={})
Bases: AbstractDataset[None, ChatCohere]
ChatCohereDataset loads a ChatCohere langchain model.
Example usage for the YAML API¶
catalog.yml
command:
type: langchain.ChatCohereDataset
kwargs:
model: "command"
temperature: 0.0
credentials: cohere # Optional, can use environment variables instead
credentials.yml (optional if using environment variables)
If credentials are passed through credentials.yml, they take precedence over environment variables.
cohere:
base_url: <cohere-api-base> # Optional, defaults to Cohere default
api_key: <cohere-api-key> # Optional if COHERE_API_KEY is set
Or use environment variables:
export COHERE_API_KEY=<your-api-key>
export CO_API_URL=<cohere-api-base> # Optional
Example usage for the Python API¶
from kedro_datasets.langchain import ChatCohereDataset
# With explicit credentials
llm = ChatCohereDataset(
credentials={
"api_key": "xxx", # pragma: allowlist secret
"base_url": "xxx",
},
kwargs={
"model": "command",
"temperature": 0.0,
},
).load()
# Or without credentials (using environment variables)
llm = ChatCohereDataset(
kwargs={
"model": "command",
"temperature": 0.0,
},
).load()
# See: https://python.langchain.com/docs/integrations/chat/cohere
llm.invoke("Hello world!")
Parameters:
-
credentials(Optional, default:{}) –contains
api_keyandbase_url. If not provided, will use environment variables COHERE_API_KEY and CO_API_URL. -
kwargs(dict[str, Any], default:{}) –keyword arguments passed to the ChatCohere constructor.
Source code in kedro_datasets/langchain/chat_cohere_dataset.py
74 75 76 77 78 79 80 81 82 83 | |
_describe ¶
_describe()
Returns a description of the dataset.
Returns:
-
dict[str, Any]–Dictionary containing the kwargs passed to ChatCohere.
Source code in kedro_datasets/langchain/chat_cohere_dataset.py
85 86 87 88 89 90 91 92 93 94 | |
load ¶
load()
Load and return a ChatCohere model instance.
Constructs a ChatCohere instance using the provided kwargs and optional credentials. If credentials are not provided, the ChatCohere instance will automatically use environment variables COHERE_API_KEY and CO_API_URL for authentication.
Returns:
-
ChatCohere–A configured ChatCohere model instance.
Source code in kedro_datasets/langchain/chat_cohere_dataset.py
104 105 106 107 108 109 110 111 112 113 114 115 | |
save ¶
save(data)
Save operation is not supported for ChatCohereDataset.
Raises:
-
DatasetError–Always raised as this dataset is read-only.
Source code in kedro_datasets/langchain/chat_cohere_dataset.py
96 97 98 99 100 101 102 | |