Skip to content

LangChain4J documentation #9802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/src/main/asciidoc/mp/integrations/langchain4j.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2020, 2025 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= LangChain4J
:description: LangChain4J Integration
:keywords: Helidon, AI, LangChain4J, LC4J
:rootdir: {docdir}/../..

include::{rootdir}/includes/mp.adoc[]

== LangChain4J Support

Helidon SE includes native xref:{rootdir}/se/integrations/langchain4j/langchain4j.adoc[LangChain4J integration], which can also be used in Helidon MP thanks to *Helidon Inject to CDI bridge*. Refer to its xref:{rootdir}/se/integrations/langchain4j/langchain4j.adoc[documentation] for more details.
125 changes: 125 additions & 0 deletions docs/src/main/asciidoc/se/integrations/langchain4j/cohere.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2025 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= LangChain4J Cohere Provider
:description: LangChain4J Cohere
:keywords: helidon, AI, LangChain4J, LC4J, Cohere
:feature-name: LangChain4J Integration
:rootdir: {docdir}/../../..

include::{rootdir}/includes/se.adoc[]

== Contents

* <<Overview, Overview>>
* <<Maven Coordinates, Maven Coordinates>>
* <<Components, Components>>
** <<CohereEmbeddingModel, CohereEmbeddingModel>>
** <<CohereScoringModel, CohereScoringModel>>
* <<Additional Information, Additional Information>>

== Overview

This module adds support for selected Cohere models.

== Maven Coordinates

In addition to the xref:langchain4j.adoc#maven-coordinates[Helidon integration with LangChain4J core dependencies], you must add the following:

[source,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`:

[source,yaml]
----
langchain4j:
cohere:
embedding-model:
enabled: true
----

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

Full list of configuration properties:

[cols="3,3a,5a"]

|===
|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&lt;string, string&gt; |A map containing custom headers.
|`enabled` |boolean |If set to false (default), 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 https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-[here] for the format.

|===


=== CohereScoringModel

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

[source,yaml]
----
langchain4j:
cohere:
scoring-model:
enabled: true
----

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

Full list of configuration properties:

[cols="3,3a,5a"]

|===
|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&lt;string, string&gt; |A map containing custom headers.
|`enabled` |boolean |If set to false (default), this component will not be available even if configured.
|`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.
|`timeout` |duration |The timeout setting for API requests. See https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-[here] for the format.

|===

== Additional Information

* xref:langchain4j.adoc[LangChain4J Integration]
* https://docs.langchain4j.dev/integrations/embedding-models/cohere[LangChain4J Cohere Documentation]
79 changes: 79 additions & 0 deletions docs/src/main/asciidoc/se/integrations/langchain4j/core.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2025 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= LangChain4J Core Components
:description: LangChain4J Core Components
:keywords: helidon, AI, LangChain4J, LC4J
:feature-name: LangChain4J Integration
:rootdir: {docdir}/../../..

include::{rootdir}/includes/se.adoc[]

== Contents

* <<Overview, Overview>>
* <<Maven Coordinates, Maven Coordinates>>
* <<Components, Components>>
** <<EmbeddingStoreContentRetriever, EmbeddingStoreContentRetriever>>
* <<Additional Information, Additional Information>>

== Overview

This module adds support for selected LangChain4J core components.

== Maven Coordinates

No additional dependencies are required beyond the xref:langchain4j.adoc#maven-coordinates[LangChain4J integration core dependencies].

== Components

=== EmbeddingStoreContentRetriever

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

[source,yaml]
----
langchain4j:
rag:
embedding-store-content-retriever:
enabled: true
embedding-model: "@default"
embedding-store: "@default"
----

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

Full list of configuration properties:

[cols="3,3a,5a"]

|===
|Key |Type |Description

|`display-name` |string |Display name.
|`enabled` |boolean |If set to `false`, embedding store content retriever will be disabled even if configured.
|`max-results` |int |Maximum number of results.
|`min-score` |double |Minimum score threshold.
|`embedding-model` |string |Name of the service in the service registry that implements `dev.langchain4j.model.embedding.EmbeddingModel`. Use `@default` (the default option) to refer to the unnamed service.
|`embedding-store` |string |Name of the service in the service registry that implements `dev.langchain4j.model.embedding.EmbeddingStore<TextSegment>`. Use `@default` (the default option) to refer to the unnamed service.

|===

== Additional Information

* xref:langchain4j.adoc[LangChain4J Integration]
Loading
Loading