LangChain4j Embeddings
LangChain4j Embeddings
What’s inside
-
LangChain4j Embeddings component, URI syntax:
langchain4j-embeddings:embeddingId
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-langchain4j-embeddings-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
Providing an EmbeddingModel
The Camel starter configures the component but does not create an EmbeddingModel. Add a LangChain4j provider starter and configure its embedding-model properties. Use the -spring-boot-starter variant with Spring Boot 3 or the -spring-boot4-starter variant with Spring Boot 4. For example, the Ollama starter creates an ollamaEmbeddingModel bean, which can be referenced with embeddingModel=#ollamaEmbeddingModel.
When exactly one EmbeddingModel is available, Camel autowires it and the embeddingModel endpoint option can be omitted. See the LangChain4j Spring Boot integration documentation for provider starters, properties, and compatible versions.
The starter supports 13 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.langchain4j-embeddings.api-key | The API key or access token of the provider, when the model is created from the provider. | String | |
camel.component.langchain4j-embeddings.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.langchain4j-embeddings.base-url | The URL of the provider’s API (http://localhost:11434 for a local Ollama), when the model is created from the provider. The provider’s default when not set. | String | |
camel.component.langchain4j-embeddings.configuration | The configuration. The option is a org.apache.camel.component.langchain4j.embeddings.LangChain4jEmbeddingsConfiguration type. | LangChain4jEmbeddingsConfiguration | |
camel.component.langchain4j-embeddings.custom-provider | The fully qualified class name of the LangChain4j model class of a provider that is not listed in provider (dev.langchain4j.model.jlama.JlamaChatModel), created from the options here through its builder() as a listed provider is. Set either provider or customProvider. | String | |
camel.component.langchain4j-embeddings.embedding-model | The EmbeddingModel engine to use. Either this or a provider is required. The option is a dev.langchain4j.model.embedding.EmbeddingModel type. | EmbeddingModel | |
camel.component.langchain4j-embeddings.enabled | Whether to enable auto configuration of the langchain4j-embeddings component. This is enabled by default. | Boolean | |
camel.component.langchain4j-embeddings.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.langchain4j-embeddings.model-name | The name of the model at the provider (qwen2.5, gpt-4o-mini, …), when the model is created from the provider. | String | |
camel.component.langchain4j-embeddings.model-properties | Provider-specific properties of the model, set on the model’s builder as they are (model.numPredict=512 for Ollama, model.maxTokens=1024 for OpenAI), when the model is created from the provider. This is a multi-value option with prefix: model. | Object> | |
camel.component.langchain4j-embeddings.provider | The LangChain4j provider of the embedding model, to create the model from the options here (modelName, baseUrl, apiKey, temperature, timeout, and provider-specific model. properties) instead of a EmbeddingModel bean. The LangChain4j module of the provider (dev.langchain4j:langchain4j-ollama, …) must be on the classpath; Camel JBang downloads it. Ignored when a EmbeddingModel is configured. For a provider not listed, set customProvider instead. | String | |
camel.component.langchain4j-embeddings.temperature | The sampling temperature of the model, when the model is created from the provider. | Double | |
camel.component.langchain4j-embeddings.timeout | The request timeout of the model (30s, 2m), when the model is created from the provider. | Duration |