diff --git a/docs/docs/apis-generate/generate.md b/docs/docs/apis-generate/generate.md index c3a2d05..ee428f8 100644 --- a/docs/docs/apis-generate/generate.md +++ b/docs/docs/apis-generate/generate.md @@ -255,11 +255,12 @@ public class StructuredOutput { OllamaAPI api = new OllamaAPI(host); - String chatModel = "llama3.1:8b"; - chatModel = "qwen2.5:0.5b"; - api.pullModel(chatModel); + int age = 28; + boolean available = false; + + String prompt = "Batman is " + age + " years old and is " + (available ? "available" : "not available") + + " because he is busy saving Gotham City. Respond using JSON"; - String prompt = "Ollama is 22 years old and is busy saving the world. Respond using JSON"; Map format = new HashMap<>(); format.put("type", "object"); format.put("properties", new HashMap() { @@ -278,11 +279,12 @@ public class StructuredOutput { }); format.put("required", Arrays.asList("age", "available")); - OllamaResult result = api.generate(chatModel, prompt, format); - Person person = result.getStructuredResponse(Person.class); - System.out.println(person); - } + OllamaResult result = api.generate(CHAT_MODEL_QWEN_SMALL, prompt, format); + Person person = result.as(Person.class); + System.out.println(person.getAge()); + System.out.println(person.getAvailable()); + } } @Data diff --git a/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java b/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java index 435a365..f09aa4a 100644 --- a/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java +++ b/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java @@ -183,8 +183,6 @@ public class OllamaAPIIntegrationTest { assertNotNull(result.getResponse()); assertFalse(result.getResponse().isEmpty()); - System.out.println(result); - assertEquals(result.getStructuredResponse().get("age").toString(), result.getStructuredResponse().get("age").toString()); assertEquals(result.getStructuredResponse().get("available").toString(),