Skip to content

0.8.0

Latest
Compare
Choose a tag to compare
@linux-china linux-china released this 07 Aug 14:38
· 6 commits to main since this release

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.