0.8.0
Structured Output
Please refer OpenAI Structured Outputs for detail.
First you need to define an record for structured output:
@StructuredOutput(name = "java_example")
public record JavaExample(@Parameter("explanation") String explanation, @Parameter("answer") String answer,
@Parameter("code") String code, @Parameter("dependencies") List<String> dependencies) {
}
Then you can use structured output record as return type as following:
@ChatCompletion(system = "You are a helpful Java language assistant.")
Mono<JavaExample> generateJavaExample(String question);
Attention: if the return type is not Mono<String>
, and it means structured output.