{"id":479766,"date":"2026-05-14T13:52:11","date_gmt":"2026-05-14T13:52:11","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=479766"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=479766","title":{"rendered":"\u0422\u0435\u0445\u043d\u0438\u043a\u0438 GenAI \u0432 Spring AI"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7d9\/19e\/9ad\/7d919e9ad9f071faf00261612d29ffd1.png\" width=\"780\" height=\"440\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/7d9\/19e\/9ad\/7d919e9ad9f071faf00261612d29ffd1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7d9\/19e\/9ad\/7d919e9ad9f071faf00261612d29ffd1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<blockquote>\n<p>\u041e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u2014\u00a0 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0445\u0430\u0439\u043a\u0443. \u0427\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0427\u0435\u0442\u044b\u0440\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438.<br \/>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043e\u0442 <code>chatClient.prompt().call()<\/code> \u0434\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e AI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 Anthropic API<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u042f \u0420\u0443\u0441\u043b\u0430\u043d \u041c\u0430\u0441\u0433\u0443\u0442\u043e\u0432, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u0432 \u0422-\u0411\u0430\u043d\u043a\u0435. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u044b \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u2014 \u0432\u0430\u0436\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u0438 \u0437\u043d\u0430\u0442\u044c \u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u044f\u0434 \u0442\u0435\u0445\u043d\u0438\u043a GenAI, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 Spring AI, \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u043c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 ChatClient \u043b\u0438\u0448\u044c \u0442\u043e\u043d\u043a\u043e\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 API \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 LLM \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 Anthropic, \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u043e \u0445\u043e\u0434\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<h2>\u041f\u0440\u043e\u043b\u043e\u0433: \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u043e\u0436\u0434\u0430\u044e\u0442 \u0445\u0430\u0439\u043a\u0443<\/h2>\n<p>\u0412\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u0438\u043d\u043d\u043e. \u041c\u044b Spring-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043e LLM, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 ChatGPT \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u0437\u043d\u0430\u0435\u043c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c LLM \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u0438. \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f: \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0445\u0430\u0439\u043a\u0443\/\u0445\u043e\u043a\u043a\u0443 (\u044f\u043f\u043e\u043d\u0441\u043a\u043e\u0435 \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435) \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0438\u0448\u0435\u0442 \u00ab\u0434\u043e\u0431\u0430\u0432\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u043e\u0441\u0435\u043d\u044c\u00bb \u2014\u00a0 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c <code>spring-ai-anthropic-spring-boot-starter<\/code>, \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c API-\u043a\u043b\u044e\u0447, \u0438 \u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<pre><code class=\"kotlin\">@RestController@RequestMapping(\"\/api\/haiku\")class HaikuController(private val haikuService: HaikuService) {  @PostMapping  fun generate(@Valid @RequestBody request: HaikuRequest): HaikuResponse =  HaikuResponse(haiku = haikuService.generate(request.prompt))}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<pre><code class=\"kotlin\">@Serviceclass HaikuService(chatClientBuilder: ChatClient.Builder) {  private val chatClient: ChatClient = chatClientBuilder.build()    fun generate(prompt: String): String =    chatClient    .prompt()    .user(prompt)    .call()    .content()    ?: error(\"ChatClient returned null content for prompt: $prompt\")}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"bash\">curl --location --request POST 'localhost:8080\/api\/haiku' \\  --header 'Content-Type: application\/json' \\  --data-raw '{  \"prompt\": \"\u041d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0438\u0445 \u043f\u0440\u043e \u043f\u043e\u0437\u0434\u043d\u044e\u044e \u0437\u0438\u043c\u0443\"  }'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"json\">{   \"haiku\": \"# \u0424\u0435\u0432\u0440\u0430\u043b\u044c\u0441\u043a\u043e\u0435\\n\\n\u0424\u0435\u0432\u0440\u0430\u043b\u044c \u0443\u0441\u0442\u0430\u043b. \u041e\u043d \u0434\u044b\u0448\u0438\u0442 \u0442\u044f\u0436\u0435\u043b\u043e,\\n\u0421\u0443\u0433\u0440\u043e\u0431\u044b \u043e\u0441\u0435\u043b\u0438, \u043f\u043e\u0442\u0435\u043c\u043d\u0435\u043b\u0438,\\n\u0418 \u0441\u043e\u043b\u043d\u0446\u0435 \u2014 \u0440\u043e\u0431\u043a\u043e\u0435, \u043d\u0435\u0441\u043c\u0435\u043b\u043e\u0435 \u2014\\n\u0412\u0441\u0451 \u0434\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441 \u0432 \u0442\u0435\u043f\u043b\u043e.\\n\\n\u041a\u0430\u043f\u0435\u043b\u044c \u0435\u0449\u0451 \u043d\u0435 \u0441\u043b\u044b\u0448\u043d\u043e, \u043d\u043e \u0443\u0436\u0435\\n\u0412 \u0432\u043e\u0437\u0434\u0443\u0445\u0435 \u0447\u0442\u043e-\u0442\u043e \u0442\u043e\u043d\u043a\u043e\u0435 \u0434\u0440\u043e\u0436\u0438\u0442,\\n\u0418 \u0432\u043e\u0440\u043e\u043d \u043d\u0430 \u0431\u0435\u0440\u0451\u0437\u0435 \u043d\u0435 \u0441\u043f\u0435\u0448\u0438\u0442 \u2014\\n\u0421\u0438\u0434\u0438\u0442 \u0438 \u0449\u0443\u0440\u0438\u0442\u0441\u044f \u0432 \u0442\u0438\u0448\u0438.\\n\\n\u0417\u0438\u043c\u0430 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u0448\u0430\u0442\u043a\u043e\u043c \u0440\u0443\u0431\u0435\u0436\u0435,\\n\u0426\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043d\u043e\u0447\u0438 \u0438 \u043c\u0435\u0442\u0435\u043b\u0438,\\n\u041d\u043e \u0434\u043d\u0438 \u2014 \u0434\u043b\u0438\u043d\u043d\u0435\u0435. \u041f\u0442\u0438\u0446\u044b \u043e\u0448\u0430\u043b\u0435\u043b\u0438\\n\u0418 \u0447\u0442\u043e-\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b\u0438 \u0432 \u0434\u0443\u0448\u0435.\\n\\n\u0415\u0449\u0451 \u043d\u0435 \u043c\u0430\u0440\u0442. \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u2014 \u043c\u0430\u0440\u0442.\\n\u0415\u0449\u0451 \u043c\u043e\u0440\u043e\u0437. \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u2014 \u0442\u0430\u043b\u043e\u0441\u0442\u044c.\\n\u0418 \u044d\u0442\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u0430\u044f \u0443\u0441\u0442\u0430\u043b\u043e\u0441\u0442\u044c\\n\u0417\u0438\u043c\u044b \u2014 \u043a\u0430\u043a \u0431\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0448\u0442\u0430\u043d\u0434\u0430\u0440\u0442.\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e-\u044f\u043f\u043e\u043d\u0441\u043a\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u2014\u00a0 \u043f\u0440\u043e\u0437\u043e\u0439. \u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u044b\u0434\u0430\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0435\u0445. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u0442 \u044d\u0441\u0441\u0435 \u043e \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0445\u0430\u0439\u043a\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0435\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c. \u041e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0412\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0435\u0433\u043e.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p><strong>\u041a\u0430\u0440\u0442\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430:<\/strong> \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0447\u0435\u0442\u044b\u0440\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<ol>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043f\u0438\u0448\u0435\u0442 \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u043b\u043e \u2014\u00a0 Prompt Engineering<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0432\u0435\u0442 &#8212; \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u2014\u00a0 Structured Output<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430 \u2014\u00a0 Chat Memory<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043d\u0430\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u043d\u044b\u043c \u044f\u0449\u0438\u043a\u043e\u043c \u2014\u00a0 Observability<\/p>\n<\/li>\n<\/ol>\n<h2>Prompt Engineering &#8212; \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0430\u0439\u043a\u0443<\/h2>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.\u00a0 <\/strong>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u00ab\u043d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u043b\u0438\u0441\u0442\u00bb.<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u043c\u0438. \u041c\u043e\u0434\u0435\u043b\u044c \u0442\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432, \u0442\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e. \u0422\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u0442\u043e \u043d\u0435\u0442. \u0422\u043e \u043f\u0438\u0448\u0435\u0442 \u043f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438, \u0442\u043e \u0432\u0434\u0440\u0443\u0433 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439.<\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u043e\u043d\u0430 \u0438 \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0435\u043b\u0430\u0442\u044c. \u041c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0433\u043e\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<\/p>\n<p><strong>\u0421\u043f\u0440\u0430\u0432\u043a\u0430: \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u043e\u043c\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430.\u00a0 <\/strong>\u0415\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 LLM \u043a\u0430\u043a \u043d\u0430 \u0447\u0435\u0440\u043d\u044b\u0439 \u044f\u0449\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u2014 \u043f\u0440\u043e\u043c\u0442 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c. \u041d\u043e \u0442\u043e\u0447\u043d\u0435\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043f\u0440\u043e\u043c\u0442\u0435 \u043a\u0430\u043a \u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u043c \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432. \u041e\u043d\u0430 \u0432\u0438\u0434\u0435\u043b\u0430 \u0442\u044b\u0441\u044f\u0447\u0438 \u0445\u0430\u0439\u043a\u0443, \u0442\u044b\u0441\u044f\u0447\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u0438\u043b \u0436\u0430\u043d\u0440\u0430, \u0442\u044b\u0441\u044f\u0447\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u0432. \u0412\u0441\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c, \u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041f\u0440\u043e\u043c\u0442 \u2014 \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0435 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u0438\u043a:<\/p>\n<p><strong>Zero-shot prompting<\/strong> \u2014\u00a0 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0431\u0435\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0414\u043b\u044f \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u2014 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e.<\/p>\n<p><strong>Few-shot prompting<\/strong> \u2014\u00a0 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0440\u043e\u043c\u0442\u0435. \u041c\u043e\u0434\u0435\u043b\u044c \u00ab\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u00bb \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e. \u0414\u043b\u044f \u0445\u0430\u0439\u043a\u0443 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0440\u0438-\u043f\u044f\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439.<\/p>\n<p><strong>Role prompting<\/strong> \u2014\u00a0 \u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u043e\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0433\u0440\u0430\u0442\u044c. \u00ab\u0422\u044b &#8212; \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443 \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0435\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u00ab\u043d\u0430\u043f\u0438\u0448\u0438 \u0445\u0430\u0439\u043a\u0443\u00bb. \u0420\u043e\u043b\u044c \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0442\u0438\u043b\u044c. \u042d\u0442\u043e \u043d\u0435 \u043c\u0430\u0433\u0438\u044f \u2014\u00a0 \u044d\u0442\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 in-context learning.<\/p>\n<p><strong>Chain-of-Thought (CoT)<\/strong> \u2014\u00a0 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u0434\u0443\u043c\u0430\u0442\u044c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u00bb. \u0414\u043b\u044f \u0445\u0430\u0439\u043a\u0443 \u044d\u0442\u043e \u00ab\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438 \u043e\u0431\u0440\u0430\u0437, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0439 \u0441\u043b\u043e\u0433\u0438, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0443\u00bb. \u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u2014\u00a0 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u0441 \u0436\u0435\u0441\u0442\u043a\u0438\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0442\u0438\u0445\u0430.<\/p>\n<p><strong>\u041f\u0440\u043e\u043c\u0442 \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u0434\u0435. <\/strong>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0440\u044b\u0432 \u2014\u00a0 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0442 \u043f\u0440\u044f\u043c\u043e \u0432 Kotlin-\u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"kotlin\">val systemPrompt = \"\"\"  \u0422\u044b \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443. \u041f\u0438\u0448\u0438 \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0451.  \u0421\u043e\u0431\u043b\u044e\u0434\u0430\u0439 \u043f\u0440\u0430\u0432\u0438\u043b\u043e 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432.  \u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0445\u0430\u0439\u043a\u0443, \u0431\u0435\u0437 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439.  \"\"\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u041f\u0440\u043e\u043c\u0442 \u2014\u00a0 \u044d\u0442\u043e \u043d\u0435 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u044d\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0447\u0430\u0449\u0435, \u0447\u0435\u043c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434: \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043d. \u041a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0442\u0430 \u0432 .kt-\u0444\u0430\u0439\u043b\u0435 \u2014\u00a0 \u043a\u043e\u043c\u043c\u0438\u0442, \u0440\u0435\u0432\u044c\u044e, \u0441\u0431\u043e\u0440\u043a\u0430, \u0434\u0435\u043f\u043b\u043e\u0439.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a Kotlin \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u043c\u0442\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/strong>. \u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>$theme<\/code> &#8212; \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u043c <code>$theme <\/code>\u0432 \u043f\u0440\u043e\u043c\u0442\u0435. \u0411\u0435\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0431\u0435\u0437 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>\u042d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043c\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0438\u043b\u0438 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u2014\u00a0 \u043d\u0443\u0436\u043d\u043e \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>. \u041e\u0434\u0438\u043d \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u043c\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0431\u0435\u0437 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c diff<\/strong>. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u043e\u043c\u0442\u0430 \u0432 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 Kotlin \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 diff \u0432 git.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u043c\u0442\u044b \u0432 \u0444\u0430\u0439\u043b\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u2014\u00a0 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u043c\u0435\u043d\u044f\u0442\u044c \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f 2 \u043f\u0440\u043e\u043c\u0442\u0430: \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u0442: \u0440\u043e\u043b\u044c, \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u0440\u0438\u043c\u0435\u0440\u044b. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u0445\u043d\u0438\u043a\u0438 role prompting \u0438 few-shot prompting. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>src\/main\/resources\/prompts\/system.st<\/code><\/p>\n<pre><code>\u0422\u044b \u2014 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0435, \u0432\u0435\u043b\u0438\u0447\u0430\u0439\u0448\u0438\u0439 \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443 \u044d\u043f\u043e\u0445\u0438 \u042d\u0434\u043e.\u0422\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0445\u0430\u0439\u043a\u0443: \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432.\u0422\u044b \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0438\u043c \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u2014 \u0431\u0435\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432, \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u0438 \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u0432 \u0441\u0442\u0440\u043e\u043a.\u041f\u0440\u0438\u043c\u0435\u0440\u044b:\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u041d\u0430\u043f\u0438\u0448\u0438, \u0422\u0435\u043c\u0430: \u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u0434\u043e\u0436\u0434\u044c\u041b\u0438\u0441\u0442\u044c\u044f \u0442\u0438\u0445\u043e \u043b\u044c\u043d\u0443\u0442\u043a \u043c\u043e\u043a\u0440\u044b\u043c \u043a\u0430\u043c\u043d\u044f\u043c \u0443 \u0442\u0440\u043e\u043f\u044b \u2014\u0434\u043e\u0436\u0434\u044c \u0441\u043c\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u043d\u044c\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u0421\u043e\u0447\u0438\u043d\u0438, \u0422\u0435\u043c\u0430: \u0440\u0430\u0441\u0441\u0432\u0435\u0442 \u043d\u0430\u0434 \u043c\u043e\u0440\u0435\u043c\u0410\u043b\u044b\u0439 \u043a\u0440\u0430\u0439 \u043d\u0435\u0431\u0435\u0441\u0431\u0443\u0434\u0438\u0442 \u0441\u043f\u044f\u0449\u0438\u0435 \u0432\u043e\u043b\u043d\u044b \u2014\u0447\u0430\u0439\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0441\u0442\u0430\u0435\u0442\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u0421\u043e\u0437\u0434\u0430\u0439, \u0422\u0435\u043c\u0430: \u043e\u0434\u0438\u043d\u043e\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0438\u043c\u043e\u0439\u0421\u043d\u0435\u0433 \u0437\u0430\u0441\u044b\u043f\u0430\u043b \u0441\u0430\u0434\u043d\u0435\u0442 \u043d\u0438 \u0441\u043b\u0435\u0434\u0430, \u043d\u0438 \u0433\u043e\u043b\u043e\u0441\u0430 \u2014\u0442\u043e\u043b\u044c\u043a\u043e \u044f \u0438 \u043d\u043e\u0447\u044c<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 <code>src\/main\/resources\/prompts\/user.st<\/code><\/p>\n<pre><code>{!\u041f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 (\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 PromptTemplate#createMessage, \u0432 LLM \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442):{command} \u2014 \u0433\u043b\u0430\u0433\u043e\u043b-\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u00ab\u041d\u0430\u043f\u0438\u0448\u0438\u00bb, \u00ab\u0421\u043e\u0447\u0438\u043d\u0438\u00bb, \u00ab\u0421\u043e\u0437\u0434\u0430\u0439\u00bb); max 200 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432{theme} \u2014 \u0442\u0435\u043c\u0430 \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0437 \u0445\u0430\u0439\u043a\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u00ab\u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u0434\u043e\u0436\u0434\u044c\u00bb, \u00ab\u0437\u0430\u043a\u0430\u0442 \u043d\u0430\u0434 \u0440\u0435\u043a\u043e\u0439\u00bb); max 200 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432!}{command}: {theme}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>{!<\/code> \u0438 <code>!}<\/code> \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u044e\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 StringTemplate \u0443\u0431\u0435\u0440\u0435\u0442 \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435.<\/p>\n<p><strong>\u041c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u0434\u043b\u044f StringTemplate (ST4). <\/strong>Spring AI \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443<a href=\"https:\/\/www.stringtemplate.org\/\"> StringTemplate 4 (ST4)<\/a>, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0422\u0435\u0440\u0435\u043d\u0441\u043e\u043c \u041f\u0430\u0440\u0440\u043e\u043c, \u0430\u0432\u0442\u043e\u0440\u043e\u043c ANTLR. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 ST4: &lt;variableName&gt; \u0432\u043c\u0435\u0441\u0442\u043e $variableName \u0432 Kotlin. \u0412 Spring AI \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a &lt;&gt; \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 {}<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 ST4, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<ul>\n<li>\n<p>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f. ST4 \u0431\u0440\u043e\u0441\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 runtime \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0430 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u043c\u0442 \u0441 &lt;theme&gt; \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435. \u041f\u0440\u043e\u043c\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b: &lt;if(examples)&gt;\u041f\u0440\u0438\u043c\u0435\u0440\u044b:\\n&lt;examples&gt;&lt;endif&gt;. \u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u0430 \u043d\u0435 \u0432 Java\/Kotlin-\u043a\u043e\u0434\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0428\u0430\u0431\u043b\u043e\u043d \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u043c\u0442\u0430. \u041a\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 MVC, \u043d\u043e \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 LLM.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041e\u0434\u0438\u043d .st-\u0444\u0430\u0439\u043b \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u043d\u0435 \u0441\u043c\u043e\u0433 \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 ST4, \u0430 \u043d\u0435 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 java\/kotlin-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. \u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p><strong>\u0412 Spring AI: \u043f\u0443\u0442\u044c \u0434\u043e AnthropicChatModel.call().<\/strong>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a .st-\u0444\u0430\u0439\u043b \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 Prompt \u043f\u0435\u0440\u0435\u0434 \u0443\u0445\u043e\u0434\u043e\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>\u0412 HaikuService.kt \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u043e\u043c\u0442\u043e\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<pre><code class=\"kotlin\">class HaikuService(  chatClientBuilder: ChatClient.Builder,  @Value(\"classpath:prompts\/system.st\") private val systemResource: Resource,  @Value(\"classpath:prompts\/user.st\") private val userResource: Resource,) {  private val chatClient: ChatClient = chatClientBuilder.build()    fun generate(command: String, theme: String): String {    val systemMessage = SystemPromptTemplate(systemResource).createMessage()    val userMessage = PromptTemplate(userResource)    .createMessage(mapOf(\"command\" to command, \"theme\" to theme))    return chatClient      .prompt(Prompt(listOf(systemMessage, userMessage)))      .call()      .content()      ?: error(\"ChatClient returned null content for command='$command', theme='$theme'\")  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<pre><code class=\"bash\">curl --location --request POST 'localhost:8080\/api\/haiku' \\\u2013-header 'Content-Type: application\/json' \\--data-raw '{\"command\": \"\u041d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0438\u0445 \u043f\u0440\u043e \u043f\u043e\u0437\u0434\u043d\u044e\u044e \u0437\u0438\u043c\u0443\",\"theme\": \"\u041a\u0438\u0431\u0435\u0440\u043f\u0430\u043d\u043a\"}'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442<\/p>\n<pre><code class=\"json\">{  \"haiku\": \"\u041d\u0435\u043e\u043d \u0441\u043a\u0432\u043e\u0437\u044c \u0442\u0443\u043c\u0430\u043d\\n\u0433\u0440\u0435\u0435\u0442 \u043c\u0435\u0440\u0442\u0432\u044b\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u2014\\n\u0441\u043d\u0435\u0433 \u043d\u0435 \u0442\u0430\u0435\u0442 \u0437\u0434\u0435\u0441\u044c\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b Spring AI, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435. <a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-model\/src\/main\/java\/org\/springframework\/ai\/chat\/prompt\/PromptTemplate.java#L64\">PromptTemplate<\/a> \u2014 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438.<\/p>\n<pre><code>public class PromptTemplate implements PromptTemplateActions, PromptTemplateMessageActions {  private static final Logger log = LoggerFactory.getLogger(PromptTemplate.class);    private static final TemplateRenderer DEFAULT_TEMPLATE_RENDERER = StTemplateRenderer.builder().build();      \/**  * If you're subclassing this class, re-consider using the built-in implementation  * together with the new PromptTemplateRenderer interface, designed to give you more  * flexibility and control over the rendering process.  *\/  private final String template;    private final Map&lt;String, Object&gt; variables = new HashMap&lt;&gt;();    private final TemplateRenderer renderer;    public PromptTemplate(Resource resource) {    this(resource, new HashMap&lt;&gt;(), DEFAULT_TEMPLATE_RENDERER);  }    \/\/.......    @Override  public String render(Map&lt;String, Object&gt; additionalVariables) {    Map&lt;String, @Nullable Object&gt; combinedVariables = new HashMap&lt;&gt;();    Map&lt;String, Object&gt; mergedVariables = new HashMap&lt;&gt;(this.variables);    \/\/ variables + additionalVariables =&gt; mergedVariables    if (additionalVariables != null &amp;&amp; !additionalVariables.isEmpty()) {      mergedVariables.putAll(additionalVariables);    }      for (Entry&lt;String, Object&gt; entry : mergedVariables.entrySet()) {      if (entry.getValue() instanceof Resource resource) {        combinedVariables.put(entry.getKey(), renderResource(resource));      }      else {        combinedVariables.put(entry.getKey(), entry.getValue());      }          }        return this.renderer.apply(this.template, combinedVariables);  }    \/\/.......    @Override  public Message createMessage(Map&lt;String, Object&gt; additionalVariables) {    return new UserMessage(render(additionalVariables));  }    \/\/.......}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 PromptTemplate \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u2014 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 TemplateRenderer, \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043a\u0430\u043a \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u0442\u0430\u043a \u0438 \u0447\u0435\u0440\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>SystemMessage \u0438 UserMessage \u2014 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043d\u0430\u0434 \u0440\u043e\u043b\u044f\u043c\u0438. \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/docs.spring.io\/spring-ai\/reference\/api\/prompt.html#_message\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Spring AI<\/a>.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/95f\/cb6\/498\/95fcb6498c95fd0c80071eebd1ce3c66.png\" alt=\"\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Spring AI\" title=\"\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Spring AI\" width=\"2048\" height=\"1670\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/95f\/cb6\/498\/95fcb6498c95fd0c80071eebd1ce3c66.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/95f\/cb6\/498\/95fcb6498c95fd0c80071eebd1ce3c66.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Spring AI<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 Message \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 AI. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439:<\/p>\n<p>SystemMessage \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043c\u0442\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<p>UserMessage \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u0442 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435<\/p>\n<p>ToolResponseMessage \u2014 \u043e\u0442\u0432\u0435\u0442, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<p>AssistantMessage \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u0438\u0430\u043b\u043e\u0433\u0430.<\/p>\n<p><a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-model\/src\/main\/java\/org\/springframework\/ai\/chat\/prompt\/Prompt.java#L45\">Prompt<\/a> \u2014\u00a0 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/models\/spring-ai-anthropic\/src\/main\/java\/org\/springframework\/ai\/anthropic\/AnthropicChatModel.java#L176\"> AnthropicChatModel.call(prompt)<\/a>. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c \u043e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0438 \u0438\u0437 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442.<\/p>\n<pre><code class=\"java\">public class Prompt implements ModelRequest&lt;List&lt;Message&gt;&gt; {  private final List&lt;Message&gt; messages;    private @Nullable ChatOptions chatOptions;    \/\/......<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>ChatOptions \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/models\/spring-ai-anthropic\/src\/main\/java\/org\/springframework\/ai\/anthropic\/AnthropicChatOptions.java\"> AnthropicChatOptions<\/a> . \u041a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0434\u0432\u0443\u043c\u044f \u0443\u0440\u043e\u0432\u043d\u044f\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 &#8212; \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u044b \u0432 ChatClient, \u0438 \u043e\u043f\u0446\u0438\u0439 per-request, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Prompt.\u00a0<\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0446\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0431\u0440\u0430\u043b \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\"><strong>\u041e\u043f\u0446\u0438\u044f<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\"><strong>\u0422\u0438\u043f<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">model<\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\">String<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u043e\u0434\u0435\u043b\u044c Claude (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, claude-3-7-sonnet-latest)\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">temperature<\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\">Double<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 (\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">maxTokens<\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\">Double<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432 \u043e\u0442\u0432\u0435\u0442\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">topP<\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\">Double<\/p>\n<\/td>\n<td>\n<p align=\"left\">Nucleus sampling \u2014 \u043f\u043e\u0440\u043e\u0433 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">topK<\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\">Integer<\/p>\n<\/td>\n<td>\n<p align=\"left\">Top-K sampling \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043f-\u0442\u043e\u043a\u0435\u043d\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">stopSequences<\/p>\n<\/td>\n<td data-colwidth=\"152\" width=\"152\">\n<p align=\"left\">List&lt;String&gt;<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u043e\u043f\u0446\u0438\u0439 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043e\u043f\u0446\u0438\u0439 \u043f\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (Tool Calling), \u0432\u044b\u0432\u043e\u0434\u0443 (Structure Output), \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u043c\u0443 \u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044e (Thinking). \u0414\u043b\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<a href=\"https:\/\/docs.spring.io\/spring-ai\/reference\/api\/chat\/anthropic-chat.html#chat-options\">\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.<\/a><\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0448\u0438 \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"kotlin\">.prompt(Prompt(listOf(systemMessage, userMessage))).call().content()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/DefaultChatClient.java#L111\"> .prompt()<\/a> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 Prompt \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 &#8212;<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/DefaultChatClient.java#L623\"> DefaultChatClientRequestSpec<\/a> , \u043a\u043e\u043f\u0438\u0440\u0443\u044f \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u043e\u043c\u0442\u0430.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/DefaultChatClient.java#L1014\"> <\/a>DefaultChatClientRequestSpec.call() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 DefaultCallResponseSpec, \u043e\u0431\u0435\u0440\u0442\u043a\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441.\u00a0<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/DefaultChatClient.java#L511\"> DefaultCallResponseSpec.doGetObservableChatClientResponse<\/a><\/p>\n<pre><code class=\"java\">var chatClientResponse = observation.observe(() -&gt; {  \/\/ Apply the advisor chain that terminates with the ChatModelCallAdvisor.  var response = this.advisorChain.nextCall(chatClientRequest);  observationContext.setResponse(response);  return response;});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u0437 \u043a\u043e\u0434\u0430 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e advisor \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 &#8212;\u00a0 <code>ChatModelCallAdvisor<\/code>. AdvisorChain \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d Chain of Responsibility. \u041c\u044b \u0441 \u043d\u0438\u043c \u043c\u043e\u0433\u043b\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Filter Chain \u0432 Servlet.<\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 ChatModelCallAdvisor \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a<\/p>\n<pre><code class=\"java\">@Overridepublic ChatClientResponse adviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) {  Assert.notNull(chatClientRequest, \"the chatClientRequest cannot be null\");    ChatClientRequest formattedChatClientRequest = augmentWithFormatInstructions(chatClientRequest);    ChatResponse chatResponse = this.chatModel.call(formattedChatClientRequest.prompt());  return ChatClientResponse.builder()    .chatResponse(chatResponse)    .context(Map.copyOf(formattedChatClientRequest.context()))    .build();}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>chatModel.call <\/code>\u0438 \u0435\u0441\u0442\u044c AnthropicChatModel, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c Spring \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0431\u0438\u043d\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043e\u043d\u0430 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 <code>ChatClient<\/code> \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430.<\/p>\n<p>\u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u043c\u0435\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0445\u0430\u0439\u043a\u0443 \u0441 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041f\u0440\u043e\u043c\u0442 \u0436\u0438\u0432\u0435\u0442 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445-\u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043a\u043e\u0434\u0430. \u041c\u043e\u0434\u0435\u043b\u044c \u0437\u043d\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u043e\u043b\u044c, \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0432\u0438\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<\/p>\n<p>\u041d\u043e \u043e\u0442\u0432\u0435\u0442 \u2014\u00a0 \u0441\u0442\u0440\u043e\u043a\u0430. \u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043c\u0435\u0448\u0430\u043d\u043e \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435 \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0445\u0430\u0439\u043a\u0443 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u2014\u00a0 \u0435\u0435 \u0441\u043c\u044b\u0441\u043b. \u041f\u0430\u0440\u0441\u0438\u0442\u044c \u044d\u0442\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e.<\/p>\n<h2>Structured Output \u2014\u00a0 \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0438\u0445 \u0441\u043c\u044b\u0441\u043b<\/h2>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430:<\/strong> \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0445\u0430\u0439\u043a\u0443 \u0435\u0435 \u043f\u043e\u044d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0437 \u0437\u0430 \u043d\u0435\u0439 \u0441\u0442\u043e\u0438\u0442. \u0417\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043a\u0441\u0442, \u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430: \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u0442\u0440\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 line (\u0442\u0435\u043a\u0441\u0442 \u0441\u0442\u0440\u043e\u043a\u0438) \u0438 meaning (\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430). \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u043e\u0439<a href=\"https:\/\/prompt-engineering-guide.vercel.app\/research\/llm-reasoning\"> reasoning<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0438\u0434\u0435\u044f \u2014\u00a0 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u042d\u0442\u043e \u0445\u0440\u0443\u043f\u043a\u043e: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0447\u0443\u0442\u044c \u0438\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u043e\u0442\u0432\u0435\u0442\u0435, \u0438 \u043f\u0430\u0440\u0441\u0435\u0440 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f. \u041d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435.<\/p>\n<p><strong>\u0421\u043f\u0440\u0430\u0432\u043a\u0430:<\/strong> Output Parsing \u0438 JSON Schema \u043a\u0430\u043a \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442. \u042f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0442\u043e\u043a\u0435\u043d\u044b, \u0430 \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u042d\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0442\u043e\u043a\u0435\u043d \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 &#8212;\u00a0 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0434 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u043c.<\/p>\n<p>\u041d\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0443\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c. \u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u043c\u0442 \u0442\u043e\u0447\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 &#8212;\u00a0 JSON Schema, \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0435\u0440\u043d\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 JSON.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d Output Parsing \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p><code>[\u0412\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441] + [JSON Schema \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430] -&gt;<\/code><\/p>\n<p><code>LLM \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON -&gt;<\/code><\/p>\n<p><code>\u0414\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f JSON \u2192 Java\/Kotlin \u043e\u0431\u044a\u0435\u043a\u0442<\/code><\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f JSON Schema? \u041f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e &#8212; \u0434\u043e\u043b\u0433\u043e, \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0445\u0440\u0443\u043f\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0411\u043e\u043b\u0435\u0435 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437 Java\/Kotlin-\u043a\u043b\u0430\u0441\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 Jackson. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 Spring AI.<\/p>\n<p>JSON Schema \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u043e\u0442\u0432\u0435\u0447\u0430\u0439 \u0432 JSON\u00bb \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e:<\/p>\n<p>1. \u0421\u0445\u0435\u043c\u0430 \u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u044f, \u0438\u0445 \u0442\u0438\u043f\u044b \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u2014\u00a0 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c.\u00a0<\/p>\n<p>2. \u0421\u0445\u0435\u043c\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 description \u2014\u00a0 \u044d\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438.\u00a0<\/p>\n<p>3. \u0414\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0442\u0438\u0432 \u0441\u0445\u0435\u043c\u044b \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u0412 Spring AI: \u043f\u0443\u0442\u044c \u0434\u043e AnthropicChatModel.call() <\/strong>\u0421\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a data class \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 JSON Schema \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u043f\u0440\u043e\u043c\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043d\u0435\u0441\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p><code>HaikuService.kt<\/code><\/p>\n<pre><code class=\"kotlin\">return chatClient  .prompt(Prompt(listOf(systemMessage, userMessage)))  .call()  .entity(object : ParameterizedTypeReference&lt;List&lt;HaikuLine&gt;&gt;() {})  ?: error(\"ChatClient returned null content for command='$command', theme='$theme'\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442\u0435 \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 HaikuLine.<\/p>\n<pre><code class=\"kotlin\">data class HaikuLine @JsonCreator constructor(  @JsonProperty(\"line\")  @JsonPropertyDescription(\"\u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0445\u0430\u0439\u043a\u0443 (\u0441\u0430\u043c \u0441\u0442\u0438\u0445 \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u043c \u044f\u0437\u044b\u043a\u0435)\")  val line: String,    @JsonProperty(\"meaning\")  @JsonPropertyDescription(\"\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 \u0438\u043b\u0438 \u0441\u043c\u044b\u0441\u043b\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\")  val meaning: String,)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0430\u043c\u043e DTO \u0442\u043e\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c. \u0423 \u043d\u0430\u0441 data class kotlin, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>JsonCreator<\/code> \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0434\u0430\u0442\u0430-\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c KotlinModule \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 JsonMapper. \u0410 \u0435\u0449\u0435 \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 <code>JsonPropertyDescription<\/code> \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f json schema, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 LLM.<\/p>\n<p>\u0412\u043d\u0435\u0434\u0440\u0438\u0432 \u0442\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448 http-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"json\">{  \"lines\": [    {      \"line\": \"\u041d\u0435\u043e\u043d \u0442\u0430\u0435\u0442 \u0432 \u0441\u043d\u0435\u0433\",      \"meaning\": \"\u042f\u0440\u043a\u0438\u0439 \u0441\u0432\u0435\u0442 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u0432\u044b\u0432\u0435\u0441\u043e\u043a \u0440\u0430\u0441\u0442\u0432\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0437\u0434\u043d\u0435\u0439 \u0437\u0438\u043c\u0435 \u2014 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0431\u0435\u0441\u0441\u0438\u043b\u044c\u043d\u0430 \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0438\u0440\u043e\u0434\u043e\u0439\"    },    {      \"line\": \"\u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0432 \u0438\u043d\u0435\u0435 \u043c\u043e\u043b\u0447\u0430\u0442 \u2014\",      \"meaning\": \"\u0421\u0435\u0442\u0438 \u0438 \u043a\u0430\u0431\u0435\u043b\u0438 \u0441\u043a\u043e\u0432\u0430\u043d\u044b \u043b\u044c\u0434\u043e\u043c, \u0441\u0432\u044f\u0437\u044c \u0437\u0430\u043c\u0435\u0440\u0437\u0430\u0435\u0442, \u043c\u0438\u0440 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u0443\u043c\u043e\u043b\u043a\u0430\u0435\u0442\"    },    {      \"line\": \"\u043c\u0430\u0440\u0442 \u043f\u0430\u0445\u043d\u0435\u0442 \u043e\u0437\u043e\u043d\u043e\u043c\",      \"meaning\": \"\u0417\u0430\u043f\u0430\u0445 \u0433\u0440\u044f\u0434\u0443\u0449\u0435\u0439 \u043e\u0442\u0442\u0435\u043f\u0435\u043b\u0438 \u0441\u043c\u0435\u0448\u0430\u043d \u0441 \u0437\u0430\u043f\u0430\u0445\u043e\u043c \u044d\u043b\u0435\u043a\u0442\u0440\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u2014 \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u0432\u0443\u0445 \u043c\u0438\u0440\u043e\u0432\"    }  ]}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b Spring AI, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u0412 \u043c\u0435\u0442\u043e\u0434\u0435<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/DefaultChatClient.java#L451\"> DefaultChatClient.entity()<\/a> \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>BeanOutputConverter<\/code> \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c.<\/p>\n<pre><code class=\"java\">@Overridepublic &lt;T&gt; @Nullable T entity(ParameterizedTypeReference&lt;T&gt; type) {  Assert.notNull(type, \"type cannot be null\");  return doSingleWithBeanOutputConverter(new BeanOutputConverter&lt;&gt;(type));}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-model\/src\/main\/java\/org\/springframework\/ai\/converter\/BeanOutputConverter.java\">BeanOutputConverter&lt;T&gt;<\/a> \u2014\u00a0 \u0441\u0435\u0440\u0434\u0446\u0435 Structured Output. \u041a\u043b\u0430\u0441\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0445\u0435\u043c\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 LLM \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 LLM.<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-model\/src\/main\/java\/org\/springframework\/ai\/converter\/BeanOutputConverter.java#L266\">getFormat<\/a> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e json schema \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u043d\u043e \u0438 \u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u0442.<\/p>\n<pre><code class=\"java\">@Overridepublic String getFormat() {  String template = \"\"\"  Your response should be in JSON format.  Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.  Do not include markdown code blocks in your response.  Remove the ```json markdown from the output.  Here is the JSON Schema instance your output must adhere to:  ```%s```  \"\"\";    return String.format(template, this.jsonSchema);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u044b\u0448\u0435 \u043c\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 data class \u043f\u043e\u0434 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u043d\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u043e\u0439 JsonMapper. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0435\u0442\u043e\u0434 protected, \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 JsonMapper.<\/p>\n<pre><code class=\"kotlin\">protected JsonMapper getJsonMapper() {  return JsonMapper.builder()  .addModules(JacksonUtils.instantiateAvailableModules())  .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)  .build();}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a <code>.entity()<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0441 \u043f\u0440\u043e\u043c\u0442\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438 <code>ChatClient.<\/code><\/p>\n<pre><code class=\"java\">if (StringUtils.hasText(outputConverter.getFormat())) {  \/\/ Used for default structured output format support, based on prompt  \/\/ instructions.  this.request.context().put(ChatClientAttributes.OUTPUT_FORMAT.getKey(), outputConverter.getFormat());}if (this.request.context().containsKey(ChatClientAttributes.STRUCTURED_OUTPUT_NATIVE.getKey()) &amp;&amp; outputConverter instanceof BeanOutputConverter beanOutputConverter) {  \/\/ Used for native structured output support, e.g. AI model API should  \/\/ provide structured output support.  this.request.context()  .put(ChatClientAttributes.STRUCTURED_OUTPUT_SCHEMA.getKey(), beanOutputConverter.getJsonSchema());}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 json \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0445\u0435\u043c\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442. \u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0432\u0438\u0434\u0438\u043c json schema \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code>spring.ai.chat.client.output.format=Your response should be in JSON format.Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.Do not include markdown code blocks in your response.Remove the ```json markdown from the output.Here is the JSON Schema instance your output must adhere to:```{\"$schema\" : \"https:\/\/json-schema.org\/draft\/2020-12\/schema\",\"type\" : \"array\",\"items\" : {\"type\" : \"object\",\"properties\" : {\"line\" : {\"type\" : \"string\",\"description\" : \"\u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0445\u0430\u0439\u043a\u0443 (\u0441\u0430\u043c \u0441\u0442\u0438\u0445 \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u043c \u044f\u0437\u044b\u043a\u0435)\"},\"meaning\" : {\"type\" : \"string\",\"description\" : \"\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 \u0438\u043b\u0438 \u0441\u043c\u044b\u0441\u043b\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\"}},\"required\" : [ \"line\", \"meaning\" ],\"additionalProperties\" : false}}```<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 HaikuResponse \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0438\u0437 \u0442\u0440\u0435\u0445 HaikuLine, \u043a\u0430\u0436\u0434\u0430\u044f \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 line \u0438 meaning. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043e\u0442\u0434\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 JSON &#8212; \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u043a\u0430\u043a \u0441 \u0436\u0438\u0432\u044b\u043c \u0430\u0432\u0442\u043e\u0440\u043e\u043c: \u00ab\u0445\u043e\u0440\u043e\u0448\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u0432\u0435\u0442\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043b\u0438\u0441\u0442\u00bb. \u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u0447\u043d\u0435\u0442 \u0437\u0430\u043d\u043e\u0432\u043e. \u041e\u043d\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043e \u043a\u0430\u043a\u043e\u043c \u043b\u0438\u0441\u0442\u0435 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u2014\u00a0 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043d\u0435\u0435 \u043f\u0435\u0440\u0432\u044b\u0439.<\/p>\n<h2>Chat Memory \u2014 \u0445\u0430\u0439\u043a\u0443 \u043a\u0430\u043a \u0436\u0438\u0432\u043e\u0439 \u0434\u0438\u0430\u043b\u043e\u0433<\/h2>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: <\/strong>\u0445\u0430\u0439\u043a\u0443 \u2014\u00a0 \u043d\u0435 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u043a\u0442. \u042d\u0442\u043e \u0434\u0438\u0430\u043b\u043e\u0433 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u044d\u0442\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u043e\u0442 \u0434\u0438\u0430\u043b\u043e\u0433: \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u00ab\u0434\u043e\u0431\u0430\u0432\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u00bb, \u043f\u043e\u0442\u043e\u043c \u00ab\u0441\u0434\u0435\u043b\u0430\u0439 \u0444\u0438\u043d\u0430\u043b \u0431\u043e\u043b\u0435\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u00bb.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e: \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chatClient.prompt() \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043d\u0443\u043b\u044f. \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0445\u0430\u0439\u043a\u0443, \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430 \u2014\u00a0 \u0432\u0441\u0435 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442.<\/p>\n<p><strong>\u0421\u043f\u0440\u0430\u0432\u043a\u0430: \u043f\u043e\u0447\u0435\u043c\u0443 LLM \u043d\u0435 \u043f\u043e\u043c\u043d\u0438\u0442 \u043d\u0438\u0447\u0435\u0433\u043e. <\/strong>\u042f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u2014\u00a0 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u2014\u00a0 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0442\u043e\u043a\u0435\u043d. \u041d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438. \u041a\u0430\u0436\u0434\u044b\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a Anthropic API \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c.<\/p>\n<p>\u042d\u0442\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a. \u041e\u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435: \u043b\u044e\u0431\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041d\u043e \u0434\u043b\u044f \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u0430 <strong>\u0438\u043b\u043b\u044e\u0437\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438.<\/strong> \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0434\u0438\u0430\u043b\u043e\u0433\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u043e\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u043c\u0442\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441: <code>messages: [SystemMessage, UserMessage(\"\u043d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u043b\u0438\u0441\u0442\")]\u00a0\u00a0<\/code><\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441: <\/p>\n<p><code>messages: [<\/code><\/p>\n<p><code>SystemMessage,<\/code><\/p>\n<p><code>UserMessage(\"\u043d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u043b\u0438\u0441\u0442\"), &lt;- \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441(\u0438\u0441\u0442\u043e\u0440\u0438\u044f)<\/code><\/p>\n<p><code>AssistantMessage(\"{lines:[{line:'...'}]}\"), &lt;- \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441(\u0438\u0441\u0442\u043e\u0440\u0438\u044f)<\/code><\/p>\n<p><code>UserMessage(\"\u0434\u043e\u0431\u0430\u0432\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u0432\u0435\u0442\u0435\u0440\")] &lt;- \u043d\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441<\/code><\/p>\n<p><code>]<\/code><\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u00ab\u0432\u0438\u0434\u0438\u0442\u00bb \u0432\u0435\u0441\u044c \u0434\u0438\u0430\u043b\u043e\u0433 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Conversation History \u2014\u00a0 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0435\u0445\u043d\u0438\u043a \u0434\u043b\u044f stateful AI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b: \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e. \u0423 Anthropic \u043e\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442. \u0414\u043b\u044f \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432 \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0443\u0441\u0435\u0447\u0435\u043d\u0438\u044f: \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 N \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0438\u043b\u0438 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u0443\u043c\u043c\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0414\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0432 \u043f\u0440\u043e\u043c\u0442:<\/p>\n<ol>\n<li>\n<p>MessageChatMemoryAdvisor \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 <code>Message<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>messages[].<\/code> \u041c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0440\u043e\u043b\u044f\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014\u00a0 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0438\u0430\u043b\u043e\u0433\u0430.<\/p>\n<\/li>\n<\/ol>\n<ol start=\"2\">\n<li>\n<p>PromptChatMemoryAdvisor \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u0442. \u041f\u043e\u043b\u0435\u0437\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0412 Spring AI: \u043f\u0443\u0442\u044c \u0434\u043e <\/strong><a href=\"http:\/\/AnthropicChatModel.call\"><strong>AnthropicChatModel.call<\/strong><\/a><strong>() <\/strong>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a <code>MessageChatMemoryAdvisor <\/code>\u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<p>\u0412 \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 http-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430:<\/p>\n<pre><code>@PostMappingfun generate(  @Valid @RequestBody request: HaikuRequest,  @RequestHeader(name = \"X-Conversation-Id\", required = false)  @Size(max = 128) rawConversationId: String?,): HaikuResponse {  val conversationId = rawConversationId?.takeIf { it.isNotBlank() }  ?: UUID.randomUUID().toString()  val lines = haikuService.generate(request.command, request.theme, conversationId)  return HaikuResponse(lines = lines, conversationId = conversationId)}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0438\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"kotlin\">@Beanfun chatMemoryRepository() = InMemoryChatMemoryRepository()@Beanfun chatMemory(  repository: InMemoryChatMemoryRepository,  @Value(\"\\${haiku.memory.max-messages:20}\") maxMessages: Int,): ChatMemory = MessageWindowChatMemory.builder()  .chatMemoryRepository(repository)  .maxMessages(maxMessages)  .build()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c ChatMemory \u043a ChatClient.<\/p>\n<pre><code class=\"kotlin\">private val chatClient: ChatClient = chatClientBuilder  .defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build())  .build()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0443 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 LLM \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 advisor \u0441 ID \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u0438\u0430\u043b\u043e\u0433\u0430, \u0447\u0442\u043e\u0431\u044b ChatClient \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <code>advisors<\/code> \u0432 \u0441\u0442\u0438\u043b\u0435 Fluent API.<\/p>\n<pre><code class=\"kotlin\">chatClient  .prompt()  .system(systemText)  .user { it.text(userText).param(\"command\", command).param(\"theme\", theme) }  .advisors { it.param(ChatMemory.CONVERSATION_ID, conversationId) }  .call()  .entity(object : ParameterizedTypeReference&lt;List&lt;HaikuLine&gt;&gt;() {})<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c in-memory \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 production \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0435\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>\u041f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-model\/src\/main\/java\/org\/springframework\/ai\/chat\/memory\/ChatMemory.java\"> ChatMemory<\/a> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-model\/src\/main\/java\/org\/springframework\/ai\/chat\/memory\/MessageWindowChatMemory.java\"> MessageWindowChatMemory<\/a>. \u0412\u044b\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 LLM.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u0430\u0440\u0430 user+assistant \u0440\u0430\u0432\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 200-500 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0445\u0430\u0439\u043a\u0443. 20 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\u00a0 ~10 \u0445\u043e\u0434\u043e\u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0430, ~4000 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044e<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e <code>MessageChatMemoryAdvisor,<\/code> \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043c\u0430\u0433\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u0438. Spring AI \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 BaseAdvisor c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/advisor\/api\/BaseAdvisor.java#L47C29-L47C39\">adviseCall<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 adviser \u0438 LLM \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 before() \u0438 after()<\/p>\n<pre><code class=\"java\">ChatClientRequest processedChatClientRequest = before(chatClientRequest, callAdvisorChain);ChatClientResponse chatClientResponse = callAdvisorChain.nextCall(processedChatClientRequest);return after(chatClientResponse, callAdvisorChain);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b before() \u0438 after() \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/advisor\/MessageChatMemoryAdvisor.java#L79\"> MessageChatMemoryAdvisor<\/a><\/p>\n<p>\u0414\u043e \u0432\u044b\u0437\u043e\u0432\u0430 LLM \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e conversationId<\/p>\n<\/li>\n<li>\n<p>\u041a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 ChatClientRequest \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 LLM \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0442\u0432\u0435\u0442 &#8212; AssistantMessage.<\/p>\n<p><code>MessageChatMemoryAdvisor<\/code> \u0438\u043c\u0435\u0435\u0442 \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 advisor, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043a LLM.<\/p>\n<p>\u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u044b \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u043c\u043d\u0438\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0425\u0430\u0439\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0435: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442, \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442, \u043a\u0430\u0436\u0434\u0430\u044f \u043d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u043d\u0430\u0435\u0442 \u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445.<\/p>\n<p>\u041d\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430. \u041a\u043e\u0433\u0434\u0430 \u043e\u0442\u0432\u0435\u0442 \u0432\u0434\u0440\u0443\u0433 \u0441\u0442\u0430\u043b \u0445\u0443\u0436\u0435 \u2014\u00a0 \u043f\u043e\u0447\u0435\u043c\u0443? \u0427\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u0448\u043b\u043e \u0432 \u043c\u043e\u0434\u0435\u043b\u044c? \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438? \u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u043d\u0435\u0442? \u041f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<h2>Observability \u2014\u00a0 \u0432\u0438\u0434\u0435\u0442\u044c \u0445\u0430\u0439\u043a\u0443 \u0438\u0437\u043d\u0443\u0442\u0440\u0438<\/h2>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: <\/strong>\u043f\u0440\u043e\u0448\u043b\u0430 \u043d\u0435\u0434\u0435\u043b\u044f \u0432 production. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0436\u0430\u043b\u0443\u044e\u0442\u0441\u044f: \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0445\u0430\u0439\u043a\u0443, \u0438\u043d\u043e\u0433\u0434\u0430 JSON \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u0442\u0432\u0435\u0442\u044b \u0441\u0442\u0430\u043b\u0438 \u0434\u043b\u0438\u043d\u043d\u0435\u0435 \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043b\u043e\u0433\u0438 &#8212; \u0442\u0430\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e. \u0412\u0438\u0434\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e HTTP 200 \u0438 \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430. \u0427\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u0448\u043b\u043e \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e. \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u043b\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438? \u0412\u0441\u0442\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u043b\u0438 JSON Schema? \u041d\u0435 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u043b\u0438 \u043b\u0438 \u043b\u0438\u043c\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430?<\/p>\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u0430\u044f \u043f\u0440\u0438\u0440\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 AI-\u0441\u0438\u0441\u0442\u0435\u043c: \u043e\u043d\u0438 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0447\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b. \u0414\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u043c \u0432\u0432\u043e\u0434\u0435 \u0434\u0430\u0435\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434. LLM &#8212;\u00a0 \u043d\u0435\u0442. \u041f\u043b\u044e\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0435\u0432 Advisor&#8217;\u043e\u0432 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u043f\u0440\u043e\u043c\u0442, \u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435.<\/p>\n<p><strong>\u0421\u043f\u0440\u0430\u0432\u043a\u0430: observability \u0432 AI-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<\/strong><\/p>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c 1: \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0442\u043e\u0432. \u0421\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041d\u0443\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u0442 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439, \u0441 JSON Schema, \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u043c, \u043a\u0430\u043a\u0438\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u044c. \u041d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u043a\u043e\u0434\u0435, \u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0431\u0440\u0430\u043b pipeline \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0439.<\/p>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c 2: \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u0435, \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430. \u0422\u043e\u043a\u0435\u043d\u044b \u2014\u00a0 \u044d\u0442\u043e \u0434\u0435\u043d\u044c\u0433\u0438 \u0438 latency. \u0412\u043d\u0435\u0437\u0430\u043f\u043d\u044b\u0439 \u0440\u043e\u0441\u0442 input_tokens \u0447\u0430\u0441\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0434\u0438\u0430\u043b\u043e\u0433\u0430 \u0440\u0430\u0437\u0440\u043e\u0441\u043b\u0430\u0441\u044c \u0441\u0432\u0435\u0440\u0445 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e.<\/p>\n<p><strong>\u0412 Spring AI: \u043f\u0443\u0442\u044c \u0434\u043e <\/strong><a href=\"http:\/\/AnthropicChatModel.call\"><strong>AnthropicChatModel.call<\/strong><\/a><strong>() <\/strong>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>SimpleLoggerAdvisor<\/code> \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f Micrometer-\u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/spring-ai-client-chat\/src\/main\/java\/org\/springframework\/ai\/chat\/client\/advisor\/SimpleLoggerAdvisor.java\">SimpleLoggerAdvisor<\/a> \u2014 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 advisor. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 ChatClient \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u0432 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0445 advisors \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code class=\"kotlin\">private val chatClient: ChatClient = chatClientBuilder  .defaultAdvisors(    MessageChatMemoryAdvisor.builder(chatMemory).build(),    SimpleLoggerAdvisor(),    tokenMetricsAdvisor,  )  .build()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>SimpleLoggerAdvisor <\/code>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>.toString<\/code> \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c DEBUG \u0432 \u043b\u043e\u0433\u0433\u0435\u0440.<\/p>\n<pre><code class=\"java\">public static final Function&lt;@Nullable ChatClientRequest, String&gt; DEFAULT_REQUEST_TO_STRING = chatClientRequest -&gt; chatClientRequest != null? chatClientRequest.toString() : \"null\";\/\/...@Overridepublic ChatClientResponse adviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) {  logRequest(chatClientRequest);  ChatClientResponse chatClientResponse = callAdvisorChain.nextCall(chatClientRequest);  logResponse(chatClientResponse);  return chatClientResponse;}\/\/....protected void logRequest(ChatClientRequest request) {  logger.debug(\"request: {}\", this.requestToString.apply(request));}protected void logResponse(ChatClientResponse chatClientResponse) {  logger.debug(\"response: {}\", this.responseToString.apply(chatClientResponse.chatResponse()));}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0430\u0434\u0432\u0438\u0437\u043e\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u044d\u0444\u0444\u0435\u043a\u0442 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0442\u0443\u043f\u0438\u043b \u0432 \u0441\u0438\u043b\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 <a href=\"http:\/\/application.properties\">application.properties<\/a> \u0437\u0430\u0434\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f DEBUG \u0434\u043b\u044f \u043b\u043e\u0433\u0433\u0435\u0440\u0430.<\/p>\n<p><code>logging.level.org.springframework.ai.chat.client.advisor=DEBUG<\/code><\/p>\n<p>\u041e\u0434\u0438\u043d advisor, \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 &#8212; \u0438 \u0432\u0438\u0434\u0438\u043c \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043b\u043e\u0433 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u0414\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043b\u043e\u0433\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439.<\/p>\n<pre><code>[haiku-generator] [nio-8080-exec-5] o.s.a.c.c.advisor.SimpleLoggerAdvisor : request: ChatClientRequest[prompt=Prompt{messages=[SystemMessage{textContent='\u0422\u044b \u2014 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0435, \u0432\u0435\u043b\u0438\u0447\u0430\u0439\u0448\u0438\u0439 \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443 \u044d\u043f\u043e\u0445\u0438 \u042d\u0434\u043e.\u0422\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0445\u0430\u0439\u043a\u0443: \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432.\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0439 \u0435\u0435 \u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0439 \u0441\u043c\u044b\u0441\u043b.\u041f\u0440\u0438\u043c\u0435\u0440\u044b:\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u041d\u0430\u043f\u0438\u0448\u0438, \u0422\u0435\u043c\u0430: \u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u0434\u043e\u0436\u0434\u044c\u0421\u0442\u0440\u043e\u043a\u0438:- \u00ab\u041b\u0438\u0441\u0442\u044c\u044f \u0442\u0438\u0445\u043e \u043b\u044c\u043d\u0443\u0442\u00bb \u2014 \u041e\u0431\u0440\u0430\u0437 \u043c\u044f\u0433\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u0438\u043f\u0430\u043d\u0438\u044f, \u043f\u043e\u043a\u043e\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e\u043c\u0443- \u00ab\u043a \u043c\u043e\u043a\u0440\u044b\u043c \u043a\u0430\u043c\u043d\u044f\u043c \u0443 \u0442\u0440\u043e\u043f\u044b \u2014\u00bb \u2014 \u0417\u0435\u043c\u043b\u044f \u043a\u0430\u043a \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c, \u043f\u0443\u0442\u044c \u0438 \u0432\u0440\u0435\u043c\u044f \u0441\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f- \u00ab\u0434\u043e\u0436\u0434\u044c \u0441\u043c\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u043d\u044c\u00bb \u2014 \u0414\u043e\u0436\u0434\u044c \u043a\u0430\u043a \u043e\u0447\u0438\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u043d\u0435\u0446 \u0438 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u0421\u043e\u0447\u0438\u043d\u0438, \u0422\u0435\u043c\u0430: \u0440\u0430\u0441\u0441\u0432\u0435\u0442 \u043d\u0430\u0434 \u043c\u043e\u0440\u0435\u043c\u0421\u0442\u0440\u043e\u043a\u0438:- \u00ab\u0410\u043b\u044b\u0439 \u043a\u0440\u0430\u0439 \u043d\u0435\u0431\u0435\u0441\u00bb \u2014 \u0417\u0430\u0440\u044f \u043a\u0430\u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0438\u0440\u0430\u043c\u0438- \u00ab\u0431\u0443\u0434\u0438\u0442 \u0441\u043f\u044f\u0449\u0438\u0435 \u0432\u043e\u043b\u043d\u044b \u2014\u00bb \u2014 \u041c\u043e\u0440\u0435 \u043a\u0430\u043a \u0436\u0438\u0432\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e, \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u043e\u0442 \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0441\u0432\u0435\u0442\u0430- \u00ab\u0447\u0430\u0439\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0441\u0442\u0430\u0435\u0442\u00bb \u2014 \u041f\u0442\u0438\u0446\u0430 \u043a\u0430\u043a \u0432\u0435\u0441\u0442\u043d\u0438\u043a \u043d\u043e\u0432\u043e\u0433\u043e \u0434\u043d\u044f\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u0421\u043e\u0437\u0434\u0430\u0439, \u0422\u0435\u043c\u0430: \u043e\u0434\u0438\u043d\u043e\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0438\u043c\u043e\u0439\u0421\u0442\u0440\u043e\u043a\u0438:- \u00ab\u0421\u043d\u0435\u0433 \u0437\u0430\u0441\u044b\u043f\u0430\u043b \u0441\u0430\u0434\u00bb \u2014 \u0411\u0435\u043b\u043e\u0435 \u0431\u0435\u0437\u043c\u043e\u043b\u0432\u0438\u0435 \u043a\u0430\u043a \u043f\u043e\u043a\u0440\u043e\u0432 \u0437\u0430\u0431\u0432\u0435\u043d\u0438\u044f- \u00ab\u043d\u0435\u0442 \u043d\u0438 \u0441\u043b\u0435\u0434\u0430, \u043d\u0438 \u0433\u043e\u043b\u043e\u0441\u0430 \u2014\u00bb \u2014 \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u043a \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0442\u044b- \u00ab\u0442\u043e\u043b\u044c\u043a\u043e \u044f \u0438 \u043d\u043e\u0447\u044c\u00bb \u2014 \u0421\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f \u0441 \u0442\u0438\u0448\u0438\u043d\u043e\u0439', messageType=SYSTEM, metadata={messageType=SYSTEM}}, UserMessage{content='\u041d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0438\u0445 \u043f\u0440\u043e \u043f\u043e\u0437\u0434\u043d\u044e\u044e \u0437\u0438\u043c\u0443: \u041a\u0438\u0431\u0435\u0440\u043f\u0430\u043d\u043a', metadata={messageType=USER}, messageType=USER}, AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=[{\"line\": \"\u041d\u0435\u043e\u043d \u0442\u0430\u0435\u0442 \u0432 \u0441\u043d\u0435\u0433\",\"meaning\": \"\u042f\u0440\u043a\u0438\u0439 \u0441\u0432\u0435\u0442 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u0432\u044b\u0432\u0435\u0441\u043e\u043a \u0440\u0430\u0441\u0442\u0432\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0437\u0434\u043d\u0435\u0439 \u0437\u0438\u043c\u0435 \u2014 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043f\u0440\u0438\u0440\u043e\u0434\u0435\"},{\"line\": \"\u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0432 \u0438\u043d\u0435\u0435 \u0434\u0440\u043e\u0436\u0430\u0442 \u2014\",\"meaning\": \"\u0421\u0435\u0442\u0438 \u0438 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043a\u043e\u0432\u0430\u043d\u044b \u0445\u043e\u043b\u043e\u0434\u043e\u043c, \u0445\u0440\u0443\u043f\u043a\u043e\u0441\u0442\u044c \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u043c\u0438\u0440\u0430 \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0438\u0445\u0438\u0435\u0439\"},{\"line\": \"\u043c\u0430\u0440\u0442 \u043f\u0430\u0445\u043d\u0435\u0442 \u0437\u043e\u043b\u043e\u0439\",\"meaning\": \"\u041a\u043e\u043d\u0435\u0446 \u0437\u0438\u043c\u044b \u0432 \u043c\u0438\u0440\u0435 \u043a\u0438\u0431\u0435\u0440\u043f\u0430\u043d\u043a\u0430 \u2014 \u043d\u0435 \u0441\u0432\u0435\u0436\u0435\u0441\u0442\u044c, \u0430 \u0437\u0430\u043f\u0430\u0445 \u0441\u0433\u043e\u0440\u0435\u0432\u0448\u0438\u0445 \u0441\u0445\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043b\u043e\u0441\u0442\u0438\"}], metadata={messageType=ASSISTANT}], UserMessage{content='\u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0439 \u044d\u043f\u0438\u0447\u043d\u044b\u0439 \u0444\u0438\u043d\u0430\u043b: \u0418\u0441\u043a\u043e\u043d\u043d\u043e \u0440\u0443\u0441\u0441\u043a\u0438\u0439', metadata={messageType=USER}, messageType=USER}], modelOptions=org.springframework.ai.anthropic.AnthropicChatOptions@c9dc1723}, context={spring.ai.chat.client.output.format=Your response should be in JSON format.Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.Do not include markdown code blocks in your response.Remove the ```json markdown from the output.Here is the JSON Schema instance your output must adhere to:```{\"$schema\" : \"https:\/\/json-schema.org\/draft\/2020-12\/schema\",\"type\" : \"array\",\"items\" : {\"type\" : \"object\",\"properties\" : {\"line\" : {\"type\" : \"string\",\"description\" : \"\u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0445\u0430\u0439\u043a\u0443 (\u0441\u0430\u043c \u0441\u0442\u0438\u0445 \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u043c \u044f\u0437\u044b\u043a\u0435)\"},\"meaning\" : {\"type\" : \"string\",\"description\" : \"\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 \u0438\u043b\u0438 \u0441\u043c\u044b\u0441\u043b\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\"}},\"required\" : [ \"line\", \"meaning\" ],\"additionalProperties\" : false}}```, chat_memory_conversation_id=22711f38-f796-45d4-b9c6-4c3a3c19e5c8}]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043b\u043e\u0433\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#8212; SystemMessage \u0441 \u0440\u043e\u043b\u044c\u044e \u0438 few-shot \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 UserMessage, AssistantMessage(\u043e\u0442\u0432\u0435\u0442 \u043e\u0442 LLM) \u0438 id \u0434\u0438\u0430\u043b\u043e\u0433\u0430. \u041f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 json schema(structured output).<\/p>\n<p>\u0412 \u043b\u043e\u0433\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043a\u0440\u043e\u043c\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043e\u0442 LLM \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 metadata, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432.<\/p>\n<pre><code>[haiku-generator] [nio-8080-exec-5] o.s.a.c.c.advisor.SimpleLoggerAdvisor : response: {\"result\" : {\"metadata\" : {\"finishReason\" : \"end_turn\",\"contentFilters\" : [ ],\"empty\" : true},\"output\" : {\"messageType\" : \"ASSISTANT\",\"metadata\" : {\"messageType\" : \"ASSISTANT\"},\"toolCalls\" : [ ],\"media\" : [ ],\"text\" : \"[\\n {\\n \\\"line\\\": \\\"\u0420\u0443\u0441\u044c \u0432\u0441\u0442\u0430\u0435\u0442 \u0438\u0437 \u043b\u044c\u0434\u0430\\\",\\n \\\"meaning\\\": \\\"\u041f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u0437\u0435\u043c\u043b\u0438 \u2014 \u0437\u0438\u043c\u0430 \u043e\u0442\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0442\u0441\u0442\u0443\u043f\u0430\u043b\u0438 \u0432\u0440\u0430\u0433\u0438, \u043d\u0435 \u0441\u043b\u043e\u043c\u0438\u0432 \u0434\u0443\u0445\u0430\\\"\\n },\\n {\\n \\\"line\\\": \\\"\u043a\u043e\u043b\u043e\u043a\u043e\u043b \u0433\u0443\u0434\u0438\u0442 \u0432 \u0432\u0435\u043a\u0430\u0445 \u2014\\\",\\n \\\"meaning\\\": \\\"\u0417\u0432\u043e\u043d \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u0439, \u0433\u043e\u043b\u043e\u0441 \u043f\u0440\u0435\u0434\u043a\u043e\u0432, \u043f\u0440\u043e\u043d\u0438\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\\\"\\n },\\n {\\n \\\"line\\\": \\\"\u043c\u0435\u0434\u0432\u0435\u0434\u044c \u0432\u0438\u0434\u0438\u0442 \u0441\u043e\u043d\\\",\\n \\\"meaning\\\": \\\"\u0418\u0441\u043a\u043e\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0420\u043e\u0441\u0441\u0438\u0438 \u0435\u0449\u0435 \u0434\u0440\u0435\u043c\u043b\u0435\u0442, \u043d\u043e \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u2014 \u0438 \u0435\u0441\u0442\u044c \u0441\u0430\u043c \u0444\u0438\u043d\u0430\u043b \u0438\u0441\u0442\u043e\u0440\u0438\u0438\\\"\\n }\\n]\"}},\"metadata\" : {\"id\" : \"msg_01FfKdyKrVMHDdGjyhcxXPNZ\",\"model\" : \"claude-sonnet-4-6\",\"rateLimit\" : {\"requestsLimit\" : 0,\"requestsRemaining\" : 0,\"requestsReset\" : 0.0,\"tokensLimit\" : 0,\"tokensRemaining\" : 0,\"tokensReset\" : 0.0},\"usage\" : {\"promptTokens\" : 930,\"completionTokens\" : 180,\"totalTokens\" : 1110,\"nativeUsage\" : {\"input_tokens\" : 930,\"output_tokens\" : 180,\"cache_creation_input_tokens\" : 0,\"cache_read_input_tokens\" : 0}},\"promptMetadata\" : [ ],\"empty\" : false},\"results\" : [ {\"metadata\" : {\"finishReason\" : \"end_turn\",\"contentFilters\" : [ ],\"empty\" : true},\"output\" : {\"messageType\" : \"ASSISTANT\",\"metadata\" : {\"messageType\" : \"ASSISTANT\"},\"toolCalls\" : [ ],\"media\" : [ ],\"text\" : \"[\\n {\\n \\\"line\\\": \\\"\u0420\u0443\u0441\u044c \u0432\u0441\u0442\u0430\u0435\u0442 \u0438\u0437 \u043b\u044c\u0434\u0430\\\",\\n \\\"meaning\\\": \\\"\u041f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u0437\u0435\u043c\u043b\u0438 \u2014 \u0437\u0438\u043c\u0430 \u043e\u0442\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0442\u0441\u0442\u0443\u043f\u0430\u043b\u0438 \u0432\u0440\u0430\u0433\u0438, \u043d\u0435 \u0441\u043b\u043e\u043c\u0438\u0432 \u0434\u0443\u0445\u0430\\\"\\n },\\n {\\n \\\"line\\\": \\\"\u043a\u043e\u043b\u043e\u043a\u043e\u043b \u0433\u0443\u0434\u0438\u0442 \u0432 \u0432\u0435\u043a\u0430\u0445 \u2014\\\",\\n \\\"meaning\\\": \\\"\u0417\u0432\u043e\u043d \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u0439, \u0433\u043e\u043b\u043e\u0441 \u043f\u0440\u0435\u0434\u043a\u043e\u0432, \u043f\u0440\u043e\u043d\u0438\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\\\"\\n },\\n {\\n \\\"line\\\": \\\"\u043c\u0435\u0434\u0432\u0435\u0434\u044c \u0432\u0438\u0434\u0438\u0442 \u0441\u043e\u043d\\\",\\n \\\"meaning\\\": \\\"\u0418\u0441\u043a\u043e\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0420\u043e\u0441\u0441\u0438\u0438 \u0435\u0449\u0435 \u0434\u0440\u0435\u043c\u043b\u0435\u0442, \u043d\u043e \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u2014 \u0438 \u0435\u0441\u0442\u044c \u0441\u0430\u043c \u0444\u0438\u043d\u0430\u043b \u0438\u0441\u0442\u043e\u0440\u0438\u0438\\\"\\n }\\n]\"}} ]}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 Anthropic \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0430\u043c. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u043e \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u043b\u043e\u0433\u0435 \u0432\u044b\u0448\u0435. \u0412 \u043b\u043e\u0433\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>DefaultUsage<\/code> \u043e\u0442 Spring AI \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440-\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0415\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432<a href=\"https:\/\/github.com\/spring-projects\/spring-ai\/blob\/main\/models\/spring-ai-anthropic\/src\/main\/java\/org\/springframework\/ai\/anthropic\/AnthropicChatModel.java#L233C10-L233C22\"> AnthropicChatModel<\/a><\/p>\n<pre><code class=\"java\">private DefaultUsage getDefaultUsage(AnthropicApi.@Nullable Usage usage) {  Integer inputTokens = usage != null &amp;&amp; usage.inputTokens() != null ? usage.inputTokens() : 0;  Integer outputTokens = usage != null &amp;&amp; usage.outputTokens() != null ? usage.outputTokens() : 0;  return new DefaultUsage(inputTokens, outputTokens, inputTokens + outputTokens, usage);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 API \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 observation micrometer \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u0440\u0438\u043a\u0443 <code>gen_ai.client.operation<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u044b API \u043f\u043b\u0430\u0442\u043d\u044b\u0435, \u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0430\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 advisor, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0430\u043c.<\/p>\n<pre><code class=\"kotlin\">@Componentclass TokenMetricsAdvisor(meterRegistry: MeterRegistry) : CallAdvisor {  private val inputSummary = DistributionSummary.builder(\"gen-ai.token.usage\")    .tag(\"token-type\", \"input\")    .register(meterRegistry)    private val outputSummary = DistributionSummary.builder(\"gen-ai.token.usage\")    .tag(\"token-type\", \"output\")    .register(meterRegistry)      override fun getName() = \"TokenMetricsAdvisor\"    override fun getOrder() = Int.MIN_VALUE    override fun adviseCall(request: ChatClientRequest, chain: CallAdvisorChain): ChatClientResponse {    val response = chain.nextCall(request)    val usage = response.chatResponse()?.metadata?.usage    if (usage != null) {      inputSummary.record(usage.promptTokens.toDouble())      outputSummary.record(usage.completionTokens.toDouble())    }    return response  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 ChatClient \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 advisor<\/p>\n<pre><code class=\"kotlin\">private val chatClient: ChatClient = chatClientBuilder  .defaultAdvisors(    MessageChatMemoryAdvisor.builder(chatMemory).build(),    SimpleLoggerAdvisor(),    tokenMetricsAdvisor,  )  .build()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0430\u043a\u0442\u0443\u0430\u0442\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"bash\">curl --location --request GET 'localhost:8080\/actuator\/metrics\/gen-ai.token.usage'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<pre><code>{  \"availableTags\": [    {      \"tag\": \"token-type\",      \"values\": [        \"output\",        \"input\"      ]    }  ],  \"measurements\": [    {      \"statistic\": \"COUNT\",      \"value\": 2.0    },    {      \"statistic\": \"TOTAL\",      \"value\": 931.0    }  ],  \"name\": \"gen-ai.token.usage\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439. \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434: \u0432 \u043b\u043e\u0433\u0430\u0445 &#8212; \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0441\u043b\u043e\u044f\u043c\u0438, \u0432 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445 &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0438 \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430. \u041a\u043e\u0433\u0434\u0430 \u0447\u0442\u043e-\u0442\u043e \u0438\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a, \u0437\u043d\u0430\u0435\u043c \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c.<\/p>\n<h2>\u042d\u043f\u0438\u043b\u043e\u0433: \u043e\u0434\u043d\u043e \u0445\u0430\u0439\u043a\u0443, \u0447\u0435\u0442\u044b\u0440\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438<\/h2>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<\/p>\n<ul>\n<li>\n<p><strong>Prompt Engineering<\/strong> \u0437\u0430\u043a\u0440\u044b\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430. \u0411\u0435\u0437 \u0440\u043e\u043b\u0438 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442. \u0421 .st-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043f\u0440\u043e\u043c\u0442 \u0441\u0442\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u043c\u0438 &#8212; \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0431\u0435\u0437 \u0434\u0435\u043f\u043b\u043e\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>Structured Output<\/strong> \u0437\u0430\u043a\u0440\u044b\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0445\u0440\u0443\u043f\u043a\u043e\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 &#8212; \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Kotlin-\u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p><strong>Chat Memory<\/strong> \u0437\u0430\u043a\u0440\u044b\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0418\u0437 \u0441\u0435\u0440\u0438\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0445\u0430\u0439\u043a\u0443 \u0437\u043d\u0430\u0435\u0442 \u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>Observability<\/strong> \u0437\u0430\u043a\u0440\u044b\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0430 \u0431\u044b\u0442\u044c \u0447\u0435\u0440\u043d\u044b\u043c \u044f\u0449\u0438\u043a\u043e\u043c &#8212; \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f: <\/strong>Spring AI \u2014\u00a0 \u043d\u0435 \u043c\u0430\u0433\u0438\u044f \u0438 \u043d\u0435 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044c \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u042d\u0442\u043e \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<ul>\n<li>\n<p>ChatOptions &#8212; \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>PromptTemplate &#8212; \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u043c\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>BeanOutputConverter &#8212; \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>ChatMemory + Advisor &#8212; \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u0438\u0430\u043b\u043e\u0433\u0430<\/p>\n<\/li>\n<li>\n<p>SimpleLoggerAdvisor + Micrometer &#8212; observability<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0441\u043b\u043e\u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u043e\u0441\u0442\u0430 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439. \u041d\u0430\u0447\u043d\u0438\u0442\u0435 <code>chatClient.prompt().call().content(). <\/code>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>PromptTemplate<\/code> \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043c\u0442 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043b\u0441\u044f. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 .<code>entity()<\/code> \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>ChatMemory<\/code> \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d \u0434\u0438\u0430\u043b\u043e\u0433. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>SimpleLoggerAdvisor<\/code> \u043a\u043e\u0433\u0434\u0430 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Spring AI \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043b\u043e\u0439 \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0435 API.<\/p>\n<p>*\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u0430-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0445\u0430\u0439\u043a\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432<a href=\"https:\/\/github.com\/rmasgutov\/haiku-generator\"> \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1035232\/\">https:\/\/habr.com\/ru\/articles\/1035232\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u2014\u00a0 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0445\u0430\u0439\u043a\u0443. \u0427\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0427\u0435\u0442\u044b\u0440\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438.\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043e\u0442 chatClient.prompt().call() \u0434\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e AI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 Anthropic API\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u042f \u0420\u0443\u0441\u043b\u0430\u043d \u041c\u0430\u0441\u0433\u0443\u0442\u043e\u0432, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u0432 \u0422-\u0411\u0430\u043d\u043a\u0435. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u044b \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u2014 \u0432\u0430\u0436\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u0438 \u0437\u043d\u0430\u0442\u044c \u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e.\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u044f\u0434 \u0442\u0435\u0445\u043d\u0438\u043a GenAI, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 Spring AI, \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u043c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 ChatClient \u043b\u0438\u0448\u044c \u0442\u043e\u043d\u043a\u043e\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 API \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 LLM \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 Anthropic, \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u043e \u0445\u043e\u0434\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.\u041f\u0440\u043e\u043b\u043e\u0433: \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u043e\u0436\u0434\u0430\u044e\u0442 \u0445\u0430\u0439\u043a\u0443\u0412\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u0438\u043d\u043d\u043e. \u041c\u044b Spring-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043e LLM, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 ChatGPT \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u0437\u043d\u0430\u0435\u043c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c LLM \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u0438. \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f: \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0445\u0430\u0439\u043a\u0443\/\u0445\u043e\u043a\u043a\u0443 (\u044f\u043f\u043e\u043d\u0441\u043a\u043e\u0435 \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435) \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0438\u0448\u0435\u0442 \u00ab\u0434\u043e\u0431\u0430\u0432\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u043e\u0441\u0435\u043d\u044c\u00bb \u2014\u00a0 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435.\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c spring-ai-anthropic-spring-boot-starter, \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c API-\u043a\u043b\u044e\u0447, \u0438 \u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.@RestController@RequestMapping(&#171;\/api\/haiku&#187;)class HaikuController(private val haikuService: HaikuService) {  @PostMapping  fun generate(@Valid @RequestBody request: HaikuRequest): HaikuResponse =  HaikuResponse(haiku = haikuService.generate(request.prompt))}@Serviceclass HaikuService(chatClientBuilder: ChatClient.Builder) {  private val chatClient: ChatClient = chatClientBuilder.build()    fun generate(prompt: String): String =    chatClient    .prompt()    .user(prompt)    .call()    .content()    ?: error(&#171;ChatClient returned null content for prompt: $prompt&#187;)}\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:curl &#8212;location &#8212;request POST &#8216;localhost:8080\/api\/haiku&#8217; \\  &#8212;header &#8216;Content-Type: application\/json&#8217; \\  &#8212;data-raw &#8216;{  &#171;prompt&#187;: &#171;\u041d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0438\u0445 \u043f\u0440\u043e \u043f\u043e\u0437\u0434\u043d\u044e\u044e \u0437\u0438\u043c\u0443&#187;  }&#8217;\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442:{   &#171;haiku&#187;: &#171;# \u0424\u0435\u0432\u0440\u0430\u043b\u044c\u0441\u043a\u043e\u0435\\n\\n\u0424\u0435\u0432\u0440\u0430\u043b\u044c \u0443\u0441\u0442\u0430\u043b. \u041e\u043d \u0434\u044b\u0448\u0438\u0442 \u0442\u044f\u0436\u0435\u043b\u043e,\\n\u0421\u0443\u0433\u0440\u043e\u0431\u044b \u043e\u0441\u0435\u043b\u0438, \u043f\u043e\u0442\u0435\u043c\u043d\u0435\u043b\u0438,\\n\u0418 \u0441\u043e\u043b\u043d\u0446\u0435 \u2014 \u0440\u043e\u0431\u043a\u043e\u0435, \u043d\u0435\u0441\u043c\u0435\u043b\u043e\u0435 \u2014\\n\u0412\u0441\u0451 \u0434\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441 \u0432 \u0442\u0435\u043f\u043b\u043e.\\n\\n\u041a\u0430\u043f\u0435\u043b\u044c \u0435\u0449\u0451 \u043d\u0435 \u0441\u043b\u044b\u0448\u043d\u043e, \u043d\u043e \u0443\u0436\u0435\\n\u0412 \u0432\u043e\u0437\u0434\u0443\u0445\u0435 \u0447\u0442\u043e-\u0442\u043e \u0442\u043e\u043d\u043a\u043e\u0435 \u0434\u0440\u043e\u0436\u0438\u0442,\\n\u0418 \u0432\u043e\u0440\u043e\u043d \u043d\u0430 \u0431\u0435\u0440\u0451\u0437\u0435 \u043d\u0435 \u0441\u043f\u0435\u0448\u0438\u0442 \u2014\\n\u0421\u0438\u0434\u0438\u0442 \u0438 \u0449\u0443\u0440\u0438\u0442\u0441\u044f \u0432 \u0442\u0438\u0448\u0438.\\n\\n\u0417\u0438\u043c\u0430 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u0448\u0430\u0442\u043a\u043e\u043c \u0440\u0443\u0431\u0435\u0436\u0435,\\n\u0426\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043d\u043e\u0447\u0438 \u0438 \u043c\u0435\u0442\u0435\u043b\u0438,\\n\u041d\u043e \u0434\u043d\u0438 \u2014 \u0434\u043b\u0438\u043d\u043d\u0435\u0435. \u041f\u0442\u0438\u0446\u044b \u043e\u0448\u0430\u043b\u0435\u043b\u0438\\n\u0418 \u0447\u0442\u043e-\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b\u0438 \u0432 \u0434\u0443\u0448\u0435.\\n\\n\u0415\u0449\u0451 \u043d\u0435 \u043c\u0430\u0440\u0442. \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u2014 \u043c\u0430\u0440\u0442.\\n\u0415\u0449\u0451 \u043c\u043e\u0440\u043e\u0437. \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u2014 \u0442\u0430\u043b\u043e\u0441\u0442\u044c.\\n\u0418 \u044d\u0442\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u0430\u044f \u0443\u0441\u0442\u0430\u043b\u043e\u0441\u0442\u044c\\n\u0417\u0438\u043c\u044b \u2014 \u043a\u0430\u043a \u0431\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0448\u0442\u0430\u043d\u0434\u0430\u0440\u0442.&#187;}\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e-\u044f\u043f\u043e\u043d\u0441\u043a\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u2014\u00a0 \u043f\u0440\u043e\u0437\u043e\u0439. \u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u044b\u0434\u0430\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0435\u0445. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u0442 \u044d\u0441\u0441\u0435 \u043e \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0445\u0430\u0439\u043a\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f.\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0435\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c. \u041e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0412\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0435\u0433\u043e.\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435.\u041a\u0430\u0440\u0442\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430: \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0447\u0435\u0442\u044b\u0440\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441.\u041c\u043e\u0434\u0435\u043b\u044c \u043f\u0438\u0448\u0435\u0442 \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u043b\u043e \u2014\u00a0 Prompt Engineering\u041e\u0442\u0432\u0435\u0442 &#8212; \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u2014\u00a0 Structured Output\u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430 \u2014\u00a0 Chat Memory\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043d\u0430\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u043d\u044b\u043c \u044f\u0449\u0438\u043a\u043e\u043c \u2014\u00a0 ObservabilityPrompt Engineering &#8212; \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0430\u0439\u043a\u0443\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.\u00a0 \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u00ab\u043d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u043e \u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u043b\u0438\u0441\u0442\u00bb.\u041e\u0442\u0432\u0435\u0442\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u043c\u0438. \u041c\u043e\u0434\u0435\u043b\u044c \u0442\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432, \u0442\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e. \u0422\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u0442\u043e \u043d\u0435\u0442. \u0422\u043e \u043f\u0438\u0448\u0435\u0442 \u043f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438, \u0442\u043e \u0432\u0434\u0440\u0443\u0433 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439.\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u043e\u043d\u0430 \u0438 \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0435\u043b\u0430\u0442\u044c. \u041c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0433\u043e\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.\u0421\u043f\u0440\u0430\u0432\u043a\u0430: \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u043e\u043c\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430.\u00a0 \u0415\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 LLM \u043a\u0430\u043a \u043d\u0430 \u0447\u0435\u0440\u043d\u044b\u0439 \u044f\u0449\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u2014 \u043f\u0440\u043e\u043c\u0442 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c. \u041d\u043e \u0442\u043e\u0447\u043d\u0435\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043f\u0440\u043e\u043c\u0442\u0435 \u043a\u0430\u043a \u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.\u041c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u043c \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432. \u041e\u043d\u0430 \u0432\u0438\u0434\u0435\u043b\u0430 \u0442\u044b\u0441\u044f\u0447\u0438 \u0445\u0430\u0439\u043a\u0443, \u0442\u044b\u0441\u044f\u0447\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u0438\u043b \u0436\u0430\u043d\u0440\u0430, \u0442\u044b\u0441\u044f\u0447\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u0432. \u0412\u0441\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c, \u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u041f\u0440\u043e\u043c\u0442 \u2014 \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0435 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432.\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u0438\u043a:Zero-shot prompting \u2014\u00a0 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0431\u0435\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0414\u043b\u044f \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u2014 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e.Few-shot prompting \u2014\u00a0 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0440\u043e\u043c\u0442\u0435. \u041c\u043e\u0434\u0435\u043b\u044c \u00ab\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u00bb \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e. \u0414\u043b\u044f \u0445\u0430\u0439\u043a\u0443 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0440\u0438-\u043f\u044f\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439.Role prompting \u2014\u00a0 \u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u043e\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0433\u0440\u0430\u0442\u044c. \u00ab\u0422\u044b &#8212; \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443 \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0435\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u00ab\u043d\u0430\u043f\u0438\u0448\u0438 \u0445\u0430\u0439\u043a\u0443\u00bb. \u0420\u043e\u043b\u044c \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0442\u0438\u043b\u044c. \u042d\u0442\u043e \u043d\u0435 \u043c\u0430\u0433\u0438\u044f \u2014\u00a0 \u044d\u0442\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 in-context learning.Chain-of-Thought (CoT) \u2014\u00a0 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u0434\u0443\u043c\u0430\u0442\u044c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u00bb. \u0414\u043b\u044f \u0445\u0430\u0439\u043a\u0443 \u044d\u0442\u043e \u00ab\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438 \u043e\u0431\u0440\u0430\u0437, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0439 \u0441\u043b\u043e\u0433\u0438, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0443\u00bb. \u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u2014\u00a0 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u0441 \u0436\u0435\u0441\u0442\u043a\u0438\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0442\u0438\u0445\u0430.\u041f\u0440\u043e\u043c\u0442 \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u0434\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0440\u044b\u0432 \u2014\u00a0 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0442 \u043f\u0440\u044f\u043c\u043e \u0432 Kotlin-\u043a\u043e\u0434\u0435:val systemPrompt = &#171;&#187;&#187;  \u0422\u044b \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443. \u041f\u0438\u0448\u0438 \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0451.  \u0421\u043e\u0431\u043b\u044e\u0434\u0430\u0439 \u043f\u0440\u0430\u0432\u0438\u043b\u043e 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432.  \u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0445\u0430\u0439\u043a\u0443, \u0431\u0435\u0437 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439.  &#171;&#187;&#187;\u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u044c\u0448\u0435.\u041f\u0440\u043e\u043c\u0442 \u2014\u00a0 \u044d\u0442\u043e \u043d\u0435 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u044d\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0447\u0430\u0449\u0435, \u0447\u0435\u043c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434: \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043d. \u041a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0442\u0430 \u0432 .kt-\u0444\u0430\u0439\u043b\u0435 \u2014\u00a0 \u043a\u043e\u043c\u043c\u0438\u0442, \u0440\u0435\u0432\u044c\u044e, \u0441\u0431\u043e\u0440\u043a\u0430, \u0434\u0435\u043f\u043b\u043e\u0439.\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a Kotlin \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u043c\u0442\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:\u041d\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $theme &#8212; \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u043c $theme \u0432 \u043f\u0440\u043e\u043c\u0442\u0435. \u0411\u0435\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0431\u0435\u0437 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.\u042d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043c\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0438\u043b\u0438 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u2014\u00a0 \u043d\u0443\u0436\u043d\u043e \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438.\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041e\u0434\u0438\u043d \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u043c\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0431\u0435\u0437 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043a\u043e\u0434\u0430.\u0427\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c diff. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u043e\u043c\u0442\u0430 \u0432 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 Kotlin \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 diff \u0432 git.\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u043c\u0442\u044b \u0432 \u0444\u0430\u0439\u043b\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u2014\u00a0 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u043c\u0435\u043d\u044f\u0442\u044c \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f 2 \u043f\u0440\u043e\u043c\u0442\u0430: \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439.\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u0442: \u0440\u043e\u043b\u044c, \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u0440\u0438\u043c\u0435\u0440\u044b. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u0445\u043d\u0438\u043a\u0438 role prompting \u0438 few-shot prompting. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b src\/main\/resources\/prompts\/system.st\u0422\u044b \u2014 \u041c\u0430\u0446\u0443\u043e \u0411\u0430\u0441\u0435, \u0432\u0435\u043b\u0438\u0447\u0430\u0439\u0448\u0438\u0439 \u043c\u0430\u0441\u0442\u0435\u0440 \u0445\u0430\u0439\u043a\u0443 \u044d\u043f\u043e\u0445\u0438 \u042d\u0434\u043e.\u0422\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0445\u0430\u0439\u043a\u0443: \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 5-7-5 \u0441\u043b\u043e\u0433\u043e\u0432.\u0422\u044b \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0438\u043c \u0441\u0442\u0438\u0445\u043e\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u2014 \u0431\u0435\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432, \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u0438 \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u0432 \u0441\u0442\u0440\u043e\u043a.\u041f\u0440\u0438\u043c\u0435\u0440\u044b:\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u041d\u0430\u043f\u0438\u0448\u0438, \u0422\u0435\u043c\u0430: \u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u0434\u043e\u0436\u0434\u044c\u041b\u0438\u0441\u0442\u044c\u044f \u0442\u0438\u0445\u043e \u043b\u044c\u043d\u0443\u0442\u043a \u043c\u043e\u043a\u0440\u044b\u043c \u043a\u0430\u043c\u043d\u044f\u043c \u0443 \u0442\u0440\u043e\u043f\u044b \u2014\u0434\u043e\u0436\u0434\u044c \u0441\u043c\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u043d\u044c\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u0421\u043e\u0447\u0438\u043d\u0438, \u0422\u0435\u043c\u0430: \u0440\u0430\u0441\u0441\u0432\u0435\u0442 \u043d\u0430\u0434 \u043c\u043e\u0440\u0435\u043c\u0410\u043b\u044b\u0439 \u043a\u0440\u0430\u0439 \u043d\u0435\u0431\u0435\u0441\u0431\u0443\u0434\u0438\u0442 \u0441\u043f\u044f\u0449\u0438\u0435 \u0432\u043e\u043b\u043d\u044b \u2014\u0447\u0430\u0439\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0441\u0442\u0430\u0435\u0442\u041a\u043e\u043c\u0430\u043d\u0434\u0430: \u0421\u043e\u0437\u0434\u0430\u0439, \u0422\u0435\u043c\u0430: \u043e\u0434\u0438\u043d\u043e\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0438\u043c\u043e\u0439\u0421\u043d\u0435\u0433 \u0437\u0430\u0441\u044b\u043f\u0430\u043b \u0441\u0430\u0434\u043d\u0435\u0442 \u043d\u0438 \u0441\u043b\u0435\u0434\u0430, \u043d\u0438 \u0433\u043e\u043b\u043e\u0441\u0430 \u2014\u0442\u043e\u043b\u044c\u043a\u043e \u044f \u0438 \u043d\u043e\u0447\u044c\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 src\/main\/resources\/prompts\/user.st{!\u041f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 (\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 PromptTemplate#createMessage, \u0432 LLM \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442):{command} \u2014 \u0433\u043b\u0430\u0433\u043e\u043b-\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u00ab\u041d\u0430\u043f\u0438\u0448\u0438\u00bb, \u00ab\u0421\u043e\u0447\u0438\u043d\u0438\u00bb, \u00ab\u0421\u043e\u0437\u0434\u0430\u0439\u00bb); max 200 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432{theme} \u2014 \u0442\u0435\u043c\u0430 \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0437 \u0445\u0430\u0439\u043a\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u00ab\u043e\u0441\u0435\u043d\u043d\u0438\u0439 \u0434\u043e\u0436\u0434\u044c\u00bb, \u00ab\u0437\u0430\u043a\u0430\u0442 \u043d\u0430\u0434 \u0440\u0435\u043a\u043e\u0439\u00bb); max 200 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432!}{command}: {theme}{! \u0438 !} \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u044e\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 StringTemplate \u0443\u0431\u0435\u0440\u0435\u0442 \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435.\u041c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u0434\u043b\u044f StringTemplate (ST4). Spring AI \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 StringTemplate 4 (ST4), \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0422\u0435\u0440\u0435\u043d\u0441\u043e\u043c \u041f\u0430\u0440\u0440\u043e\u043c, \u0430\u0432\u0442\u043e\u0440\u043e\u043c ANTLR. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 ST4: &lt;variableName&gt; \u0432\u043c\u0435\u0441\u0442\u043e $variableName \u0432 Kotlin. \u0412 Spring AI \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a &lt;&gt; \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 {}\u041f\u043e\u0447\u0435\u043c\u0443 ST4, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0442\u0440\u043e\u043a:\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f. ST4 \u0431\u0440\u043e\u0441\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 runtime \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0430 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u043c\u0442 \u0441 &lt;theme&gt; \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e.\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435. \u041f\u0440\u043e\u043c\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b: &lt;if(examples)&gt;\u041f\u0440\u0438\u043c\u0435\u0440\u044b:\\n&lt;examples&gt;&lt;endif&gt;. \u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u0430 \u043d\u0435 \u0432 Java\/Kotlin-\u043a\u043e\u0434\u0435.\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0428\u0430\u0431\u043b\u043e\u043d \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u043c\u0442\u0430. \u041a\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 MVC, \u043d\u043e \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 LLM.\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041e\u0434\u0438\u043d .st-\u0444\u0430\u0439\u043b \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.\u042f \u043d\u0435 \u0441\u043c\u043e\u0433 \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 ST4, \u0430 \u043d\u0435 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 java\/kotlin-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. \u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.\u0412 Spring AI: \u043f\u0443\u0442\u044c \u0434\u043e AnthropicChatModel.call().\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a .st-\u0444\u0430\u0439\u043b \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 Prompt \u043f\u0435\u0440\u0435\u0434 \u0443\u0445\u043e\u0434\u043e\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c.\u0412 HaikuService.kt \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u043e\u043c\u0442\u043e\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.class HaikuService(  chatClientBuilder: ChatClient.Builder,  @Value(&#171;classpath:prompts\/system.st&#187;) private val systemResource: Resource,  @Value(&#171;classpath:prompts\/user.st&#187;) private val userResource: Resource,) {  private val chatClient: ChatClient = chatClientBuilder.build()    fun generate(command: String, theme: String): String {    val systemMessage = SystemPromptTemplate(systemResource).createMessage()    val userMessage = PromptTemplate(userResource)    .createMessage(mapOf(&#171;command&#187; to command, &#171;theme&#187; to theme))    return chatClient      .prompt(Prompt(listOf(systemMessage, userMessage)))      .call()      .content()      ?: error(&#171;ChatClient returned null content for command=&#8217;$command&#8217;, theme=&#8217;$theme'&#187;)  }}\u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441curl &#8212;location &#8212;request POST &#8216;localhost:8080\/api\/haiku&#8217; \\\u2013-header&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-479766","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=479766"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479766\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=479766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=479766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=479766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}