عرض عملي: مساعد ذكي لكتابة أوصاف المنتجات في Shop API
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
build the helper end to end. Prepares JNR-056-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- 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.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.