LangChain4j Embedding Store
Add, remove and search embeddings in a LangChain4j embedding store (a vector database).
What’s inside
-
LangChain4j Embedding Store component, URI syntax:
langchain4j-embeddingstore:embeddingStoreId
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-langchain4j-embeddingstore-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
Providing embedding services
The component requires an EmbeddingStore bean. It can also use an EmbeddingModel to compute embeddings from plain-text message bodies. Configure either dependency with a compatible LangChain4j Spring Boot starter or provide it as a Spring bean. When more than one bean of either type is available, reference the intended bean explicitly with embeddingStore or embeddingModel on the endpoint.
See the LangChain4j Spring Boot integration documentation for provider and embedding-store starters, properties, and compatible versions.
The starter supports 11 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.langchain4j-embeddingstore.action | The operation to perform: ADD stores an embedding, REMOVE deletes embeddings by id or by Filter, and SEARCH returns the stored embeddings closest to a query embedding. The CamelLangchain4jEmbeddingStoreAction header overrides it, and one of the two is required. | LangChain4jEmbeddingStoreAction | |
camel.component.langchain4j-embeddingstore.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-embeddingstore.configuration | The shared configuration of the component. Each endpoint starts from a copy of it and then applies its own options. The option is a org.apache.camel.component.langchain4j.embeddingstore.LangChain4jEmbeddingStoreConfiguration type. | LangChain4jEmbeddingStoreConfiguration | |
camel.component.langchain4j-embeddingstore.embedding-model | The LangChain4j EmbeddingModel that embeds the message body when the CamelLangChain4jEmbeddingsEmbedding header (for a batch ADD the CamelLangChain4jEmbeddingsEmbeddings header) is not set. ADD stores the body as a TextSegment with its embedding (a List of String or TextSegment as a batch), and SEARCH uses the embedding of the body as the query. When the CamelLangChain4jEmbeddingsTextSegment header is set, that TextSegment is embedded instead of the body. The option is a dev.langchain4j.model.embedding.EmbeddingModel type. | EmbeddingModel | |
camel.component.langchain4j-embeddingstore.embedding-store | The LangChain4j EmbeddingStore of TextSegment that ADD, REMOVE and SEARCH work on. It is replaced by the store that the embeddingStoreFactory creates, when that option is set. The option is a dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment> type. | TextSegment> | |
camel.component.langchain4j-embeddingstore.embedding-store-factory | A factory that creates the EmbeddingStore when the producer starts. When set, the store it creates is used instead of the embeddingStore option. The option is a org.apache.camel.component.langchain4j.embeddingstore.EmbeddingStoreFactory type. | EmbeddingStoreFactory | |
camel.component.langchain4j-embeddingstore.enabled | Whether to enable auto configuration of the langchain4j-embeddingstore component. This is enabled by default. | Boolean | |
camel.component.langchain4j-embeddingstore.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-embeddingstore.max-results | The maximum number of matches that SEARCH returns (the maxResults of the LangChain4j EmbeddingSearchRequest); it must be greater than 0. The CamelLangchain4jEmbeddingStoreMaxResults header overrides it. | 5 | Integer |
camel.component.langchain4j-embeddingstore.min-score | The minimum relevance score, from 0.0 to 1.0, of the matches that SEARCH returns (the minScore of the LangChain4j EmbeddingSearchRequest). When it is not set, LangChain4j uses 0.0, so no match is left out by its score. The CamelLangchain4jEmbeddingStoreMinScore header overrides it. | Double | |
camel.component.langchain4j-embeddingstore.return-text-content | Whether SEARCH returns a List of the texts of the matched TextSegments instead of a List of EmbeddingMatch. A match that was stored without a TextSegment is left out of the list. | false | Boolean |