diff --git a/docs/modules/ROOT/examples/components/langchain-embeddings.yml b/docs/modules/ROOT/examples/components/langchain-embeddings.yml new file mode 100644 index 000000000000..039a18fbeffa --- /dev/null +++ b/docs/modules/ROOT/examples/components/langchain-embeddings.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-langchain-embeddings +cqArtifactIdBase: langchain-embeddings +cqNativeSupported: false +cqStatus: Preview +cqDeprecated: false +cqJvmSince: 3.10.0 +cqNativeSince: n/a +cqCamelPartName: langchain-embeddings +cqCamelPartTitle: LangChain4j Embeddings +cqCamelPartDescription: LangChain4j Embeddings +cqExtensionPageTitle: LangChain4j Embeddings diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 0dabad380354..45d9ebb336ef 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -197,6 +197,7 @@ *** xref:reference/extensions/ldif.adoc[LDIF] *** xref:reference/extensions/lra.adoc[LRA] *** xref:reference/extensions/lzf.adoc[LZF Deflate Compression] +*** xref:reference/extensions/langchain-embeddings.adoc[LangChain4j Embeddings] *** xref:reference/extensions/language.adoc[Language] *** xref:reference/extensions/leveldb.adoc[LevelDB] *** xref:reference/extensions/log.adoc[Log] diff --git a/docs/modules/ROOT/pages/reference/extensions/langchain-embeddings.adoc b/docs/modules/ROOT/pages/reference/extensions/langchain-embeddings.adoc new file mode 100644 index 000000000000..f491f4306fb5 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/langchain-embeddings.adoc @@ -0,0 +1,41 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +[id="extensions-langchain-embeddings"] += LangChain4j Embeddings +:linkattrs: +:cq-artifact-id: camel-quarkus-langchain-embeddings +:cq-native-supported: false +:cq-status: Preview +:cq-status-deprecation: Preview +:cq-description: LangChain4j Embeddings +:cq-deprecated: false +:cq-jvm-since: 3.10.0 +:cq-native-since: n/a + +ifeval::[{doc-show-badges} == true] +[.badges] +[.badge-key]##JVM since##[.badge-supported]##3.10.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +endif::[] + +LangChain4j Embeddings + +[id="extensions-langchain-embeddings-whats-inside"] +== What's inside + +* xref:{cq-camel-components}::langchain-embeddings-component.adoc[LangChain4j Embeddings component], URI syntax: `langchain-embeddings:embeddingId` + +Please refer to the above link for usage and configuration details. + +[id="extensions-langchain-embeddings-maven-coordinates"] +== Maven coordinates + +[source,xml] +---- + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + +---- +ifeval::[{doc-show-user-guide-link} == true] +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. +endif::[] diff --git a/extensions-jvm/langchain-embeddings/deployment/pom.xml b/extensions-jvm/langchain-embeddings/deployment/pom.xml new file mode 100644 index 000000000000..efc0a8c7dcaf --- /dev/null +++ b/extensions-jvm/langchain-embeddings/deployment/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-parent + 3.10.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-langchain-embeddings-deployment + Camel Quarkus :: LangChain4j Embeddings :: Deployment + + + + org.apache.camel.quarkus + camel-quarkus-core-deployment + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + + diff --git a/extensions-jvm/langchain-embeddings/deployment/src/main/java/org/apache/camel/quarkus/component/langchain/embeddings/deployment/LangchainEmbeddingsProcessor.java b/extensions-jvm/langchain-embeddings/deployment/src/main/java/org/apache/camel/quarkus/component/langchain/embeddings/deployment/LangchainEmbeddingsProcessor.java new file mode 100644 index 000000000000..b93ecb84f333 --- /dev/null +++ b/extensions-jvm/langchain-embeddings/deployment/src/main/java/org/apache/camel/quarkus/component/langchain/embeddings/deployment/LangchainEmbeddingsProcessor.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.camel.quarkus.component.langchain.embeddings.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; +import org.apache.camel.quarkus.core.JvmOnlyRecorder; +import org.jboss.logging.Logger; + +class LangchainEmbeddingsProcessor { + + private static final Logger LOG = Logger.getLogger(LangchainEmbeddingsProcessor.class); + private static final String FEATURE = "camel-langchain-embeddings"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + /** + * Remove this once this extension starts supporting the native mode. + */ + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + @Record(value = ExecutionTime.RUNTIME_INIT) + void warnJvmInNative(JvmOnlyRecorder recorder) { + JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time + recorder.warnJvmInNative(FEATURE); // warn at runtime + } +} diff --git a/extensions-jvm/langchain-embeddings/pom.xml b/extensions-jvm/langchain-embeddings/pom.xml new file mode 100644 index 000000000000..ec6500923598 --- /dev/null +++ b/extensions-jvm/langchain-embeddings/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-extensions-jvm + 3.10.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-langchain-embeddings-parent + Camel Quarkus :: LangChain4j Embeddings + pom + + + deployment + runtime + + diff --git a/extensions-jvm/langchain-embeddings/runtime/pom.xml b/extensions-jvm/langchain-embeddings/runtime/pom.xml new file mode 100644 index 000000000000..0694a6d3c54e --- /dev/null +++ b/extensions-jvm/langchain-embeddings/runtime/pom.xml @@ -0,0 +1,100 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-parent + 3.10.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-langchain-embeddings + Camel Quarkus :: LangChain4j Embeddings :: Runtime + LangChain4j Embeddings + + + 3.10.0 + + + + + org.apache.camel.quarkus + camel-quarkus-core + + + org.apache.camel + camel-langchain-embeddings + + + + + + + io.quarkus + quarkus-extension-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + + + + + full + + + !quickly + + + + + + org.apache.camel.quarkus + camel-quarkus-maven-plugin + + + update-extension-doc-page + + update-extension-doc-page + + process-classes + + + + + + + + diff --git a/extensions-jvm/langchain-embeddings/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-jvm/langchain-embeddings/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 000000000000..daec2d48d05b --- /dev/null +++ b/extensions-jvm/langchain-embeddings/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel LangChain4j Embeddings" +description: "LangChain4j Embeddings" +metadata: + icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg" + unlisted: true + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/langchain-embeddings.html" + categories: + - "integration" + status: + - "preview" diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 8e16b04c6678..80c7c291d7a9 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -78,6 +78,7 @@ jooq json-patch jsonapi + langchain-embeddings ldif lucene mail-microsoft-oauth diff --git a/integration-tests-jvm/langchain-embeddings/pom.xml b/integration-tests-jvm/langchain-embeddings/pom.xml new file mode 100644 index 000000000000..329f17a53469 --- /dev/null +++ b/integration-tests-jvm/langchain-embeddings/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-build-parent-it + 3.10.0-SNAPSHOT + ../../poms/build-parent-it/pom.xml + + + camel-quarkus-integration-test-langchain-embeddings + Camel Quarkus :: Integration Tests :: LangChain4j Embeddings + Integration tests for Camel Quarkus LangChain4j Embeddings extension + + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + + + io.quarkus + quarkus-resteasy + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + virtualDependencies + + + !noVirtualDependencies + + + + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-deployment + ${project.version} + pom + test + + + * + * + + + + + + + diff --git a/integration-tests-jvm/langchain-embeddings/src/main/java/org/apache/camel/quarkus/component/langchain/embeddings/it/LangchainEmbeddingsResource.java b/integration-tests-jvm/langchain-embeddings/src/main/java/org/apache/camel/quarkus/component/langchain/embeddings/it/LangchainEmbeddingsResource.java new file mode 100644 index 000000000000..e5a4b7156e99 --- /dev/null +++ b/integration-tests-jvm/langchain-embeddings/src/main/java/org/apache/camel/quarkus/component/langchain/embeddings/it/LangchainEmbeddingsResource.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.camel.quarkus.component.langchain.embeddings.it; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import org.apache.camel.CamelContext; +import org.jboss.logging.Logger; + +@Path("/langchain-embeddings") +@ApplicationScoped +public class LangchainEmbeddingsResource { + + private static final Logger LOG = Logger.getLogger(LangchainEmbeddingsResource.class); + + private static final String COMPONENT_LANGCHAIN_EMBEDDINGS = "langchain-embeddings"; + @Inject + CamelContext context; + + @Path("/load/component/langchain-embeddings") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response loadComponentLangchainEmbeddings() throws Exception { + /* This is an autogenerated test */ + if (context.getComponent(COMPONENT_LANGCHAIN_EMBEDDINGS) != null) { + return Response.ok().build(); + } + LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_LANGCHAIN_EMBEDDINGS); + return Response.status(500, COMPONENT_LANGCHAIN_EMBEDDINGS + " could not be loaded from the Camel context").build(); + } +} diff --git a/integration-tests-jvm/langchain-embeddings/src/test/java/org/apache/camel/quarkus/component/langchain/embeddings/it/LangchainEmbeddingsTest.java b/integration-tests-jvm/langchain-embeddings/src/test/java/org/apache/camel/quarkus/component/langchain/embeddings/it/LangchainEmbeddingsTest.java new file mode 100644 index 000000000000..844321d14f8f --- /dev/null +++ b/integration-tests-jvm/langchain-embeddings/src/test/java/org/apache/camel/quarkus/component/langchain/embeddings/it/LangchainEmbeddingsTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.camel.quarkus.component.langchain.embeddings.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class LangchainEmbeddingsTest { + + @Test + public void loadComponentLangchainEmbeddings() { + /* A simple autogenerated test */ + RestAssured.get("/langchain-embeddings/load/component/langchain-embeddings") + .then() + .statusCode(200); + } + +} diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml index 7505895d0b23..0011ff1bc511 100644 --- a/integration-tests-jvm/pom.xml +++ b/integration-tests-jvm/pom.xml @@ -77,6 +77,7 @@ jooq json-patch jsonapi + langchain-embeddings ldif lucene mail-microsoft-oauth diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index b70ab61a7610..d86420092daa 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1740,6 +1740,11 @@ camel-kudu ${camel.version} + + org.apache.camel + camel-langchain-embeddings + ${camel.version} + org.apache.camel camel-language @@ -4558,6 +4563,16 @@ camel-quarkus-kudu-deployment ${camel-quarkus.version} + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + ${camel-quarkus.version} + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-deployment + ${camel-quarkus.version} + org.apache.camel.quarkus camel-quarkus-language diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index d3239b6b912b..feb837715d93 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -1677,6 +1677,11 @@ camel-kudu 4.5.0 + + org.apache.camel + camel-langchain-embeddings + 4.5.0 + org.apache.camel camel-language @@ -4483,6 +4488,16 @@ camel-quarkus-kudu-deployment 3.10.0-SNAPSHOT + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + 3.10.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-deployment + 3.10.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-language diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index 89f1b58077bb..7b0c7028206d 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -1677,6 +1677,11 @@ camel-kudu 4.5.0 + + org.apache.camel + camel-langchain-embeddings + 4.5.0 + org.apache.camel camel-language @@ -4483,6 +4488,16 @@ camel-quarkus-kudu-deployment 3.10.0-SNAPSHOT + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + 3.10.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-deployment + 3.10.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-language diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index 56f46fd743c5..714c62a8502c 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -1677,6 +1677,11 @@ camel-kudu 4.5.0 + + org.apache.camel + camel-langchain-embeddings + 4.5.0 + org.apache.camel camel-language @@ -4483,6 +4488,16 @@ camel-quarkus-kudu-deployment 3.10.0-SNAPSHOT + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings + 3.10.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-langchain-embeddings-deployment + 3.10.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-language