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:
<dependency>
<groupId>io.helidon.integrations.langchain4j.providers</groupId>
<artifactId>helidon-integrations-langchain4j-providers-cohere</artifactId>
</dependency>
CohereEmbeddingModel
To automatically create and add CohereEmbeddingModel to the service registry
add the following lines to application.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.
Configuration options
| Key | Type | Description |
|---|---|---|
api-key | string | Required. The API key used to authenticate requests to the Cohere API. |
base-url | string | The base URL for the model API. If not present, the default value supplied from LangChain4j is used. |
custom-headers | Map<string, string> | A map containing custom headers. |
enabled | boolean | If set to false, this component will not be available even if configured. |
input-type | string | Input type. |
log-requests | boolean | Whether to log API requests. |
log-responses | boolean | Whether to log API responses. |
max-segments-per-batch | int | Maximum number of segments per batch. |
model-name | string | The model name to use. |
timeout | duration | The 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:
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.
Configuration options
| Key | Type | Description |
|---|---|---|
api-key | string | Required. The API key used to authenticate requests to the Cohere API. |
base-url | string | The base URL for the model API. If not present, the default value supplied from LangChain4j is used. |
custom-headers | Map<string, string> | A map containing custom headers. |
enabled | boolean | If set to false, this component will not be available even if configured. |
http-client-builder | injected bean | HTTP client builder to use. The default service is injected when available; select a named service with http-client-builder.service-registry.named. |
http-client-builder-discover-services | boolean | Whether to enable automatic service discovery for http-client-builder. Defaults to true. |
log-requests | boolean | Whether to log API requests. |
log-responses | boolean | Whether to log API responses. |
max-retries | int | The maximum number of retries for failed API requests. |
model-name | string | The model name to use. |
proxy | injected bean | Deprecated. Legacy HTTP or SOCKS proxy. The default service is injected when available; select a named service with proxy.service-registry.named. |
proxy-discover-services | boolean | Whether to enable automatic service discovery for the deprecated proxy option. Defaults to true. |
timeout | duration | The timeout setting for API requests. See here for the format. |
Prefer http-client-builder for new configurations. The deprecated proxy
option remains available for compatibility and supports direct (no proxy), HTTP,
and SOCKS modes. A programmatically or declaratively configured, including
named, http-client-builder takes precedence over proxy. An equivalently
configured proxy takes precedence over a default-discovered HTTP client
builder. If both options are only default-discovered, the HTTP client builder
takes precedence.