You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2025/09/13 11:07:54 UTC

(camel) 02/02: CAMEL-22334 Separate the headers out from being a nested class to their own class (LangChain4jEmbeddingStoreHeaders)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit bb67b29bf370cc47ac887366c2d47dbc1f1fc9e0
Author: Tom Cunningham <tc...@redhat.com>
AuthorDate: Fri Sep 12 08:42:55 2025 -0400

    CAMEL-22334 Separate the headers out from being a nested class to their own class (LangChain4jEmbeddingStoreHeaders)
---
 .../LangChain4jEmbeddingStoreHeaders.java          | 48 ++++++++++++++++++++++
 .../LangChain4jEmbeddingStoreProducer.java         | 10 ++---
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreHeaders.java b/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreHeaders.java
new file mode 100644
index 00000000000..e40318d9db5
--- /dev/null
+++ b/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreHeaders.java
@@ -0,0 +1,48 @@
+/*
+ * 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.component.langchain4j.embeddingstore;
+
+import org.apache.camel.spi.Metadata;
+
+/**
+ * Message headers used by the embedding store component.
+ *
+ * <p>
+ * These headers control the behavior of embedding store operations and provide additional parameters for search and
+ * filter operations.
+ * </p>
+ */
+public class LangChain4jEmbeddingStoreHeaders {
+    /** Specifies the embedding store operation to perform (ADD, REMOVE, or SEARCH) */
+    @Metadata(description = "The action to be performed.", javaType = "String",
+              enums = "ADD,REMOVE,SEARCH")
+    public static final String ACTION = "CamelLangchain4jEmbeddingStoreAction";
+
+    /** Maximum number of results to return from search operations */
+    @Metadata(description = "Maximum number of search results to return", javaType = "Integer",
+              defaultValue = LangChain4jEmbeddingStore.DEFAULT_MAX_RESULTS)
+    public static final String MAX_RESULTS = "CamelLangchain4jEmbeddingStoreMaxResults";
+
+    /** Minimum similarity score threshold for search results */
+    @Metadata(description = "Minimum similarity score for search results", javaType = "Double")
+    public static final String MIN_SCORE = "CamelLangchain4jEmbeddingStoreMinScore";
+
+    /** Filter to apply to search operations for metadata-based filtering */
+    @Metadata(description = "Search filter for metadata-based constraints",
+              javaType = "dev.langchain4j.store.embedding.filter.Filter")
+    public static final String FILTER = "CamelLangchain4jEmbeddingStoreFilter";
+}
diff --git a/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreProducer.java b/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreProducer.java
index 36a0568af06..16563b40401 100644
--- a/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreProducer.java
+++ b/components/camel-ai/camel-langchain4j-embeddingstore/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/LangChain4jEmbeddingStoreProducer.java
@@ -86,7 +86,7 @@ public class LangChain4jEmbeddingStoreProducer extends DefaultProducer {
         try {
             if (action == null) {
                 throw new NoSuchHeaderException(
-                        "The action is a required header", exchange, LangChain4jEmbeddingStore.Headers.ACTION);
+                        "The action is a required header", exchange, LangChain4jEmbeddingStoreHeaders.ACTION);
             }
 
             switch (action) {
@@ -193,8 +193,8 @@ public class LangChain4jEmbeddingStoreProducer extends DefaultProducer {
         }
 
         int maxResults = Integer.parseInt(LangChain4jEmbeddingStore.DEFAULT_MAX_RESULTS);
-        if (in.getHeader(LangChain4jEmbeddingStore.Headers.MAX_RESULTS, Integer.class) != null) {
-            maxResults = in.getHeader(LangChain4jEmbeddingStore.Headers.MAX_RESULTS, Integer.class);
+        if (in.getHeader(LangChain4jEmbeddingStoreHeaders.MAX_RESULTS, Integer.class) != null) {
+            maxResults = in.getHeader(LangChain4jEmbeddingStoreHeaders.MAX_RESULTS, Integer.class);
         }
 
         EmbeddingSearchRequestBuilder esrb = EmbeddingSearchRequest.builder()
@@ -202,12 +202,12 @@ public class LangChain4jEmbeddingStoreProducer extends DefaultProducer {
                 .maxResults(maxResults);
 
         if (in.getHeader(LangChain4jEmbeddingStore.Headers.MIN_SCORE, Integer.class) != null) {
-            Double minScore = in.getHeader(LangChain4jEmbeddingStore.Headers.MIN_SCORE, Double.class);
+            Double minScore = in.getHeader(LangChain4jEmbeddingStoreHeaders.MIN_SCORE, Double.class);
             esrb = esrb.minScore(minScore);
         }
 
         if (in.getHeader(LangChain4jEmbeddingStore.Headers.FILTER, Filter.class) != null) {
-            Filter filter = in.getHeader(LangChain4jEmbeddingStore.Headers.FILTER, Filter.class);
+            Filter filter = in.getHeader(LangChain4jEmbeddingStoreHeaders.FILTER, Filter.class);
             esrb = esrb.filter(filter);
         }
         EmbeddingSearchRequest embeddingSearchRequest = esrb.build();