Skip to content

Commit 0a6f430

Browse files
authored
Update docs on setting response-format (#382)
Co-authored-by: Jonas Israel <[email protected]>
1 parent 75dea3f commit 0a6f430

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,17 @@ Note, that it is necessary to tell the AI model to actually return a JSON object
380380
If you want the response to not only consist of valid JSON but additionally adhere to a specific JSON schema, you can use `JSON_SCHEMA`. in order to do that, add a JSON schema to the configuration as shown below and the response will adhere to the given schema.
381381

382382
```java
383+
static class TestClass {
384+
@JsonProperty(required = true) // <-- this is necessary for the schema generation
385+
private String stringField;
386+
387+
@JsonProperty(required = true)
388+
private int intField;
389+
}
390+
383391
var schema =
384-
ResponseJsonSchema.fromType(MyClass.class)
385-
.withDescription("Output schema for the example class MyClass.")
392+
ResponseJsonSchema.fromType(TestClass.class)
393+
.withDescription("Output schema for the example class TestClass.")
386394
.withStrict(true);
387395
var config = new OrchestrationModuleConfig()
388396
.withLlmConfig(OrchestrationAiModel.GPT_4O);

0 commit comments

Comments
 (0)