Skip to content

Cohere

Overview

This module adds support for selected Cohere models.

Maven Coordinates

In addition to the Helidon integration with LangChain4j core dependencies, you must add the following:

xml
<dependency>
    <groupId>io.helidon.integrations.langchain4j.providers</groupId>
    <artifactId>helidon-integrations-langchain4j-providers-cohere</artifactId>
</dependency>

Components

CohereEmbeddingModel

To automatically create and add CohereEmbeddingModel to the service registry add the following lines to application.yaml:

yaml
langchain4j:
  providers:
    cohere:
      api-key: "${COHERE_TOKEN}"

  models:
    cohere-embedding-model:
      provider: cohere
      model-name: "embed-english-v3.0"

If enabled is set to false, the configuration is ignored, and the component is not created.

Full list of configuration properties:

KeyTypeDescription
api-keystringRequired. The API key used to authenticate requests to the Cohere API.
base-urlstringThe base URL for the model API. If not present, the default value supplied from LangChain4j is used.
custom-headersMap<string, string>A map containing custom headers.
enabledbooleanIf set to false, this component will not be available even if configured.
input-typestringInput type.
log-requestsbooleanWhether to log API requests.
log-responsesbooleanWhether to log API responses.
max-segments-per-batchintMaximum number of segments per batch.
model-namestringThe model name to use.
timeoutdurationThe timeout setting for API requests. See here for the format.

CohereScoringModel

To automatically create and add CohereScoringModel to the service registry add the following lines to application.yaml:

yaml
langchain4j:
  providers:
    cohere:
      api-key: "${COHERE_TOKEN}"

  models:
    cohere-scoring-model:
      provider: cohere
      model-name: "rerank-english-v3.0"

If enabled is set to false, the configuration is ignored, and the component is not created.

Full list of configuration properties:

KeyTypeDescription
api-keystringRequired. The API key used to authenticate requests to the Cohere API.
base-urlstringThe base URL for the model API. If not present, the default value supplied from LangChain4j is used.
custom-headersMap<string, string>A map containing custom headers.
enabledbooleanIf set to false, this component will not be available even if configured.
log-requestsbooleanWhether to log API requests.
log-responsesbooleanWhether to log API responses.
max-retriesintThe maximum number of retries for failed API requests.
model-namestringThe model name to use.
timeoutdurationThe timeout setting for API requests. See here for the format.

Additional Information