Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Orchestration] Convenience for response format #341

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Jonas-Isr
Copy link
Member

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.withJsonSchemaResponse(schema);

If only any JSON response is wanted, without strict adherence to a given schema, the user can use
var configWithJsonResponse = config.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
  • convenience methods to add response format (JSON schema or JSON object) to config
    • had to overwrite OrchestrationModulConfig.withTemplateConfig() to make it work conveniently

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

}

@Test
void testResponseFormatOverwrittenByNewTemplateConfigWithResponseFormat() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the overwriting behaviours throw?
It could avoid customers asking why their response format is broken

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 think if the users set a response format in their new template config they will expect it to change, right? So I don't think we should throw here.

Jonas-Isr and others added 2 commits February 20, 2025 10:04
@Jonas-Isr Jonas-Isr removed the please-review Request to review a pull-request label Feb 21, 2025
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