Skip to content

feat: support partial translation via apply_to array #768

Open
n-o-u-r-h-a-n wants to merge 42 commits intomainfrom
support-partial-translation
Open

feat: support partial translation via apply_to array #768
n-o-u-r-h-a-n wants to merge 42 commits intomainfrom
support-partial-translation

Conversation

@n-o-u-r-h-a-n
Copy link
Contributor

@n-o-u-r-h-a-n n-o-u-r-h-a-n commented Feb 25, 2026

Context

AI/ai-sdk-java-backlog#341.

Apply_to array is now supported instead of being set to null to support partial translation of the user's prompt.

Feature scope:

  • TranslationApplyToSelector a new class was created as a convenience builder for SAPDocumentTranslationApplyToSelector.
  • Sample code was updated.
  • Translation test was updated in OrchestrationTest.
    • New tests were added in OrchestrationModuleConfigTest to cover the new class methods.

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Aligned changes with the JavaScript SDK
  • Documentation updated
  • Release notes updated

Copy link
Contributor

@CharlesDuboisSAP CharlesDuboisSAP left a comment

Choose a reason for hiding this comment

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

Make sure the API that you write is fluent.

Not readable doesn't flow:

.withApplyTo(
  List.of(
    TranslationApplyToSelector.placeholders(List.of("exam_type", "topic")),
    TranslationApplyToSelector.templateRoles(TemplateRole.ASSISTANT)))

Readable and flows:

.applyToPlaceholders("exam_type", "topic")
.applyToTemplateRoles(TemplateRole.ASSISTANT)

n-o-u-r-h-a-n and others added 26 commits February 25, 2026 11:58
…es/OrchestrationService.java

Co-authored-by: Charles Dubois <103174266+CharlesDuboisSAP@users.noreply.github.com>
…o support-partial-translation

# Conflicts:
#	orchestration/src/main/java/com/sap/ai/sdk/orchestration/TranslationConfig.java
#	orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfigTest.java
Copy link
Member

@Jonas-Isr Jonas-Isr left a comment

Choose a reason for hiding this comment

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

Looks pretty good overall. Mostly smaller stuff I noticed 🙂

Copy link
Member

@Jonas-Isr Jonas-Isr left a comment

Choose a reason for hiding this comment

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

Looks mostly good :)

String targetLanguage;

@With String sourceLanguage;
@Getter String sourceLanguage;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Getter String sourceLanguage;
String sourceLanguage;

You don't need the @Getter here, @Value already adds getters to the fields.

Comment on lines +130 to +136
/**
* Set the source language for this translation. If no selectors are used, this applies to the
* whole message. If selectors are used, this applies to the most recently added selector.
*
* @param sourceLanguage The source language code
* @return A new Input with the given source language applied.
*/
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to highlight the behaviour a bit more.

Suggested change
/**
* Set the source language for this translation. If no selectors are used, this applies to the
* whole message. If selectors are used, this applies to the most recently added selector.
*
* @param sourceLanguage The source language code
* @return A new Input with the given source language applied.
*/
/**
* Set the source language for this translation.
* <br>
* <strong>Important Note:</strong> If no selectors are used, this applies to the
* whole message. If selectors are used, this applies to the most recently added selector.
*
* @param sourceLanguage The source language code
* @return A new Input with the given source language applied.
*/

String targetLanguage;

@With String sourceLanguage;
@Getter @With String sourceLanguage;
Copy link
Member

Choose a reason for hiding this comment

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

The getter is added by @Value already.

Suggested change
@Getter @With String sourceLanguage;
@With String sourceLanguage;

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants