Demo: an AI product-description helper for Shop API
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
build the helper end to end. Prepares JNR-056-LAB1.
Draft outline details
Step by step
- Define
ProductDescriptionAssistantand theDescriptionrecord with validation annotations. - Add the Spring AI starter and set provider and model in configuration; the key comes from an environment variable.
- Implement it with
ChatClient,.entity(Description.class), a timeout, and a max-token limit. - Planned mistake: the first version asks for plain text and splits it by newline; the model adds extra lines and parsing breaks. Fix: request structured output and validate it.
- Add
POST /products/{id}/description-suggestionthat returns the record, or a Problem Details error for invalid output. - Write controller and service tests with the fake; confirm they pass offline.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.