cohere_chat

Generates responses to messages in a chat conversation, using the Cohere API and external tools.

Introduced in version 4.37.0.

  • Common

  • Advanced

# Common configuration fields, showing default values
label: ""
cohere_chat:
  base_url: https://api.cohere.com
  auth_token: "" # No default (required)
  model: command-r-plus # No default (required)
  prompt: "" # No default (optional)
  system_prompt: "" # No default (optional)
  max_tokens: 0 # No default (optional)
  temperature: 0 # No default (optional)
  response_format: text
  json_schema: "" # No default (optional)
  max_tool_calls: 10
  tools: []
# All configuration fields, showing default values
label: ""
cohere_chat:
  base_url: https://api.cohere.com
  auth_token: "" # No default (required)
  model: command-r-plus # No default (required)
  prompt: "" # No default (optional)
  system_prompt: "" # No default (optional)
  max_tokens: 0 # No default (optional)
  temperature: 0 # No default (optional)
  response_format: text
  json_schema: "" # No default (optional)
  schema_registry:
    url: "" # No default (required)
    subject: "" # No default (required)
    refresh_interval: "" # No default (optional)
    tls:
      skip_cert_verify: false
      enable_renegotiation: false
      root_cas: ""
      root_cas_file: ""
      client_certs: []
    oauth:
      enabled: false
      consumer_key: ""
      consumer_secret: ""
      access_token: ""
      access_token_secret: ""
    basic_auth:
      enabled: false
      username: ""
      password: ""
    jwt:
      enabled: false
      private_key_file: ""
      signing_method: ""
      claims: {}
      headers: {}
  top_p: 0 # No default (optional)
  frequency_penalty: 0 # No default (optional)
  presence_penalty: 0 # No default (optional)
  seed: 0 # No default (optional)
  stop: [] # No default (optional)
  max_tool_calls: 10
  tools: []

This processor sends the contents of user prompts to the Cohere API, which generates responses using all available context, including supplementary data provided by external tools. By default, the processor submits the entire payload of each message as a string, unless you use the prompt field to customize it.

To learn more about chat completion, see the Cohere API documentation.

Fields

api_key

The API key for the Cohere API.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

base_url

The base URL to use for API requests.

Type: string

frequency_penalty

A number between -2.0 and 2.0. Positive values penalize new tokens based on the frequency of their appearance in the text so far. This decreases the model’s likelihood to repeat the same line verbatim.

Type: float

json_schema

The JSON schema to use when responding in json_schema format. To learn more about the JSON schema features supported, see the Cohere documentation.

Type: string

max_tokens

The maximum number of tokens to allow in the chat completion.

Type: int

max_tool_calls

The maximum number of tool calls the model can perform.

Type: int

Default: 10

model

The name of the Cohere large language model (LLM) you want to use.

Type: string

# Examples:
model: command-r-plus
model: command-r
model: command
model: command-light

presence_penalty

A number between -2.0 and 2.0. Positive values penalize new tokens based on the frequency of their appearance in the text so far. This increases the model’s likelihood to talk about new topics.

Type: float

prompt

The user prompt you want to generate a response for. By default, the processor submits the entire payload as a string.

This field supports interpolation functions.

Type: string

response_format

Choose the model’s output format. If json_schema is specified, then you must also configure a json_schema or schema_registry.

Type: string

Default: text

Options: text, json, json_schema

schema_registry

The schema registry to dynamically load schemas from when responding in json_schema format. Schemas themselves must be in JSON format. To learn more about the JSON schema features supported, see the Cohere documentation.

Type: object

schema_registry.basic_auth

Configure basic authentication for requests from this component to your schema registry.

Type: object

schema_registry.basic_auth.enabled

Whether to use basic authentication in requests.

Type: bool

Default: false

schema_registry.basic_auth.password

The password of the account credentials to authenticate with.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

Default: ""

schema_registry.basic_auth.username

The username of the account credentials to authenticate as.

Type: string

Default: ""

schema_registry.jwt

BETA: Configure JSON Web Token (JWT) authentication for the secure transmission of data from your schema registry to this component.

Type: object

schema_registry.jwt.claims

Values used to pass the identity of the authenticated entity to the service provider. In this case, between this component and the schema registry.

Type: object

Default: {}

schema_registry.jwt.enabled

Whether to use JWT authentication in requests.

Type: bool

Default: false

schema_registry.jwt.headers

The key/value pairs that identify the type of token and signing algorithm.

Type: object

Default: {}

schema_registry.jwt.private_key_file

A file in PEM format encoded via PKCS1 or PKCS8 as private key.

Type: string

Default: ""

schema_registry.jwt.signing_method

The method used to sign the token, such as RS256, RS384, RS512 or EdDSA.

Type: string

Default: ""

schema_registry.oauth

Configure OAuth version 1.0 to give this component authorized access to your schema registry.

Type: object

schema_registry.oauth.access_token

The value this component can use to gain access to the data in the schema registry.

Type: string

Default: ""

schema_registry.oauth.access_token_secret

The secret that establishes ownership of the oauth.access_token.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

Default: ""

schema_registry.oauth.consumer_key

The value used to identify this component or client to your schema registry.

Type: string

Default: ""

schema_registry.oauth.consumer_secret

The secret used to establish ownership of the consumer key.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

Default: ""

schema_registry.oauth.enabled

Whether to use OAuth version 1 in requests to the schema registry.

Type: bool

Default: false

schema_registry.refresh_interval

The refresh rate for fetching the latest schema. If not specified the schema does not refresh.

Type: string

schema_registry.subject

The subject name to fetch the schema for.

Type: string

schema_registry.tls

Override system defaults with custom TLS settings.

Type: object

schema_registry.tls.client_certs[]

A list of client certificates to use. For each certificate specify values for either the cert and key fields, or cert_file and key_file fields.

Type: object

Default: []

# Examples:
client_certs:
  - cert: foo
    key: bar

  - cert_file: ./example.pem
    key_file: ./example.key

schema_registry.tls.client_certs[].cert

A plain text certificate to use.

Type: string

Default: ""

schema_registry.tls.client_certs[].cert_file

The path of a certificate to use.

Type: string

Default: ""

schema_registry.tls.client_certs[].key

A plain text certificate key to use.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

Default: ""

schema_registry.tls.client_certs[].key_file

The path of a certificate key to use.

Type: string

Default: ""

schema_registry.tls.client_certs[].password

A plain text password for when the private key is password encrypted in PKCS#1 or PKCS#8 format. The obsolete pbeWithMD5AndDES-CBC algorithm is not supported for the PKCS#8 format.

Because the obsolete pbeWithMD5AndDES-CBC algorithm does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

Default: ""

# Examples:
password: foo
password: ${KEY_PASSWORD}

schema_registry.tls.enable_renegotiation

Whether to allow the remote server to request renegotiation. Enable this option if you’re seeing the error message local error: tls: no renegotiation.

Requires version 3.45.0 or later.

Type: bool

Default: false

schema_registry.tls.root_cas

Specify a certificate authority to use (optional). This is a string that represents a certificate chain from the parent trusted root certificate, through possible intermediate signing certificates, to the host certificate.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Secrets.

Type: string

Default: ""

# Examples:
root_cas: |-
  -----BEGIN CERTIFICATE-----
  ...
  -----END CERTIFICATE-----

schema_registry.tls.root_cas_file

Specify the path to a root certificate authority file (optional). This is a file, often with a .pem extension, which contains a certificate chain from the parent trusted root certificate, through possible intermediate signing certificates, to the host certificate.certificate.

Type: string

Default: ""

# Examples:
root_cas_file: ./root_cas.pem

schema_registry.tls.skip_cert_verify

Whether to skip server-side certificate verification.

Type: bool

Default: false

schema_registry.url

The base URL of the schema registry service.

Type: string

seed

If specified, Redpanda Connect makes a best effort to sample deterministically. Repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed.

Type: int

stop[]

Specify up to four sequences to stop the API from generating further tokens.

Type: array

system_prompt

The system prompt to submit along with the user prompt.

This field supports interpolation functions.

Type: string

temperature

Choose a sampling temperature between 0 and 2:

  • Higher values, such as 0.8 make the output more random.

  • Lower values, such as 0.2 make the output more focused and deterministic.

Redpanda recommends adding a value for this field or top_p, but not both.

Type: float

tools[]

External tools that the model can invoke, such as functions, APIs, or web browsing. You can define a series of processors that describe these tools, enabling the model to use agent-like behavior to decide when and how to invoke them to enhance response generation.

Type: object

Default: []

tools[].description

A description of this tool, the LLM uses this to decide if the tool should be used.

Type: string

tools[].name

The name of this tool.

Type: string

tools[].parameters

The parameters the LLM needs to provide to invoke this tool.

Type: object

tools[].parameters.properties

The properties for the processor’s input data

Type: object

tools[].parameters.properties.description

A description of this parameter.

Type: string

tools[].parameters.properties.enum[]

Specifies that this parameter is an enum and only these specific values should be used.

Type: array

Default: []

tools[].parameters.properties.type

The type of this parameter.

Type: string

tools[].parameters.required[]

The required parameters for this pipeline.

Type: array

Default: []

tools[].processors[]

The pipeline to execute when the LLM uses this tool.

Type: processor

top_p

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. For example, a top_p of 0.1 means only the tokens comprising the top 10% probability mass are sampled.

Redpanda recommends adding a value for this field or temperature, but not both.

Type: float

Example

In this pipeline configuration, the Command R+ model executes a number of processors, which make a tool call to retrieve weather data for a specific city.

input:
  generate:
    count: 1
    mapping: |
      root = "What is the weather like in Chicago?"
pipeline:
  processors:
    - cohere_chat:
        auth_token: my_cohere_api_token
        model: command-r-plus
        prompt: "${!content().string()}"
        tools:
          - name: GetWeather
            description: "Retrieve the weather for a specific city"
            parameters:
              required: ["city"]
              properties:
                city:
                  type: string
                  description: the city to look up the weather for
            processors:
              - http:
                  verb: GET
                  url: 'https://wttr.in/${!this.city}?T'
                  headers:
                    User-Agent: curl/8.11.1 # Returns a text string from the weather website
output:
  stdout: {}