Skip to content

Commit 5e20dbe

Browse files
committed
CAMEL-22545 new camel-huggingface component
1 parent 9ff951b commit 5e20dbe

40 files changed

+3634
-0
lines changed

bom/camel-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,11 @@
10921092
<artifactId>camel-huaweicloud-smn</artifactId>
10931093
<version>4.18.0-SNAPSHOT</version>
10941094
</dependency>
1095+
<dependency>
1096+
<groupId>org.apache.camel</groupId>
1097+
<artifactId>camel-huggingface</artifactId>
1098+
<version>4.18.0-SNAPSHOT</version>
1099+
</dependency>
10951100
<dependency>
10961101
<groupId>org.apache.camel</groupId>
10971102
<artifactId>camel-ibm-cos</artifactId>

catalog/camel-allcomponents/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,11 @@
952952
<artifactId>camel-huaweicloud-smn</artifactId>
953953
<version>${project.version}</version>
954954
</dependency>
955+
<dependency>
956+
<groupId>org.apache.camel</groupId>
957+
<artifactId>camel-huggingface</artifactId>
958+
<version>${project.version}</version>
959+
</dependency>
955960
<dependency>
956961
<groupId>org.apache.camel</groupId>
957962
<artifactId>camel-ibm-cos</artifactId>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<artifactId>camel-ai-parent</artifactId>
25+
<groupId>org.apache.camel</groupId>
26+
<version>4.18.0-SNAPSHOT</version>
27+
</parent>
28+
29+
<artifactId>camel-huggingface</artifactId>
30+
<packaging>jar</packaging>
31+
<name>Camel :: AI :: Hugging Face</name>
32+
<description>Integration with Hugging Face's Model Hub by using the Deep Java Library (DJL) Python bridge</description>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.apache.camel</groupId>
37+
<artifactId>camel-support</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.fasterxml.jackson.core</groupId>
41+
<artifactId>jackson-databind</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>ai.djl</groupId>
45+
<artifactId>api</artifactId>
46+
<version>${djl-version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>ai.djl.huggingface</groupId>
50+
<artifactId>tokenizers</artifactId>
51+
<version>${djl-version}</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>ai.djl.python</groupId>
55+
<artifactId>python</artifactId>
56+
<version>${djl-python-version}</version>
57+
<scope>runtime</scope>
58+
</dependency>
59+
60+
<!-- testing -->
61+
<dependency>
62+
<groupId>org.apache.camel</groupId>
63+
<artifactId>camel-test-junit5</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
</dependencies>
67+
<profiles>
68+
<profile>
69+
<id>huggingface</id>
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-failsafe-plugin</artifactId>
75+
<configuration>
76+
<forkedProcessTimeoutInSeconds>1200</forkedProcessTimeoutInSeconds>
77+
<skipITs>${skipITs}</skipITs>
78+
<skipTests>${skipTests}</skipTests>
79+
</configuration>
80+
<executions>
81+
<execution>
82+
<id>integration-test</id>
83+
<goals>
84+
<goal>integration-test</goal>
85+
<goal>verify</goal>
86+
</goals>
87+
<configuration>
88+
<skipITs>${skipITs}</skipITs>
89+
<groups>slow</groups>
90+
</configuration>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
</profile>
97+
</profiles>
98+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/* Generated by camel build tools - do NOT edit this file! */
2+
package org.apache.camel.component.huggingface;
3+
4+
import javax.annotation.processing.Generated;
5+
import java.util.Map;
6+
7+
import org.apache.camel.CamelContext;
8+
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
9+
import org.apache.camel.spi.PropertyConfigurerGetter;
10+
import org.apache.camel.spi.ConfigurerStrategy;
11+
import org.apache.camel.spi.GeneratedPropertyConfigurer;
12+
import org.apache.camel.util.CaseInsensitiveMap;
13+
import org.apache.camel.support.component.PropertyConfigurerSupport;
14+
15+
/**
16+
* Generated by camel build tools - do NOT edit this file!
17+
*/
18+
@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo")
19+
@SuppressWarnings("unchecked")
20+
public class HuggingFaceComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
21+
22+
private org.apache.camel.component.huggingface.HuggingFaceConfiguration getOrCreateConfiguration(HuggingFaceComponent target) {
23+
if (target.getConfiguration() == null) {
24+
target.setConfiguration(new org.apache.camel.component.huggingface.HuggingFaceConfiguration());
25+
}
26+
return target.getConfiguration();
27+
}
28+
29+
@Override
30+
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
31+
HuggingFaceComponent target = (HuggingFaceComponent) obj;
32+
switch (ignoreCase ? name.toLowerCase() : name) {
33+
case "authtoken":
34+
case "authToken": getOrCreateConfiguration(target).setAuthToken(property(camelContext, java.lang.String.class, value)); return true;
35+
case "autoselect":
36+
case "autoSelect": getOrCreateConfiguration(target).setAutoSelect(property(camelContext, boolean.class, value)); return true;
37+
case "autowiredenabled":
38+
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
39+
case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.huggingface.HuggingFaceConfiguration.class, value)); return true;
40+
case "device": getOrCreateConfiguration(target).setDevice(property(camelContext, java.lang.String.class, value)); return true;
41+
case "healthcheckconsumerenabled":
42+
case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true;
43+
case "healthcheckproducerenabled":
44+
case "healthCheckProducerEnabled": target.setHealthCheckProducerEnabled(property(camelContext, boolean.class, value)); return true;
45+
case "lazystartproducer":
46+
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
47+
case "maxtokens":
48+
case "maxTokens": getOrCreateConfiguration(target).setMaxTokens(property(camelContext, int.class, value)); return true;
49+
case "memoryidheader":
50+
case "memoryIdHeader": getOrCreateConfiguration(target).setMemoryIdHeader(property(camelContext, java.lang.String.class, value)); return true;
51+
case "minlength":
52+
case "minLength": getOrCreateConfiguration(target).setMinLength(property(camelContext, int.class, value)); return true;
53+
case "modelid":
54+
case "modelId": getOrCreateConfiguration(target).setModelId(property(camelContext, java.lang.String.class, value)); return true;
55+
case "modelloadingtimeout":
56+
case "modelLoadingTimeout": getOrCreateConfiguration(target).setModelLoadingTimeout(property(camelContext, int.class, value)); return true;
57+
case "multilabel":
58+
case "multiLabel": getOrCreateConfiguration(target).setMultiLabel(property(camelContext, boolean.class, value)); return true;
59+
case "predicttimeout":
60+
case "predictTimeout": getOrCreateConfiguration(target).setPredictTimeout(property(camelContext, int.class, value)); return true;
61+
case "predictorbean":
62+
case "predictorBean": getOrCreateConfiguration(target).setPredictorBean(property(camelContext, java.lang.String.class, value)); return true;
63+
case "revision": getOrCreateConfiguration(target).setRevision(property(camelContext, java.lang.String.class, value)); return true;
64+
case "systemprompt":
65+
case "systemPrompt": getOrCreateConfiguration(target).setSystemPrompt(property(camelContext, java.lang.String.class, value)); return true;
66+
case "temperature": getOrCreateConfiguration(target).setTemperature(property(camelContext, float.class, value)); return true;
67+
case "topk":
68+
case "topK": getOrCreateConfiguration(target).setTopK(property(camelContext, int.class, value)); return true;
69+
case "userrole":
70+
case "userRole": getOrCreateConfiguration(target).setUserRole(property(camelContext, java.lang.String.class, value)); return true;
71+
default: return false;
72+
}
73+
}
74+
75+
@Override
76+
public Class<?> getOptionType(String name, boolean ignoreCase) {
77+
switch (ignoreCase ? name.toLowerCase() : name) {
78+
case "authtoken":
79+
case "authToken": return java.lang.String.class;
80+
case "autoselect":
81+
case "autoSelect": return boolean.class;
82+
case "autowiredenabled":
83+
case "autowiredEnabled": return boolean.class;
84+
case "configuration": return org.apache.camel.component.huggingface.HuggingFaceConfiguration.class;
85+
case "device": return java.lang.String.class;
86+
case "healthcheckconsumerenabled":
87+
case "healthCheckConsumerEnabled": return boolean.class;
88+
case "healthcheckproducerenabled":
89+
case "healthCheckProducerEnabled": return boolean.class;
90+
case "lazystartproducer":
91+
case "lazyStartProducer": return boolean.class;
92+
case "maxtokens":
93+
case "maxTokens": return int.class;
94+
case "memoryidheader":
95+
case "memoryIdHeader": return java.lang.String.class;
96+
case "minlength":
97+
case "minLength": return int.class;
98+
case "modelid":
99+
case "modelId": return java.lang.String.class;
100+
case "modelloadingtimeout":
101+
case "modelLoadingTimeout": return int.class;
102+
case "multilabel":
103+
case "multiLabel": return boolean.class;
104+
case "predicttimeout":
105+
case "predictTimeout": return int.class;
106+
case "predictorbean":
107+
case "predictorBean": return java.lang.String.class;
108+
case "revision": return java.lang.String.class;
109+
case "systemprompt":
110+
case "systemPrompt": return java.lang.String.class;
111+
case "temperature": return float.class;
112+
case "topk":
113+
case "topK": return int.class;
114+
case "userrole":
115+
case "userRole": return java.lang.String.class;
116+
default: return null;
117+
}
118+
}
119+
120+
@Override
121+
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
122+
HuggingFaceComponent target = (HuggingFaceComponent) obj;
123+
switch (ignoreCase ? name.toLowerCase() : name) {
124+
case "authtoken":
125+
case "authToken": return getOrCreateConfiguration(target).getAuthToken();
126+
case "autoselect":
127+
case "autoSelect": return getOrCreateConfiguration(target).isAutoSelect();
128+
case "autowiredenabled":
129+
case "autowiredEnabled": return target.isAutowiredEnabled();
130+
case "configuration": return target.getConfiguration();
131+
case "device": return getOrCreateConfiguration(target).getDevice();
132+
case "healthcheckconsumerenabled":
133+
case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled();
134+
case "healthcheckproducerenabled":
135+
case "healthCheckProducerEnabled": return target.isHealthCheckProducerEnabled();
136+
case "lazystartproducer":
137+
case "lazyStartProducer": return target.isLazyStartProducer();
138+
case "maxtokens":
139+
case "maxTokens": return getOrCreateConfiguration(target).getMaxTokens();
140+
case "memoryidheader":
141+
case "memoryIdHeader": return getOrCreateConfiguration(target).getMemoryIdHeader();
142+
case "minlength":
143+
case "minLength": return getOrCreateConfiguration(target).getMinLength();
144+
case "modelid":
145+
case "modelId": return getOrCreateConfiguration(target).getModelId();
146+
case "modelloadingtimeout":
147+
case "modelLoadingTimeout": return getOrCreateConfiguration(target).getModelLoadingTimeout();
148+
case "multilabel":
149+
case "multiLabel": return getOrCreateConfiguration(target).isMultiLabel();
150+
case "predicttimeout":
151+
case "predictTimeout": return getOrCreateConfiguration(target).getPredictTimeout();
152+
case "predictorbean":
153+
case "predictorBean": return getOrCreateConfiguration(target).getPredictorBean();
154+
case "revision": return getOrCreateConfiguration(target).getRevision();
155+
case "systemprompt":
156+
case "systemPrompt": return getOrCreateConfiguration(target).getSystemPrompt();
157+
case "temperature": return getOrCreateConfiguration(target).getTemperature();
158+
case "topk":
159+
case "topK": return getOrCreateConfiguration(target).getTopK();
160+
case "userrole":
161+
case "userRole": return getOrCreateConfiguration(target).getUserRole();
162+
default: return null;
163+
}
164+
}
165+
}
166+

0 commit comments

Comments
 (0)