This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new e785ba78ad52 CAMEL-27608: camel-langchain4j-web-search - search
options on the component, maxResults and resultType not required (#30997)
e785ba78ad52 is described below
commit e785ba78ad526bf5e5a2d9b1044c0b908d9467a4
Author: allthingssecurity <[email protected]>
AuthorDate: Sat Nov 28 03:22:41 2026 +0530
CAMEL-27608: camel-langchain4j-web-search - search options on the
component, maxResults and resultType not required (#30997)
1. The search options could not be set on the component.
LangChain4jWebSearchComponent had a configuration field with @Metadata
but no setter, so the package plugin generated no component options from
LangChain4jWebSearchConfiguration and the component configurer knew only
lazyStartProducer and autowiredEnabled. createEndpoint() copies the
component configuration into each endpoint, but nothing could fill it,
so camel.component.langchain4j-web-search.maxResults and the other
options failed to bind. The component now has setConfiguration(), as
the other camel-langchain4j components have, and the search options are
component options too. Options set on the endpoint override them.
2. maxResults (default 1) and resultType (default CONTENT) were marked
required although the fields hold their default, so a user never has to
set them. They are no longer required.
Regenerated langchain4j-web-search.json (component and catalog copy), the
component configurer, and the component and endpoint DSL.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../catalog/components/langchain4j-web-search.json | 21 +-
.../LangChain4jWebSearchComponentConfigurer.java | 81 ++++++++
.../web/search/langchain4j-web-search.json | 21 +-
.../web/search/LangChain4jWebSearchComponent.java | 7 +
.../search/LangChain4jWebSearchConfiguration.java | 20 +-
.../LangChain4jWebSearchComponentOptionsTest.java | 141 +++++++++++++
...angchain4jWebSearchComponentBuilderFactory.java | 220 +++++++++++++++++++++
...LangChain4jWebSearchEndpointBuilderFactory.java | 20 +-
8 files changed, 503 insertions(+), 28 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-web-search.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-web-search.json
index 6fc010f1e32e..c1843994bc24 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-web-search.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-web-search.json
@@ -24,8 +24,19 @@
"remote": true
},
"componentProperties": {
- "lazyStartProducer": { "index": 0, "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": 1, "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 [...]
+ "additionalParams": { "index": 0, "kind": "property", "displayName":
"Additional Params", "group": "producer", "label": "", "required": false,
"type": "object", "javaType": "java.util.Map<java.lang.String,
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "More parameters for the
search engine, a [...]
+ "configuration": { "index": 1, "kind": "property", "displayName":
"Configuration", "group": "producer", "label": "", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description": "The
configuration that each endpoint starts from. Options set on the endpoint
override it." },
+ "geoLocation": { "index": 2, "kind": "property", "displayName": "Geo
Location", "group": "producer", "label": "", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The geographic location
of the search results, such as a country code, in the forma [...]
+ "language": { "index": 3, "kind": "property", "displayName": "Language",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The language of the
search results, in the format that the search engine expects. The Tavi [...]
+ "lazyStartProducer": { "index": 4, "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 [...]
+ "maxResults": { "index": 5, "kind": "property", "displayName": "Max
Results", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 1, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The number of results
that the producer asks the search engine f [...]
+ "resultType": { "index": 6, "kind": "property", "displayName": "Result
Type", "group": "producer", "label": "", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType",
"enum": [ "LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT", "CONTENT", "SNIPPET" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"CONTENT", "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jW [...]
+ "safeSearch": { "index": 7, "kind": "property", "displayName": "Safe
Search", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "Whether the search
engine filters explicit content out of the results. If not set, [...]
+ "startIndex": { "index": 8, "kind": "property", "displayName": "Start
Index", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The index of the first
search result to return, in the numbering that the search en [...]
+ "startPage": { "index": 9, "kind": "property", "displayName": "Start
Page", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The page number of the
search results to return. If not set, LangChain4j uses 1. The [...]
+ "webSearchEngine": { "index": 10, "kind": "property", "displayName": "Web
Search Engine", "group": "producer", "label": "", "required": false, "type":
"object", "javaType": "dev.langchain4j.web.search.WebSearchEngine",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The
dev.langchain4j.web.search.WebSearchEngine t [...]
+ "autowiredEnabled": { "index": 11, "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 [...]
+ "webSearchRequest": { "index": 12, "kind": "property", "displayName": "Web
Search Request", "group": "advanced", "label": "advanced", "required": false,
"type": "object", "javaType": "dev.langchain4j.web.search.WebSearchRequest",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "A
dev.langchain4j.web.search.WebSear [...]
},
"bodyTypes": {
"producerIn": { "carriers": [ "any" ], "description": "The search terms as
text; another body is converted to text, so a Map or a POJO is searched as its
toString(), and no body fails. With webSearchRequest the body is not read" },
@@ -36,12 +47,12 @@
"additionalParams": { "index": 1, "kind": "parameter", "displayName":
"Additional Params", "group": "producer", "label": "", "required": false,
"type": "object", "javaType": "java.util.Map<java.lang.String,
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "More parameters for the
search engine, [...]
"geoLocation": { "index": 2, "kind": "parameter", "displayName": "Geo
Location", "group": "producer", "label": "", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The geographic location
of the search results, such as a country code, in the form [...]
"language": { "index": 3, "kind": "parameter", "displayName": "Language",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The language of the
search results, in the format that the search engine expects. The Tav [...]
- "maxResults": { "index": 4, "kind": "parameter", "displayName": "Max
Results", "group": "producer", "label": "", "required": true, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 1, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The number of results
that the producer asks the search engine f [...]
- "resultType": { "index": 5, "kind": "parameter", "displayName": "Result
Type", "group": "producer", "label": "", "required": true, "type": "enum",
"javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType",
"enum": [ "LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT", "CONTENT", "SNIPPET" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"CONTENT", "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jW [...]
+ "maxResults": { "index": 4, "kind": "parameter", "displayName": "Max
Results", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 1, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The number of results
that the producer asks the search engine [...]
+ "resultType": { "index": 5, "kind": "parameter", "displayName": "Result
Type", "group": "producer", "label": "", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType",
"enum": [ "LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT", "CONTENT", "SNIPPET" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"CONTENT", "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4j [...]
"safeSearch": { "index": 6, "kind": "parameter", "displayName": "Safe
Search", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "Whether the search
engine filters explicit content out of the results. If not set, [...]
"startIndex": { "index": 7, "kind": "parameter", "displayName": "Start
Index", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The index of the first
search result to return, in the numbering that the search e [...]
"startPage": { "index": 8, "kind": "parameter", "displayName": "Start
Page", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The page number of the
search results to return. If not set, LangChain4j uses 1. The [...]
- "webSearchEngine": { "index": 9, "kind": "parameter", "displayName": "Web
Search Engine", "group": "producer", "label": "", "required": true, "type":
"object", "javaType": "dev.langchain4j.web.search.WebSearchEngine",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The
dev.langchain4j.web.search.WebSearchEngine th [...]
+ "webSearchEngine": { "index": 9, "kind": "parameter", "displayName": "Web
Search Engine", "group": "producer", "label": "", "required": false, "type":
"object", "javaType": "dev.langchain4j.web.search.WebSearchEngine",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The
dev.langchain4j.web.search.WebSearchEngine t [...]
"lazyStartProducer": { "index": 10, "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 produ [...]
"webSearchRequest": { "index": 11, "kind": "parameter", "displayName":
"Web Search Request", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"dev.langchain4j.web.search.WebSearchRequest", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "A
dev.langchain4j.web.search.WebSea [...]
}
diff --git
a/components/camel-ai/camel-langchain4j-web-search/src/generated/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentConfigurer.java
b/components/camel-ai/camel-langchain4j-web-search/src/generated/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentConfigurer.java
index 0664b01dc0fd..775b1dd4de36 100644
---
a/components/camel-ai/camel-langchain4j-web-search/src/generated/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentConfigurer.java
+++
b/components/camel-ai/camel-langchain4j-web-search/src/generated/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentConfigurer.java
@@ -20,25 +20,77 @@ import
org.apache.camel.support.component.PropertyConfigurerSupport;
@SuppressWarnings("unchecked")
public class LangChain4jWebSearchComponentConfigurer extends
PropertyConfigurerSupport implements GeneratedPropertyConfigurer,
PropertyConfigurerGetter {
+ private
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration
getOrCreateConfiguration(LangChain4jWebSearchComponent target) {
+ if (target.getConfiguration() == null) {
+ target.setConfiguration(new
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration());
+ }
+ return target.getConfiguration();
+ }
+
@Override
public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
LangChain4jWebSearchComponent target = (LangChain4jWebSearchComponent)
obj;
switch (ignoreCase ? name.toLowerCase(Locale.ROOT) : name) {
+ case "additionalparams":
+ case "additionalParams":
getOrCreateConfiguration(target).setAdditionalParams(property(camelContext,
java.util.Map.class, value)); return true;
case "autowiredenabled":
case "autowiredEnabled":
target.setAutowiredEnabled(property(camelContext, boolean.class, value));
return true;
+ case "configuration": target.setConfiguration(property(camelContext,
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration.class,
value)); return true;
+ case "geolocation":
+ case "geoLocation":
getOrCreateConfiguration(target).setGeoLocation(property(camelContext,
java.lang.String.class, value)); return true;
+ case "language":
getOrCreateConfiguration(target).setLanguage(property(camelContext,
java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "maxresults":
+ case "maxResults":
getOrCreateConfiguration(target).setMaxResults(property(camelContext,
java.lang.Integer.class, value)); return true;
+ case "resulttype":
+ case "resultType":
getOrCreateConfiguration(target).setResultType(property(camelContext,
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType.class,
value)); return true;
+ case "safesearch":
+ case "safeSearch":
getOrCreateConfiguration(target).setSafeSearch(property(camelContext,
java.lang.Boolean.class, value)); return true;
+ case "startindex":
+ case "startIndex":
getOrCreateConfiguration(target).setStartIndex(property(camelContext,
java.lang.Integer.class, value)); return true;
+ case "startpage":
+ case "startPage":
getOrCreateConfiguration(target).setStartPage(property(camelContext,
java.lang.Integer.class, value)); return true;
+ case "websearchengine":
+ case "webSearchEngine":
getOrCreateConfiguration(target).setWebSearchEngine(property(camelContext,
dev.langchain4j.web.search.WebSearchEngine.class, value)); return true;
+ case "websearchrequest":
+ case "webSearchRequest":
getOrCreateConfiguration(target).setWebSearchRequest(property(camelContext,
dev.langchain4j.web.search.WebSearchRequest.class, value)); return true;
default: return false;
}
}
+ @Override
+ public String[] getAutowiredNames() {
+ return new String[]{"webSearchEngine"};
+ }
+
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase(Locale.ROOT) : name) {
+ case "additionalparams":
+ case "additionalParams": return java.util.Map.class;
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
+ case "configuration": return
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration.class;
+ case "geolocation":
+ case "geoLocation": return java.lang.String.class;
+ case "language": return java.lang.String.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
+ case "maxresults":
+ case "maxResults": return java.lang.Integer.class;
+ case "resulttype":
+ case "resultType": return
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType.class;
+ case "safesearch":
+ case "safeSearch": return java.lang.Boolean.class;
+ case "startindex":
+ case "startIndex": return java.lang.Integer.class;
+ case "startpage":
+ case "startPage": return java.lang.Integer.class;
+ case "websearchengine":
+ case "webSearchEngine": return
dev.langchain4j.web.search.WebSearchEngine.class;
+ case "websearchrequest":
+ case "webSearchRequest": return
dev.langchain4j.web.search.WebSearchRequest.class;
default: return null;
}
}
@@ -47,10 +99,39 @@ public class LangChain4jWebSearchComponentConfigurer
extends PropertyConfigurerS
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
LangChain4jWebSearchComponent target = (LangChain4jWebSearchComponent)
obj;
switch (ignoreCase ? name.toLowerCase(Locale.ROOT) : name) {
+ case "additionalparams":
+ case "additionalParams": return
getOrCreateConfiguration(target).getAdditionalParams();
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "configuration": return target.getConfiguration();
+ case "geolocation":
+ case "geoLocation": return
getOrCreateConfiguration(target).getGeoLocation();
+ case "language": return getOrCreateConfiguration(target).getLanguage();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
+ case "maxresults":
+ case "maxResults": return
getOrCreateConfiguration(target).getMaxResults();
+ case "resulttype":
+ case "resultType": return
getOrCreateConfiguration(target).getResultType();
+ case "safesearch":
+ case "safeSearch": return
getOrCreateConfiguration(target).getSafeSearch();
+ case "startindex":
+ case "startIndex": return
getOrCreateConfiguration(target).getStartIndex();
+ case "startpage":
+ case "startPage": return
getOrCreateConfiguration(target).getStartPage();
+ case "websearchengine":
+ case "webSearchEngine": return
getOrCreateConfiguration(target).getWebSearchEngine();
+ case "websearchrequest":
+ case "webSearchRequest": return
getOrCreateConfiguration(target).getWebSearchRequest();
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getCollectionValueType(Object target, String name, boolean
ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase(Locale.ROOT) : name) {
+ case "additionalparams":
+ case "additionalParams": return java.lang.Object.class;
default: return null;
}
}
diff --git
a/components/camel-ai/camel-langchain4j-web-search/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/web/search/langchain4j-web-search.json
b/components/camel-ai/camel-langchain4j-web-search/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/web/search/langchain4j-web-search.json
index 6fc010f1e32e..c1843994bc24 100644
---
a/components/camel-ai/camel-langchain4j-web-search/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/web/search/langchain4j-web-search.json
+++
b/components/camel-ai/camel-langchain4j-web-search/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/web/search/langchain4j-web-search.json
@@ -24,8 +24,19 @@
"remote": true
},
"componentProperties": {
- "lazyStartProducer": { "index": 0, "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": 1, "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 [...]
+ "additionalParams": { "index": 0, "kind": "property", "displayName":
"Additional Params", "group": "producer", "label": "", "required": false,
"type": "object", "javaType": "java.util.Map<java.lang.String,
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "More parameters for the
search engine, a [...]
+ "configuration": { "index": 1, "kind": "property", "displayName":
"Configuration", "group": "producer", "label": "", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description": "The
configuration that each endpoint starts from. Options set on the endpoint
override it." },
+ "geoLocation": { "index": 2, "kind": "property", "displayName": "Geo
Location", "group": "producer", "label": "", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The geographic location
of the search results, such as a country code, in the forma [...]
+ "language": { "index": 3, "kind": "property", "displayName": "Language",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The language of the
search results, in the format that the search engine expects. The Tavi [...]
+ "lazyStartProducer": { "index": 4, "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 [...]
+ "maxResults": { "index": 5, "kind": "property", "displayName": "Max
Results", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 1, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The number of results
that the producer asks the search engine f [...]
+ "resultType": { "index": 6, "kind": "property", "displayName": "Result
Type", "group": "producer", "label": "", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType",
"enum": [ "LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT", "CONTENT", "SNIPPET" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"CONTENT", "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jW [...]
+ "safeSearch": { "index": 7, "kind": "property", "displayName": "Safe
Search", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "Whether the search
engine filters explicit content out of the results. If not set, [...]
+ "startIndex": { "index": 8, "kind": "property", "displayName": "Start
Index", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The index of the first
search result to return, in the numbering that the search en [...]
+ "startPage": { "index": 9, "kind": "property", "displayName": "Start
Page", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The page number of the
search results to return. If not set, LangChain4j uses 1. The [...]
+ "webSearchEngine": { "index": 10, "kind": "property", "displayName": "Web
Search Engine", "group": "producer", "label": "", "required": false, "type":
"object", "javaType": "dev.langchain4j.web.search.WebSearchEngine",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The
dev.langchain4j.web.search.WebSearchEngine t [...]
+ "autowiredEnabled": { "index": 11, "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 [...]
+ "webSearchRequest": { "index": 12, "kind": "property", "displayName": "Web
Search Request", "group": "advanced", "label": "advanced", "required": false,
"type": "object", "javaType": "dev.langchain4j.web.search.WebSearchRequest",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "A
dev.langchain4j.web.search.WebSear [...]
},
"bodyTypes": {
"producerIn": { "carriers": [ "any" ], "description": "The search terms as
text; another body is converted to text, so a Map or a POJO is searched as its
toString(), and no body fails. With webSearchRequest the body is not read" },
@@ -36,12 +47,12 @@
"additionalParams": { "index": 1, "kind": "parameter", "displayName":
"Additional Params", "group": "producer", "label": "", "required": false,
"type": "object", "javaType": "java.util.Map<java.lang.String,
java.lang.Object>", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "More parameters for the
search engine, [...]
"geoLocation": { "index": 2, "kind": "parameter", "displayName": "Geo
Location", "group": "producer", "label": "", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The geographic location
of the search results, such as a country code, in the form [...]
"language": { "index": 3, "kind": "parameter", "displayName": "Language",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The language of the
search results, in the format that the search engine expects. The Tav [...]
- "maxResults": { "index": 4, "kind": "parameter", "displayName": "Max
Results", "group": "producer", "label": "", "required": true, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 1, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The number of results
that the producer asks the search engine f [...]
- "resultType": { "index": 5, "kind": "parameter", "displayName": "Result
Type", "group": "producer", "label": "", "required": true, "type": "enum",
"javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType",
"enum": [ "LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT", "CONTENT", "SNIPPET" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"CONTENT", "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jW [...]
+ "maxResults": { "index": 4, "kind": "parameter", "displayName": "Max
Results", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 1, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The number of results
that the producer asks the search engine [...]
+ "resultType": { "index": 5, "kind": "parameter", "displayName": "Result
Type", "group": "producer", "label": "", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType",
"enum": [ "LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT", "CONTENT", "SNIPPET" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"CONTENT", "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4j [...]
"safeSearch": { "index": 6, "kind": "parameter", "displayName": "Safe
Search", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "Whether the search
engine filters explicit content out of the results. If not set, [...]
"startIndex": { "index": 7, "kind": "parameter", "displayName": "Start
Index", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The index of the first
search result to return, in the numbering that the search e [...]
"startPage": { "index": 8, "kind": "parameter", "displayName": "Start
Page", "group": "producer", "label": "", "required": false, "type": "integer",
"javaType": "java.lang.Integer", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The page number of the
search results to return. If not set, LangChain4j uses 1. The [...]
- "webSearchEngine": { "index": 9, "kind": "parameter", "displayName": "Web
Search Engine", "group": "producer", "label": "", "required": true, "type":
"object", "javaType": "dev.langchain4j.web.search.WebSearchEngine",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The
dev.langchain4j.web.search.WebSearchEngine th [...]
+ "webSearchEngine": { "index": 9, "kind": "parameter", "displayName": "Web
Search Engine", "group": "producer", "label": "", "required": false, "type":
"object", "javaType": "dev.langchain4j.web.search.WebSearchEngine",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "The
dev.langchain4j.web.search.WebSearchEngine t [...]
"lazyStartProducer": { "index": 10, "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 produ [...]
"webSearchRequest": { "index": 11, "kind": "parameter", "displayName":
"Web Search Request", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"dev.langchain4j.web.search.WebSearchRequest", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration",
"configurationField": "configuration", "description": "A
dev.langchain4j.web.search.WebSea [...]
}
diff --git
a/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponent.java
b/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponent.java
index b1dab154dac3..4d03d546f036 100644
---
a/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponent.java
+++
b/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponent.java
@@ -43,6 +43,13 @@ public class LangChain4jWebSearchComponent extends
DefaultComponent {
return configuration;
}
+ /**
+ * The configuration that each endpoint starts from. Options set on the
endpoint override it.
+ */
+ public void setConfiguration(LangChain4jWebSearchConfiguration
configuration) {
+ this.configuration = configuration;
+ }
+
@Override
protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
LangChain4jWebSearchConfiguration configuration =
this.configuration.copy();
diff --git
a/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchConfiguration.java
b/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchConfiguration.java
index d6b4eb27ceb6..a3fab150f538 100644
---
a/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchConfiguration.java
+++
b/components/camel-ai/camel-langchain4j-web-search/src/main/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchConfiguration.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.langchain4j.web.search;
+import java.util.HashMap;
import java.util.Map;
import dev.langchain4j.web.search.WebSearchEngine;
@@ -30,14 +31,15 @@ import org.apache.camel.spi.UriParams;
@UriParams
public class LangChain4jWebSearchConfiguration implements Cloneable {
- @Metadata(required = true, autowired = true)
+ // not required in the catalog: the endpoint, the component or autowiring
can give it, and the producer checks it
+ @Metadata(autowired = true)
@UriParam(description = "The dev.langchain4j.web.search.WebSearchEngine
that runs the search, for example a"
+ " TavilyWebSearchEngine or a
GoogleCustomWebSearchEngine of the LangChain4j web search engine"
- + " modules. If not set, the single instance in
the registry is used, and the producer fails to"
- + " start when there is none.")
+ + " modules. It can be set on the endpoint or on
the component. If neither sets it, the single"
+ + " instance in the registry is used, and the
producer fails to start when there is none.")
private WebSearchEngine webSearchEngine;
- @Metadata(required = true, defaultValue = "CONTENT")
+ @Metadata(defaultValue = "CONTENT")
@UriParam(description = "What the producer returns for each result:
CONTENT its content as a String, or its snippet when"
+ " the result has no content (as some engines
give none), SNIPPET its snippet, or"
+ " LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT the
dev.langchain4j.web.search.WebSearchOrganicResult."
@@ -45,7 +47,7 @@ public class LangChain4jWebSearchConfiguration implements
Cloneable {
+ " when there is no result.")
private LangChain4jWebSearchResultType resultType =
LangChain4jWebSearchResultType.CONTENT;
- @Metadata(required = true, defaultValue = "1")
+ @Metadata(defaultValue = "1")
@UriParam(description = "The number of results that the producer asks the
search engine for. With 1 the body is a single"
+ " result, otherwise a List. An engine can return
fewer results and can have its own maximum.")
private Integer maxResults = 1;
@@ -157,7 +159,13 @@ public class LangChain4jWebSearchConfiguration implements
Cloneable {
public LangChain4jWebSearchConfiguration copy() {
try {
- return (LangChain4jWebSearchConfiguration) super.clone();
+ LangChain4jWebSearchConfiguration copy =
(LangChain4jWebSearchConfiguration) super.clone();
+ if (additionalParams != null) {
+ // each endpoint gets its own map: a key bound on an endpoint
must not reach the component and the other
+ // endpoints
+ copy.additionalParams = new HashMap<>(additionalParams);
+ }
+ return copy;
} catch (CloneNotSupportedException e) {
throw new RuntimeCamelException(e);
}
diff --git
a/components/camel-ai/camel-langchain4j-web-search/src/test/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentOptionsTest.java
b/components/camel-ai/camel-langchain4j-web-search/src/test/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentOptionsTest.java
new file mode 100644
index 000000000000..a5176028d939
--- /dev/null
+++
b/components/camel-ai/camel-langchain4j-web-search/src/test/java/org/apache/camel/component/langchain4j/web/search/LangChain4jWebSearchComponentOptionsTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.web.search;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import dev.langchain4j.web.search.WebSearchEngine;
+import dev.langchain4j.web.search.WebSearchInformationResult;
+import dev.langchain4j.web.search.WebSearchOrganicResult;
+import dev.langchain4j.web.search.WebSearchRequest;
+import dev.langchain4j.web.search.WebSearchResults;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.support.PropertyBindingSupport;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * The search options can be set on the component, as
camel.component.langchain4j-web-search.* properties do, and an
+ * endpoint without options uses them.
+ */
+public class LangChain4jWebSearchComponentOptionsTest extends CamelTestSupport
{
+
+ private final AtomicReference<WebSearchRequest> componentEngineRequest =
new AtomicReference<>();
+ private final AtomicReference<WebSearchRequest> otherEngineRequest = new
AtomicReference<>();
+
+ private final WebSearchEngine componentEngine = request -> {
+ componentEngineRequest.set(request);
+ return results();
+ };
+
+ private final WebSearchEngine otherEngine = request -> {
+ otherEngineRequest.set(request);
+ return results();
+ };
+
+ private static WebSearchResults results() {
+ return WebSearchResults.from(
+ WebSearchInformationResult.from(2L),
+ List.of(WebSearchOrganicResult.from("Title",
URI.create("https://example.com"), "snippet", "content"),
+ WebSearchOrganicResult.from("Title 2",
URI.create("https://example.org"), "snippet 2",
+ "content 2")));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ // two engines in the registry, so that the endpoint cannot autowire
one: the engine must come from the component
+ context.getRegistry().bind("componentEngine", componentEngine);
+ context.getRegistry().bind("otherEngine", otherEngine);
+
+ LangChain4jWebSearchComponent component
+ = context.getComponent(LangChain4jWebSearchEngine.SCHEME,
LangChain4jWebSearchComponent.class);
+ Map<String, Object> properties = new HashMap<>();
+ properties.put("webSearchEngine", "#componentEngine");
+ properties.put("maxResults", "2");
+ properties.put("resultType", "SNIPPET");
+ properties.put("language", "de");
+ PropertyBindingSupport.build()
+ .withCamelContext(context)
+ .withTarget(component)
+ .withConfigurer(component.getComponentPropertyConfigurer())
+ .withProperties(properties)
+ .withMandatory(true)
+ .bind();
+
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:component")
+ .to("langchain4j-web-search:component");
+
+ from("direct:override")
+
.to("langchain4j-web-search:override?maxResults=1&resultType=CONTENT&webSearchEngine=#otherEngine");
+ }
+ };
+ }
+
+ @Test
+ void endpointWithoutOptionsUsesTheComponentOptions() {
+ Object body = template.requestBody("direct:component", "apache camel");
+
+ WebSearchRequest request = componentEngineRequest.get();
+ assertNotNull(request);
+ assertEquals("apache camel", request.searchTerms());
+ assertEquals(2, request.maxResults());
+ assertEquals("de", request.language());
+ assertEquals(List.of("snippet", "snippet 2"), body);
+ assertNull(otherEngineRequest.get());
+ }
+
+ @Test
+ void endpointOptionsOverrideTheComponentOptions() {
+ Object body = template.requestBody("direct:override", "apache camel");
+
+ WebSearchRequest request = otherEngineRequest.get();
+ assertNotNull(request);
+ assertEquals(1, request.maxResults());
+ // not set on the endpoint, so the component value is used
+ assertEquals("de", request.language());
+ assertEquals("content", body);
+ assertNull(componentEngineRequest.get());
+ }
+
+ @Test
+ void anAdditionalParamOfAnEndpointStaysOnThatEndpoint() {
+ LangChain4jWebSearchComponent component
+ = context.getComponent(LangChain4jWebSearchEngine.SCHEME,
LangChain4jWebSearchComponent.class);
+ component.getConfiguration().setAdditionalParams(new
HashMap<>(Map.of("a", "1")));
+
+ LangChain4jWebSearchEndpoint withB = context.getEndpoint(
+ "langchain4j-web-search:withB?additionalParams[b]=2",
LangChain4jWebSearchEndpoint.class);
+ LangChain4jWebSearchEndpoint plain
+ = context.getEndpoint("langchain4j-web-search:plain",
LangChain4jWebSearchEndpoint.class);
+
+ assertEquals(Map.of("a", "1", "b", "2"),
withB.getConfiguration().getAdditionalParams());
+ // without the deep-copy fix in copy(), b would have leaked into the
component and every other endpoint
+ assertEquals(Map.of("a", "1"),
component.getConfiguration().getAdditionalParams());
+ assertEquals(Map.of("a", "1"),
plain.getConfiguration().getAdditionalParams());
+ }
+}
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jWebSearchComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jWebSearchComponentBuilderFactory.java
index d8b147528806..b99488e1f142 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jWebSearchComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jWebSearchComponentBuilderFactory.java
@@ -52,6 +52,75 @@ public interface Langchain4jWebSearchComponentBuilderFactory
{
*/
interface Langchain4jWebSearchComponentBuilder extends
ComponentBuilder<LangChain4jWebSearchComponent> {
+ /**
+ * More parameters for the search engine, as a Map of names to values,
+ * such as the parameters of the search API that no option covers.
Which
+ * names are used depends on the engine, and the Tavily engine ignores
+ * them.
+ *
+ * The option is a: <code>java.util.Map&lt;java.lang.String,
+ * java.lang.Object&gt;</code> type.
+ *
+ * Group: producer
+ *
+ * @param additionalParams the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
additionalParams(java.util.Map<java.lang.String, java.lang.Object>
additionalParams) {
+ doSetProperty("additionalParams", additionalParams);
+ return this;
+ }
+
+ /**
+ * The configuration that each endpoint starts from. Options set on the
+ * endpoint override it.
+ *
+ * The option is a:
+ *
<code>org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration</code>
type.
+ *
+ * Group: producer
+ *
+ * @param configuration the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
configuration(org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration
configuration) {
+ doSetProperty("configuration", configuration);
+ return this;
+ }
+
+ /**
+ * The geographic location of the search results, such as a country
+ * code, in the format that the search engine expects. The Tavily
engine
+ * ignores it.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ *
+ * @param geoLocation the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
geoLocation(java.lang.String geoLocation) {
+ doSetProperty("geoLocation", geoLocation);
+ return this;
+ }
+
+ /**
+ * The language of the search results, in the format that the search
+ * engine expects. The Tavily engine ignores it.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ *
+ * @param language the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder language(java.lang.String
language) {
+ doSetProperty("language", language);
+ return this;
+ }
+
/**
* Whether the producer should be started lazy (on the first message).
@@ -78,6 +147,120 @@ public interface
Langchain4jWebSearchComponentBuilderFactory {
}
+ /**
+ * The number of results that the producer asks the search engine for.
+ * With 1 the body is a single result, otherwise a List. An engine can
+ * return fewer results and can have its own maximum.
+ *
+ * The option is a: <code>java.lang.Integer</code> type.
+ *
+ * Default: 1
+ * Group: producer
+ *
+ * @param maxResults the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
maxResults(java.lang.Integer maxResults) {
+ doSetProperty("maxResults", maxResults);
+ return this;
+ }
+
+
+ /**
+ * What the producer returns for each result: CONTENT its content as a
+ * String, or its snippet when the result has no content (as some
+ * engines give none), SNIPPET its snippet, or
+ * LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT the
+ * dev.langchain4j.web.search.WebSearchOrganicResult. The body is a
+ * single value when the request asks for one result, otherwise a List,
+ * and null when there is no result.
+ *
+ * The option is a:
+ *
<code>org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType</code>
type.
+ *
+ * Default: CONTENT
+ * Group: producer
+ *
+ * @param resultType the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
resultType(org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType
resultType) {
+ doSetProperty("resultType", resultType);
+ return this;
+ }
+
+ /**
+ * Whether the search engine filters explicit content out of the
+ * results. If not set, LangChain4j uses true. The Tavily engine
ignores
+ * it.
+ *
+ * The option is a: <code>java.lang.Boolean</code> type.
+ *
+ * Group: producer
+ *
+ * @param safeSearch the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
safeSearch(java.lang.Boolean safeSearch) {
+ doSetProperty("safeSearch", safeSearch);
+ return this;
+ }
+
+ /**
+ * The index of the first search result to return, in the numbering
that
+ * the search engine uses. The Tavily engine ignores it.
+ *
+ * The option is a: <code>java.lang.Integer</code> type.
+ *
+ * Group: producer
+ *
+ * @param startIndex the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
startIndex(java.lang.Integer startIndex) {
+ doSetProperty("startIndex", startIndex);
+ return this;
+ }
+
+ /**
+ * The page number of the search results to return. If not set,
+ * LangChain4j uses 1. The Tavily engine ignores it.
+ *
+ * The option is a: <code>java.lang.Integer</code> type.
+ *
+ * Group: producer
+ *
+ * @param startPage the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
startPage(java.lang.Integer startPage) {
+ doSetProperty("startPage", startPage);
+ return this;
+ }
+
+ /**
+ * The dev.langchain4j.web.search.WebSearchEngine that runs the search,
+ * for example a TavilyWebSearchEngine or a GoogleCustomWebSearchEngine
+ * of the LangChain4j web search engine modules. It can be set on the
+ * endpoint or on the component. If neither sets it, the single
instance
+ * in the registry is used, and the producer fails to start when there
+ * is none.
+ *
+ * The option is a:
+ * <code>dev.langchain4j.web.search.WebSearchEngine</code>
+ * type.
+ *
+ * Group: producer
+ *
+ * @param webSearchEngine the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
webSearchEngine(dev.langchain4j.web.search.WebSearchEngine webSearchEngine) {
+ doSetProperty("webSearchEngine", webSearchEngine);
+ return this;
+ }
+
+
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in
the
@@ -98,6 +281,26 @@ public interface
Langchain4jWebSearchComponentBuilderFactory {
doSetProperty("autowiredEnabled", autowiredEnabled);
return this;
}
+
+ /**
+ * A dev.langchain4j.web.search.WebSearchRequest that the producer
sends
+ * as it is. When set, the producer does not read the message body and
+ * does not use the other search options, and only a maxResults of 1 in
+ * this request gives a single result instead of a List.
+ *
+ * The option is a:
+ * <code>dev.langchain4j.web.search.WebSearchRequest</code>
+ * type.
+ *
+ * Group: advanced
+ *
+ * @param webSearchRequest the value to set
+ * @return the dsl builder
+ */
+ default Langchain4jWebSearchComponentBuilder
webSearchRequest(dev.langchain4j.web.search.WebSearchRequest webSearchRequest) {
+ doSetProperty("webSearchRequest", webSearchRequest);
+ return this;
+ }
}
class Langchain4jWebSearchComponentBuilderImpl
@@ -107,14 +310,31 @@ public interface
Langchain4jWebSearchComponentBuilderFactory {
protected LangChain4jWebSearchComponent buildConcreteComponent() {
return new LangChain4jWebSearchComponent();
}
+ private
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration
getOrCreateConfiguration(LangChain4jWebSearchComponent component) {
+ if (component.getConfiguration() == null) {
+ component.setConfiguration(new
org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration());
+ }
+ return component.getConfiguration();
+ }
@Override
protected boolean setPropertyOnComponent(
Component component,
String name,
Object value) {
switch (name) {
+ case "additionalParams":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setAdditionalParams((java.util.Map) value); return true;
+ case "configuration": ((LangChain4jWebSearchComponent)
component).setConfiguration((org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchConfiguration)
value); return true;
+ case "geoLocation":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setGeoLocation((java.lang.String) value); return true;
+ case "language":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setLanguage((java.lang.String) value); return true;
case "lazyStartProducer": ((LangChain4jWebSearchComponent)
component).setLazyStartProducer((boolean) value); return true;
+ case "maxResults":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setMaxResults((java.lang.Integer) value); return true;
+ case "resultType":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setResultType((org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType)
value); return true;
+ case "safeSearch":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setSafeSearch((java.lang.Boolean) value); return true;
+ case "startIndex":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setStartIndex((java.lang.Integer) value); return true;
+ case "startPage":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setStartPage((java.lang.Integer) value); return true;
+ case "webSearchEngine":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setWebSearchEngine((dev.langchain4j.web.search.WebSearchEngine)
value); return true;
case "autowiredEnabled": ((LangChain4jWebSearchComponent)
component).setAutowiredEnabled((boolean) value); return true;
+ case "webSearchRequest":
getOrCreateConfiguration((LangChain4jWebSearchComponent)
component).setWebSearchRequest((dev.langchain4j.web.search.WebSearchRequest)
value); return true;
default: return false;
}
}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jWebSearchEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jWebSearchEndpointBuilderFactory.java
index 596de2f89be3..e3cbd9a29c8e 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jWebSearchEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jWebSearchEndpointBuilderFactory.java
@@ -120,7 +120,6 @@ public interface LangChain4jWebSearchEndpointBuilderFactory
{
*
* The option is a: <code>java.lang.Integer</code> type.
*
- * Required: true
* Default: 1
* Group: producer
*
@@ -139,7 +138,6 @@ public interface LangChain4jWebSearchEndpointBuilderFactory
{
* The option will be converted to a <code>java.lang.Integer</code>
* type.
*
- * Required: true
* Default: 1
* Group: producer
*
@@ -162,7 +160,6 @@ public interface LangChain4jWebSearchEndpointBuilderFactory
{
* The option is a:
*
<code>org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType</code>
type.
*
- * Required: true
* Default: CONTENT
* Group: producer
*
@@ -185,7 +182,6 @@ public interface LangChain4jWebSearchEndpointBuilderFactory
{
* The option will be converted to a
*
<code>org.apache.camel.component.langchain4j.web.search.LangChain4jWebSearchResultType</code>
type.
*
- * Required: true
* Default: CONTENT
* Group: producer
*
@@ -294,14 +290,14 @@ public interface
LangChain4jWebSearchEndpointBuilderFactory {
/**
* The dev.langchain4j.web.search.WebSearchEngine that runs the search,
* for example a TavilyWebSearchEngine or a GoogleCustomWebSearchEngine
- * of the LangChain4j web search engine modules. If not set, the single
- * instance in the registry is used, and the producer fails to start
- * when there is none.
+ * of the LangChain4j web search engine modules. It can be set on the
+ * endpoint or on the component. If neither sets it, the single
instance
+ * in the registry is used, and the producer fails to start when there
+ * is none.
*
* The option is a:
* <code>dev.langchain4j.web.search.WebSearchEngine</code> type.
*
- * Required: true
* Group: producer
*
* @param webSearchEngine the value to set
@@ -314,14 +310,14 @@ public interface
LangChain4jWebSearchEndpointBuilderFactory {
/**
* The dev.langchain4j.web.search.WebSearchEngine that runs the search,
* for example a TavilyWebSearchEngine or a GoogleCustomWebSearchEngine
- * of the LangChain4j web search engine modules. If not set, the single
- * instance in the registry is used, and the producer fails to start
- * when there is none.
+ * of the LangChain4j web search engine modules. It can be set on the
+ * endpoint or on the component. If neither sets it, the single
instance
+ * in the registry is used, and the producer fails to start when there
+ * is none.
*
* The option will be converted to a
* <code>dev.langchain4j.web.search.WebSearchEngine</code> type.
*
- * Required: true
* Group: producer
*
* @param webSearchEngine the value to set