LangChain4j Ingest Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Preview"
Ingest documents into a LangChain4j EmbeddingStore: the payload is split into overlapping segments, embedded in batches and written to the store, each segment stamped with the pipeline name and the document id.
The document id is read from the CamelLangChain4jIngestDocumentId exchange property when a prior step captured it (the parser actions do, before the parse), else from the header named by documentIdHeader - the property always wins, so a parsed document cannot forge its own identity. Bean references are #bean:name values; when embeddingStore or embeddingModel is not set, the single registry bean of that type is used. With idempotentRepository set, the first write per document id wins - a re-delivered edited document is skipped, so streams that carry updates need a version-aware id. The filter options (includeId, excludeId, minDocumentSize, documentFilter) answer rejected deliveries with a filtered outcome that never keeps a dedup claim.
With modality set to media the payload (audio, an image, video or a PDF) is embedded whole, as one vector; the source must deliver raw bytes. A file source re-polls any document that fails the exchange on every run, so restrict the ids with includeId or the source’s include.
Configuration Options
The following table summarizes the configuration options available for the langchain4j-ingest-sink Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Content Type | MIME type of a media payload, such as audio/wav or image/png, handed to the embedding model. When unset, it is derived from the document id’s file extension (Camel’s MIME table); a document whose type cannot be determined, or whose medium the model does not declare, fails the exchange. Only valid with modality media, else the sink fails to start. | string | |||
Document Filter | A Predicate bean deciding whether a delivery is ingested, as a | string | |||
Document Id Header | Name of the header carrying the stable document id, such as CamelAwsS3Key for an S3 source or CamelKafkaKey for a Kafka one; the CamelLangChain4jIngestDocumentId exchange property, when set, takes precedence. | string | CamelLangChain4jIngestDocumentId | ||
Document Splitter | A DocumentSplitter bean replacing the default recursive splitting, as a | string | |||
Embedding Batch Size | How many segments are embedded per request to the embedding model. | integer | 32 | ||
Embedding Model | The EmbeddingModel bean to embed with, as a | string | |||
Embedding Store | The EmbeddingStore bean to write to, as a | string | |||
Exclude Id | Comma-separated Ant-style patterns for document ids to skip, for example | string | |||
Idempotent Repository | An IdempotentRepository bean remembering ingested document ids, as a | string | |||
Include Id | Comma-separated Ant-style patterns the document id must match to be ingested, for example | string | |||
Max Document Size | Maximum size of one document in characters, bytes with modality media; unset means no limit. The pipeline holds a document in memory whole, so set the cap when the source can deliver oversized payloads. An oversized document fails the exchange cleanly. | integer | |||
Max Overlap Size | How much of the previous segment each segment repeats, in characters. | integer | 50 | ||
Max Segment Size | Maximum size of one segment, in characters. | integer | 500 | ||
Min Document Size | Minimum size of one document in characters, bytes with modality media; unset means no minimum. A shorter document is answered filtered and releases its dedup claim. | integer | |||
Modality | What the payload is; text when unset. Enum values: * text * media | string | |||
Pipeline Name | The pipeline name, stamped on every written segment. | string | ingest |
Dependencies
At runtime, the langchain4j-ingest-sink Kamelet relies upon the presence of the following dependencies:
-
camel:langchain4j-ingest
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:langchain4j-ingest-sink" You can now run it directly through the following command
camel run route.yaml