Hugging Face

Integration with Hugging Face’s Model Hub by using the Deep Java Library (DJL) Python bridge

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-huggingface-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 24 options, which are listed below.

Name Description Default Type

camel.component.huggingface.auth-token

HF API token for private models

String

camel.component.huggingface.auto-select

If true, auto-select the best label (highest score) for zero-shot classification

true

Boolean

camel.component.huggingface.autowired-enabled

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 type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.huggingface.configuration

The configuration. The option is a org.apache.camel.component.huggingface.HuggingFaceConfiguration type.

HuggingFaceConfiguration

camel.component.huggingface.device

Device for inference (cpu, gpu, auto)

String

camel.component.huggingface.enabled

Whether to enable auto configuration of the huggingface component. This is enabled by default.

Boolean

camel.component.huggingface.health-check-consumer-enabled

Used for enabling or disabling all consumer based health checks from this component

true

Boolean

camel.component.huggingface.health-check-producer-enabled

Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.

true

Boolean

camel.component.huggingface.lazy-start-producer

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 during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.huggingface.max-tokens

Max tokens for generation tasks

Integer

camel.component.huggingface.memory-id-header

Header name for conversation memory ID (for multi-user chats)

CamelChatMemoryId

String

camel.component.huggingface.min-length

Min tokens for summarization tasks

Integer

camel.component.huggingface.model-id

Hugging Face model ID (e.g., distilbert-base-uncased-finetuned-sst-2-english)

String

camel.component.huggingface.model-loading-timeout

Model loading timeout in seconds, if negative then use default (240 seconds)

Integer

camel.component.huggingface.multi-label

Allow multi-label classifications for zero-shot tasks

false

Boolean

camel.component.huggingface.oauth-profile

OAuth profile name for obtaining an access token via the OAuth 2.0 Client Credentials grant. When set, the token is acquired from the configured identity provider and used as authToken. Requires camel-oauth on the classpath.

String

camel.component.huggingface.pooling

Whether to pool the predictor (keep the Python process alive) or create a new one for each request

true

Boolean

camel.component.huggingface.predict-timeout

Predict timeout in seconds, if negative then use default (120 seconds)

Integer

camel.component.huggingface.predictor-bean

Bean name of a custom TaskPredictor implementation (for tasks not covered by built-in predictors)

String

camel.component.huggingface.revision

Model revision or branch (default: main)

String

camel.component.huggingface.system-prompt

Initial system prompt for chat tasks (e.g., 'You are a helpful assistant named Alan.')

String

camel.component.huggingface.temperature

Temperature for sampling (0.0-1.0)

Float

camel.component.huggingface.top-k

Top-k parameter for classification tasks

5

Integer

camel.component.huggingface.user-role

Role for user messages in chat history (e.g., 'user' or 'human')

user

String