Skip to content

Conversation

@Jonas-Isr
Copy link
Member

@Jonas-Isr Jonas-Isr commented Feb 19, 2025

Context

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

This PR adds convenience methods to set the response format in Orchestration. A JSON schema can be created from a class and then used as a response schema as follows:

var schema =
        ResponseJsonSchema.from(Translation.class)
            .withDescription("Output schema for language translation.")
            .withStrict(true);
val configWithResponseSchema = config.withTemplateConfig(TemplateConfig.create().withJsonSchemaResponse(schema));

If only any JSON response is wanted, without strict adherence to a given schema, the user can use
var configWithJsonResponse = config.withTemplateConfig(TemplateConfig.create().withJsonResponse()).

Feature scope:

  • Add a way to generate schema conveniently
    • Add new class ResponseJsonSchema
    • Add methods to create such schema from class or from a map
  • Add convenience layer for templates
    • Add new classes TemplateConfig, OrchestrationTemplate, and OrchestrationTemplateReference
    • convenience methods to add response format (JSON schema or JSON object) to config via TemplateConfig

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

@Jonas-Isr Jonas-Isr self-assigned this Feb 19, 2025
@Jonas-Isr Jonas-Isr added the please-review Request to review a pull-request label Feb 19, 2025
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.

Minor comments

@Jonas-Isr Jonas-Isr removed the please-review Request to review a pull-request label Feb 21, 2025
*/
@Tolerate
@Nonnull
@Beta
Copy link
Member Author

Choose a reason for hiding this comment

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

I added @Beta annotations to every new convenience method/class.

@Value
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@Beta
public class OrchestrationTemplateReference extends TemplateConfig {
Copy link
Member Author

Choose a reason for hiding this comment

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

I did not add tests for this class in OrchestrationUnitTests since this is part of BLI 184

@Jonas-Isr Jonas-Isr added the please-review Request to review a pull-request label Feb 27, 2025
newtork and others added 2 commits February 27, 2025 17:32
# Conflicts:
#	docs/release-notes/release_notes.md
@Jonas-Isr Jonas-Isr enabled auto-merge (squash) February 28, 2025 10:32
Copy link
Contributor

@newtork newtork left a comment

Choose a reason for hiding this comment

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

LGTM

@Jonas-Isr Jonas-Isr merged commit fcbf9fd into main Feb 28, 2025
6 checks passed
@Jonas-Isr Jonas-Isr deleted the orch-schema-convenience branch February 28, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please-review Request to review a pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants