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-spring-boot.git

commit 4fa767a3d621c9769e2a22d97c532c2ad406dd6f
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Sep 3 16:19:12 2024 +0200

    CAMEL-21159: fix incorrect metadata/catalog for camel-langchain4j-chat
---
 .../catalog/components/langchain4j-chat.json       | 31 +++++++++++++---------
 .../src/main/docs/langchain4j-chat.json            |  7 +++++
 .../LangChain4jChatComponentConfiguration.java     | 22 +++++++++++++++
 3 files changed, 48 insertions(+), 12 deletions(-)

diff --git 
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/langchain4j-chat.json
 
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/langchain4j-chat.json
index 1b461704340..292b5f63d62 100644
--- 
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/langchain4j-chat.json
+++ 
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/langchain4j-chat.json
@@ -18,25 +18,32 @@
     "async": false,
     "api": false,
     "consumerOnly": false,
-    "producerOnly": true,
+    "producerOnly": false,
     "lenientProperties": false,
     "remote": true
   },
   "componentProperties": {
-    "chatOperation": { "index": 0, "kind": "property", "displayName": "Chat 
Operation", "group": "producer", "label": "", "required": true, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatOperations", 
"enum": [ "CHAT_SINGLE_MESSAGE", "CHAT_SINGLE_MESSAGE_WITH_PROMPT", 
"CHAT_MULTIPLE_MESSAGES" ], "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "defaultValue": "CHAT_SINGLE_MESSAGE", 
"configurationClass": "org.apache [...]
-    "configuration": { "index": 1, "kind": "property", "displayName": 
"Configuration", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
configuration." },
-    "lazyStartProducer": { "index": 2, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
-    "autowiredEnabled": { "index": 3, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
-    "chatModel": { "index": 4, "kind": "property", "displayName": "Chat 
Model", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "dev.langchain4j.model.chat.ChatLanguageModel", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration", 
"configurationField": "configuration", "description": "Chat Language Model of 
type dev.langchai [...]
+    "chatOperation": { "index": 0, "kind": "property", "displayName": "Chat 
Operation", "group": "common", "label": "", "required": true, "type": "object", 
"javaType": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatOperations", 
"enum": [ "CHAT_SINGLE_MESSAGE", "CHAT_SINGLE_MESSAGE_WITH_PROMPT", 
"CHAT_MULTIPLE_MESSAGES" ], "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "defaultValue": "CHAT_SINGLE_MESSAGE", 
"configurationClass": "org.apache.c [...]
+    "configuration": { "index": 1, "kind": "property", "displayName": 
"Configuration", "group": "common", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
configuration." },
+    "bridgeErrorHandler": { "index": 2, "kind": "property", "displayName": 
"Bridge Error Handler", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Allows for bridging the consumer to the Camel routing Error Handler, which 
mean any exceptions (if possible) occurred while the Camel consumer is trying 
to pickup incoming messages, or the like [...]
+    "lazyStartProducer": { "index": 3, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
+    "autowiredEnabled": { "index": 4, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
+    "chatModel": { "index": 5, "kind": "property", "displayName": "Chat 
Model", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "dev.langchain4j.model.chat.ChatLanguageModel", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration", 
"configurationField": "configuration", "description": "Chat Language Model of 
type dev.langchai [...]
   },
   "headers": {
-    "CamelLangChain4jChatPromptTemplate": { "index": 0, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The prompt Template.", "constantName": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChat$Headers#PROMPT_TEMPLATE"
 },
-    "CamelLangChain4jChatAugmentedData": { "index": 1, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Augmented Data for RAG", 
"constantName": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChat$Headers#AUGMENTED_DATA"
 }
+    "CamelLangChain4jChatPromptTemplate": { "index": 0, "kind": "header", 
"displayName": "", "group": "common", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The prompt Template.", "constantName": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChat$Headers#PROMPT_TEMPLATE"
 },
+    "CamelLangChain4jChatAugmentedData": { "index": 1, "kind": "header", 
"displayName": "", "group": "common", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Augmented Data for RAG", 
"constantName": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChat$Headers#AUGMENTED_DATA"
 }
   },
   "properties": {
-    "chatId": { "index": 0, "kind": "path", "displayName": "Chat Id", "group": 
"producer", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The id" },
-    "chatOperation": { "index": 1, "kind": "parameter", "displayName": "Chat 
Operation", "group": "producer", "label": "", "required": true, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatOperations", 
"enum": [ "CHAT_SINGLE_MESSAGE", "CHAT_SINGLE_MESSAGE_WITH_PROMPT", 
"CHAT_MULTIPLE_MESSAGES" ], "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "defaultValue": "CHAT_SINGLE_MESSAGE", 
"configurationClass": "org.apach [...]
-    "lazyStartProducer": { "index": 2, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
-    "chatModel": { "index": 3, "kind": "parameter", "displayName": "Chat 
Model", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "dev.langchain4j.model.chat.ChatLanguageModel", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration", 
"configurationField": "configuration", "description": "Chat Language Model of 
type dev.langcha [...]
+    "chatId": { "index": 0, "kind": "path", "displayName": "Chat Id", "group": 
"common", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The id" },
+    "chatOperation": { "index": 1, "kind": "parameter", "displayName": "Chat 
Operation", "group": "common", "label": "", "required": true, "type": "object", 
"javaType": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatOperations", 
"enum": [ "CHAT_SINGLE_MESSAGE", "CHAT_SINGLE_MESSAGE_WITH_PROMPT", 
"CHAT_MULTIPLE_MESSAGES" ], "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "defaultValue": "CHAT_SINGLE_MESSAGE", 
"configurationClass": "org.apache. [...]
+    "description": { "index": 2, "kind": "parameter", "displayName": 
"Description", "group": "consumer", "label": "consumer", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Tool description" },
+    "parameters": { "index": 3, "kind": "parameter", "displayName": 
"Parameters", "group": "consumer", "label": "consumer", "required": false, 
"type": "object", "javaType": "java.util.Map<java.lang.String, 
java.lang.String>", "enum": [ "string", "integer", "number", "object", "array", 
"boolean", "null" ], "prefix": "parameter.", "multiValue": true, "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "List of Tool parameters in the form of param [...]
+    "bridgeErrorHandler": { "index": 4, "kind": "parameter", "displayName": 
"Bridge Error Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions (if possible) occurred 
while the Camel consumer is trying to pickup incoming  [...]
+    "camelToolParameter": { "index": 5, "kind": "parameter", "displayName": 
"Camel Tool Parameter", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.component.langchain4j.chat.tool.CamelSimpleToolParameter", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "Tool's Camel Parameters, programmatically define Tool 
description and parameters" },
+    "exceptionHandler": { "index": 6, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
+    "exchangePattern": { "index": 7, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
+    "lazyStartProducer": { "index": 8, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
+    "chatModel": { "index": 9, "kind": "parameter", "displayName": "Chat 
Model", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "dev.langchain4j.model.chat.ChatLanguageModel", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration", 
"configurationField": "configuration", "description": "Chat Language Model of 
type dev.langcha [...]
   }
 }
diff --git 
a/components-starter/camel-langchain4j-chat-starter/src/main/docs/langchain4j-chat.json
 
b/components-starter/camel-langchain4j-chat-starter/src/main/docs/langchain4j-chat.json
index 71c919c910a..f5bb4679535 100644
--- 
a/components-starter/camel-langchain4j-chat-starter/src/main/docs/langchain4j-chat.json
+++ 
b/components-starter/camel-langchain4j-chat-starter/src/main/docs/langchain4j-chat.json
@@ -20,6 +20,13 @@
       "sourceType": 
"org.apache.camel.component.langchain4j.chat.springboot.LangChain4jChatComponentConfiguration",
       "defaultValue": true
     },
+    {
+      "name": "camel.component.langchain4j-chat.bridge-error-handler",
+      "type": "java.lang.Boolean",
+      "description": "Allows for bridging the consumer to the Camel routing 
Error Handler, which mean any exceptions (if possible) occurred while the Camel 
consumer is trying to pickup incoming messages, or the likes, will now be 
processed as a message and handled by the routing Error Handler. Important: 
This is only possible if the 3rd party component allows Camel to be alerted if 
an exception was thrown. Some components handle this internally only, and 
therefore bridgeErrorHandler is n [...]
+      "sourceType": 
"org.apache.camel.component.langchain4j.chat.springboot.LangChain4jChatComponentConfiguration",
+      "defaultValue": false
+    },
     {
       "name": "camel.component.langchain4j-chat.chat-model",
       "type": "dev.langchain4j.model.chat.ChatLanguageModel",
diff --git 
a/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConfiguration.java
 
b/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConfiguration.java
index ce96d453d70..bad71ac3e05 100644
--- 
a/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConfiguration.java
+++ 
b/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConfiguration.java
@@ -50,6 +50,20 @@ public class LangChain4jChatComponentConfiguration
      * type.
      */
     private LangChain4jChatConfiguration configuration;
+    /**
+     * Allows for bridging the consumer to the Camel routing Error Handler,
+     * which mean any exceptions (if possible) occurred while the Camel 
consumer
+     * is trying to pickup incoming messages, or the likes, will now be
+     * processed as a message and handled by the routing Error Handler.
+     * Important: This is only possible if the 3rd party component allows Camel
+     * to be alerted if an exception was thrown. Some components handle this
+     * internally only, and therefore bridgeErrorHandler is not possible. In
+     * other situations we may improve the Camel component to hook into the 3rd
+     * party component and make this possible for future releases. By default
+     * the consumer will use the org.apache.camel.spi.ExceptionHandler to deal
+     * with exceptions, that will be logged at WARN or ERROR level and ignored.
+     */
+    private Boolean bridgeErrorHandler = false;
     /**
      * Whether the producer should be started lazy (on the first message). By
      * starting lazy you can use this to allow CamelContext and routes to
@@ -92,6 +106,14 @@ public class LangChain4jChatComponentConfiguration
         this.configuration = configuration;
     }
 
+    public Boolean getBridgeErrorHandler() {
+        return bridgeErrorHandler;
+    }
+
+    public void setBridgeErrorHandler(Boolean bridgeErrorHandler) {
+        this.bridgeErrorHandler = bridgeErrorHandler;
+    }
+
     public Boolean getLazyStartProducer() {
         return lazyStartProducer;
     }

Reply via email to