Skip to content

CAMEL-24366: Add embeddingModel auto-embed to langchain4j-embeddingstore component - #25387

Merged
davsclaus merged 2 commits into
apache:mainfrom
JiriOndrusek:feature/embeddingstore-auto-embed
Aug 6, 2026
Merged

CAMEL-24366: Add embeddingModel auto-embed to langchain4j-embeddingstore component#25387
davsclaus merged 2 commits into
apache:mainfrom
JiriOndrusek:feature/embeddingstore-auto-embed

Conversation

@JiriOndrusek

@JiriOndrusek JiriOndrusek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

fixes https://issues.apache.org/jira/browse/CAMEL-24366

Summary

  • Adds an optional embeddingModel property (autowired) to the langchain4j-embeddingstore component
  • When configured, ADD and SEARCH operations accept plain text in the message body instead of requiring a pre-computed Embedding header
  • The existing CamelLangChain4jEmbeddingsEmbedding header always takes precedence when present, preserving backward compatibility

Changes

  • LangChain4jEmbeddingStoreConfiguration — new embeddingModel field with @UriParam and @Metadata(autowired = true)
  • LangChain4jEmbeddingStoreProducer — extracted shared resolveEmbedding() helper used by both add() and search(), with null-body guard and TextSegment header preservation
  • LangChain4jEmbeddingStoreAutoEmbedTest — 6 tests covering auto-embed ADD/SEARCH, header precedence, null body error, TextSegment preservation, and no-model fallback
  • Generated configurers, DSL builders, and catalog metadata regenerated

Test plan

  • Auto-embed ADD with plain text body
  • Auto-embed SEARCH with plain text body
  • Explicit embedding header takes precedence over auto-embed
  • Null body with auto-embed throws descriptive error
  • TextSegment header preserved when provided without embedding header
  • Missing model and header throws NoSuchHeaderException

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code on behalf of davsclaus

Nice feature addition — clean code, good test coverage, and well-documented. The header-takes-precedence design preserves backward compatibility nicely.

One question about a test dependency (see inline comment). Otherwise this looks good.

Note: this review covers project conventions and code structure. It does not replace specialized review tools such as CodeRabbit, Sourcery, or SonarCloud.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Comment thread components/camel-ai/camel-langchain4j-embeddingstore/pom.xml Outdated
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

JiriOndrusek and others added 2 commits August 6, 2026 15:35
…ore component

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JiriOndrusek
JiriOndrusek force-pushed the feature/embeddingstore-auto-embed branch from 53e3977 to 004cbbe Compare August 6, 2026 13:36
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-ai/camel-langchain4j-embeddingstore
  • docs
  • dsl/camel-componentdsl
  • dsl/camel-endpointdsl

🔬 Scalpel shadow comparison — Scalpel: 13 tested, 25 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 13 modules (5 direct + 8 downstream), skip tests for 25 (generated code, meta-modules)

Modules Scalpel would test (13)
  • camel-catalog
  • camel-componentdsl
  • camel-endpointdsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-langchain4j-embeddingstore
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • docs
Modules with tests skipped (25)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-csimple-maven-plugin
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: AI :: LangChain4j :: EmbeddingStore
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added the enhancement New feature or request label Aug 6, 2026
@davsclaus
davsclaus merged commit 57af72c into apache:main Aug 6, 2026
6 checks passed

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean feature with good backward compatibility and solid test coverage. The resolveEmbedding() extraction is a nice factoring. One logic issue found in the null-body guard, plus a minor Javadoc note.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of @gnodet

TextSegment textSegment = in.getHeader(LangChain4jEmbeddingsHeaders.TEXT_SEGMENT, TextSegment.class);

if (embedding == null && config.getEmbeddingModel() != null) {
String text = in.getBody(String.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null-body check here is unconditional within the auto-embed block, but it shouldn't be. When a TextSegment header is already present (fetched at line 236), the body text isn't needed — embed(textSegment) at line 249 will use the header-provided segment. Currently, sending a message with a TextSegment header but a null/non-String body will throw IllegalArgumentException even though there's enough information to compute the embedding.

Consider moving the body-fetch and null-check inside the if (textSegment == null) block:

Suggested change
String text = in.getBody(String.class);
if (textSegment == null) {
String text = in.getBody(String.class);
if (text == null) {
throw new IllegalArgumentException(
"Message body cannot be converted to String for auto-embedding. "
+ "Either set the body to a text value or provide a pre-computed embedding via the "
+ LangChain4jEmbeddingsHeaders.EMBEDDING + " header.");
}
textSegment = TextSegment.from(text);
}

Note: the existing test addWithTextSegmentHeaderPreservedDuringAutoEmbed always supplies a non-null body, so it doesn't catch this edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants