haive.core.models.llm.providers.cohere¶

Cohere Provider Module.

This module implements the Cohere language model provider for the Haive framework, supporting Cohere’s Command models with advanced generation and reasoning capabilities.

The provider handles API key management, model configuration, and safe imports of the langchain-cohere package dependencies.

Examples

Basic usage:

from haive.core.models.llm.providers.cohere import CohereProvider

provider = CohereProvider(
    model="command-r-plus",
    temperature=0.7,
    max_tokens=1000
)
llm = provider.instantiate()

With custom parameters:

provider = CohereProvider(
    model="command-r",
    temperature=0.1,
    k=40,
    p=0.9,
    frequency_penalty=0.1
)

Classes¶

CohereProvider

Cohere language model provider configuration.

Module Contents¶

class haive.core.models.llm.providers.cohere.CohereProvider(/, **data)¶

Bases: haive.core.models.llm.providers.base.BaseLLMProvider

Cohere language model provider configuration.

This provider supports Cohere’s Command models including Command R+, Command R, and other models optimized for reasoning, generation, and multilingual tasks.

Parameters:

data (Any)

provider¶

Always LLMProvider.COHERE

Type:

LLMProvider

model¶

The Cohere model to use

Type:

str

temperature¶

Sampling temperature (0.0-5.0)

Type:

float

max_tokens¶

Maximum tokens in response

Type:

int

k¶

Top-k sampling parameter

Type:

int

p¶

Top-p nucleus sampling parameter

Type:

float

frequency_penalty¶

Frequency penalty parameter

Type:

float

presence_penalty¶

Presence penalty parameter

Type:

float

stop_sequences¶

Stop sequences for generation

Type:

list

Examples

High-performance reasoning:

provider = CohereProvider(
    model="command-r-plus",
    temperature=0.3,
    max_tokens=2000,
    k=40
)

Creative writing:

provider = CohereProvider(
    model="command-r",
    temperature=0.9,
    p=0.95,
    frequency_penalty=0.2
)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

classmethod get_models()¶

Get available Cohere models.

Return type:

list[str]

max_tokens: int | None = None¶

Get maximum total tokens for this model.