{"id":469604,"date":"2025-08-05T09:02:49","date_gmt":"2025-08-05T09:02:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=469604"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=469604","title":{"rendered":"<span>\u041a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b AI \u0430\u0433\u0435\u043d\u0442\u044b: \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 ReAct \u0438 Reflection<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! <\/p>\n<p>\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f AI \u0430\u0433\u0435\u043d\u0442\u044b \u0441\u0442\u0430\u043b\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0442\u0440\u0435\u043d\u0434\u043e\u043c. \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>create_react_agent <\/em>\u0438\u0437 <em>langchain<\/em>, \u043d\u043e \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0430\u0433\u0435\u043d\u0442\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0438 \u043f\u0440\u0438\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e <em>ReAct <\/em>\u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e <em>Reflection <\/em>\u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 <em>prompt <\/em>\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 <\/p>\n<\/li>\n<li>\n<p>\u041a\u0435\u0439\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 <\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 AI \u0430\u0433\u0435\u043d\u0442<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043a\u043e\u0434\u0443, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u043e\u043c. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<ul>\n<li>\n<p><em>AI \u0430\u0433\u0435\u043d\u0442<\/em>  &#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043e\u0439 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0430\u0433\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447<\/p>\n<\/li>\n<li>\n<p><em>AI \u0430\u0433\u0435\u043d\u0442<\/em> &#8212; \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0441\u0435 \u043e\u043d\u0438 \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c: \u0430\u0433\u0435\u043d\u0442\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u043c\u0435\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e \u0438 \u0441\u0430\u043c\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0440\u0430\u0441\u043f\u043b\u044b\u0432\u0447\u0430\u0442\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u0432\u0430\u043b\u0438 \u043a\u0435\u0439\u0441\u044b, \u043a\u043e\u0433\u0434\u0430 \u0430\u0433\u0435\u043d\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0448\u0430\u0433\u0430\u0445, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0431\u044b\u043b\u0430 \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439.  <\/p>\n<p><strong>\u0421\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 AI \u0430\u0433\u0435\u043d\u0442\u043e\u0432:<\/strong><\/p>\n<ol>\n<li>\n<p><em>System Prompt <\/em><\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0435\u0442 \u0440\u043e\u043b\u044c <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>Tools <\/em>(\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b)<\/p>\n<ul>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0430\u0433\u0435\u043d\u0442\u0443 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0438\u0441\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438\u043b\u0438 \u0431\u0430\u0437\u0435<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/em><\/p>\n<ul>\n<li>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0441\u0440\u043e\u0447\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c <\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043b\u0433\u043e\u0441\u0440\u043e\u0447\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <em>LLM <\/em>\u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438\u043b\u0438 \u0434\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441\u043d\u043e-\u043e\u0442\u0432\u0435\u0442\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b, \u0442\u043e \u0432\u0430\u0448\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>LLM <\/em>&#8212; \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u043e\u043c, \u0430 \u043d\u0435 \u0430\u0433\u0435\u043d\u0442\u043e\u043c. <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 &#8212; \u0432 \u043c\u043e\u0438\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445:<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/918048\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439 RAG: \u043e\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0441 LangGraph. \u0427\u0430\u0441\u0442\u044c 2 \/ \u0425\u0430\u0431\u0440<\/a>  <\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/876844\/\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 AI-\u0430\u0433\u0435\u043d\u0442\u0430\u0445. \u0427\u0430\u0441\u0442\u044c 2. Retrievers, TextSplitters<\/a>  <\/p>\n<p> \u0438 \u043c\u043e\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0435. \u0412 \u043d\u0435\u043c \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p>\u0424\u0430\u0439\u043b \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\u043c\u0438 (<em>Supervisor<\/em>, <em>plan-and-execute<\/em>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0432 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0430<\/strong>: <a href=\"https:\/\/t.me\/+otyoa0mN5nVmZjIy\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0439 \u043a\u0430\u043d\u0430\u043b<\/a><\/p>\n<h2>\u0412\u0438\u0434\u044b \u0430\u0433\u0435\u043d\u0442\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440<\/h2>\n<p>\u0410\u0433\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0434\u0432\u0435 \u0433\u0440\u0443\u043f\u043f\u044b:<\/p>\n<ul>\n<li>\n<p>\u0410\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u0433\u0435\u043d\u0442\u044b \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u0443\u043c\u0435\u044e\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \/ \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u044b. <\/p>\n<p>\u0410\u0433\u0435\u043d\u0442\u044b \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043b\u0430\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044e, \u043d\u043e \u043f\u0440\u043e\u0449\u0435 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0432\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f. \u0421\u0444\u0435\u0440\u0430 AI \u0435\u0449\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043e\u043b\u043e\u0434\u0430\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0441\u0435\u0431\u044f. <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <\/h2>\n<p>\u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>langchain<\/em>, <em>langchain_gigachat<\/em>. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c langgraph <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:<\/p>\n<pre><code class=\"python\">!pip install langchain langchain-gigachat<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">from langchain_gigachat import GigaChat llm = GigaChat(     verify_ssl_certs=False,     credentials=\"\u0442\u043e\u043a\u0435\u043d\",     model=\"GigaChat-2\",     temperature=0.1 )<\/code><\/pre>\n<p>\u0422\u043e\u043a\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e <\/strong>\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 GigaChat<\/p>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/strong><\/p>\n<pre><code class=\"python\">from langchain.tools import BaseTool from pydantic import BaseModel, Field from typing import Optional, Any, Type import json<\/code><\/pre>\n<h2>ReAct agent<\/h2>\n<p>\u042f\u0440\u043a\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>ReAct <\/em>\u0430\u0433\u0435\u043d\u0442. <\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0433\u0435\u043d\u0442\u0430: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 <em>FINISH <\/em><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0421\u043d\u043e\u0432\u0430 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 (\u0448\u0430\u0433 1)<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e  &#8212; \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u0430. <\/p>\n<p>\u041a\u0435\u0439\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f: <\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0434\u043d\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u043f\u0438\u0448\u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 10 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0425\u0430\u0431\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 \u0418\u0418. <\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u0433\u0435\u043d\u0442\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442: <\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a API \u0445\u0430\u0431\u0440\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0441\u0443\u043c\u043c\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e <\/p>\n<\/li>\n<li>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 <\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <\/strong><\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0448\u0443 \u0434\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0438\u043c\u043f\u0440\u043e\u0432\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0438 \u0447\u0442\u0435\u043d\u0438\u0435. <strong>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/strong> \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u044f \u0437\u0430\u0434\u0430\u044e \u0441\u0445\u0435\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<strong> <\/strong><\/p>\n<pre><code class=\"python\">#\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0431\u0430\u0437\u0443 (\u0441\u043b\u043e\u0432\u0430\u0440\u044c) class RegisterUserInput(BaseModel):     username: str = Field(..., description=\"\u041b\u043e\u0433\u0438\u043d\", examples=[\"ViacheslavVoo\"])     email: str = Field(..., description=\"Email\", examples=[\"Viacheslav@test.com\"])     phone: Optional[str] = Field(None, description=\"\u041d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 +7XXX...\", examples=[\"+7999999999\"])   class RegisterUserTool(BaseTool):     name: str = \"register_user\"     description: str = \"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435\"     args_schema: Type[BaseModel] = RegisterUserInput      def _run(self, **kwargs):         users[kwargs[\"username\"]] = kwargs[\"email\"]         return f\"User {kwargs['username']} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\"   # \u043f\u043e\u0438\u0441\u043a \u0432 \u0431\u0430\u0437\u0435 (\u0441\u043b\u043e\u0432\u0430\u0440\u0435)       class SearchDBInput(BaseModel):     username: str = Field(..., description=\"\u041b\u043e\u0433\u0438\u043d\/\u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\", examples=[\"ViacheslavVoo\"])     limit: Optional[int] = Field(5, description=\"\u041b\u0438\u043c\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432\")   class SearchDBTool(BaseTool):     name: str = \"search_db\"     description: str = \"\u0418\u0449\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435\"     args_schema: Type[BaseModel] = SearchDBInput      def _run(self, username: str, limit: int = 5):         return f\"\u041d\u0430\u0439\u0434\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {users[username]}'\" <\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0442\u044f\u0436\u0435\u043b\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c, \u043d\u0435 \u0438\u043c\u0435\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u044b, \u044f \u043d\u0430\u0447\u043d\u0443 \u0441 \u043e\u0431\u0449\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. <\/p>\n<p><strong>\u041a\u0430\u0440\u043a\u0430\u0441 \u0430\u0433\u0435\u043d\u0442\u0430<\/strong><\/p>\n<ol>\n<li>\n<p><em>run()<\/em><\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>build_prompt()<\/em><\/p>\n<ul>\n<li>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>parse_response<\/em>()<\/p>\n<ul>\n<li>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0448\u0430\u0433  &#8212; \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 &#8212; <em>final_answer()<\/em><\/p>\n<p>\u041a\u0430\u0440\u043a\u0430\u0441 \u0430\u0433\u0435\u043d\u0442\u0430 \u043d\u0430 Python:<\/p>\n<pre><code class=\"python\">class ReactAgent:    def __init__(self, tools: list[BaseTool], llm, max_iterations: int = 5):         self.tools = {tool.name: tool for tool in tools}         self.llm = llm         self.max_iterations = max_iterations         self.history = []      @property     def tool_desc(self):       pass      def run(self, task: str) -&gt; str:         pass      def _build_prompt(self, task: str) -&gt; str:        pass      def _parse_response(self, response: str) -&gt; tuple[str, dict]:        pass      def _final_answer(self, task: str) -&gt; str:       pass<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0433\u0435\u043d\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 <\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. <\/p>\n<p><strong>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<em> tool_desc<\/em>. <\/strong><\/p>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u043c\u043f\u0442\u0435. <\/p>\n<pre><code class=\"python\">@property def  tool_desc(self):   tools_desc = []         for tool in self.tools.values():             args_desc = \"\\n\".join(                 f\"    {field}: {value.description} ({'\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439' if value.is_required() else '\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439'})\"                 for field, value in tool.args_schema.model_fields.items()             )             tools_desc.append(f\"{tool.name} - {tool.description}\\n{args_desc}\")         tools_desc.append(f\"FINISH  - \u0432\u044b\u0431\u0435\u0440\u0438 \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430\")         return tools_desc<\/code><\/pre>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <em>build_prompt.<\/em><\/strong><\/p>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>prompt<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0420\u043e\u043b\u044c \u0430\u0433\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b <\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043c\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 <em>FINISH <\/em>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430 <em>action_input<\/em>. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">  def _build_prompt(self, task: str) -&gt; str:         history = \"\\n\".join(self.history[-3:]) if self.history else \"\u041d\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u0438\"          return f\"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0435\u0448\u0430\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432         \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c FINISH \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430                   **\u0417\u0430\u0434\u0430\u0447\u0430**: {task}          **\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b**:         {chr(10).join(self.tool_desc)}                  **\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438**:         -\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0437\u0430\u0434\u0430\u0447\u0443          -\u043f\u0440\u043e\u0430\u043d\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u044e          -\u0432\u044b\u0431\u0435\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.          -\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u044b \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435         -\u0435\u0441\u043b\u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u044b \u0443\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438  \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0438\u043b\u0438 \u043a FINISH.         -\u0435\u0441\u043b\u0438 \u0442\u044b \u0432\u044b\u0431\u0435\u0440\u0430\u0435\u0448\u044c FINISH  \u0442\u043e action_input: \"\"          **\u0422\u0432\u043e\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432**:         {history}                        **\u041e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON**:         {{             \"action\": \"\u0438\u043c\u044f_\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\",             \"action_input\": {{                 \"arg1\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\",                 \"arg2\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\"             }},             \"though\": \"\u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\"         }}                  \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0432\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438. \u041d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432         \"\"\" <\/code><\/pre>\n<p><strong><em>parse_response<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 <em>LLM  <\/em>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. <\/p>\n<pre><code class=\"python\">  def _parse_response(self, response: str) -&gt; tuple[str, dict]:         data = json.loads(response.strip())         return data[\"action\"], data[\"action_input\"]<\/code><\/pre>\n<p><strong><em>final_answer<\/em><\/strong><\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442. \u042d\u0442\u043e\u0442 \u0448\u0430\u0433 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435. <\/p>\n<pre><code class=\"python\">    def _final_answer(self, task: str) -&gt; str:         prompt = \"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.                   \u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: {user_input}                  \u0418\u0442\u0441\u043e\u0440\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: {history}                  \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442  - \u0432\u044b\u0432\u043e\u0434 \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438.         \"\"\"         chain = ChatPromptTemplate.from_template(prompt) | self.llm | StrOutputParser()         return chain.invoke({\"user_input\": task, \"history\": self.history})<\/code><\/pre>\n<p><strong><em>run<\/em><\/strong><\/p>\n<p>\u0412 \u043d\u0435\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>prompt<\/em><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c <em>action\/action_input<\/em><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\"> def run(self, task: str) -&gt; str:         for _ in range(self.max_iterations):             prompt = self._build_prompt(task)             llm_response = self.llm.invoke(prompt)              try:                 # 2. \u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u043e\u0442\u0432\u0435\u0442\u0430                 action, action_input = self._parse_response(llm_response.content)                     if action == \"FINISH\":                     return action_input             except Exception as e:                 self.history.append(f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430: {str(e)}\")                 continue              # 3. \u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435             if action not in self.tools:                 self.history.append(f\"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442: {action}\")                 continue              tool = self.tools[action]             try:                 observation = tool.run(action_input)                 self.history.append(f\"\u0422\u044b \u0432\u044b\u0437\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442:{action}({action_input}) \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: {observation}\")             except Exception as e:                 self.history.append(f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f {action}: {str(e)}\")          return \"\u0414\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442 \u043b\u0438\u043c\u0438\u0442 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439\"<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0432\u0435\u0442\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e.<\/p>\n<p><strong><em>\u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a ReAct \u0430\u0433\u0435\u043d\u0442\u0430<\/em><\/strong>: \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u043d \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043b\u0430\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438\u043b\u0438 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 <em>\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f<\/em>. <\/p>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u0430\u0433\u0435\u043d\u0442\u0430:<\/strong><\/p>\n<pre><code class=\"python\">from src.llm import llm #\u0432\u0430\u0448\u0430 \u044f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c.   if __name__ == \"__main__\":     agent = ReactAgent(tools, llm)      # \u0417\u0430\u0434\u0430\u0447\u0430 1: \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f     result = agent.run(\"\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Ivan \u0441 email ivan@test.com\")     print(result)      # \u0421\u043e\u0441\u0442\u0430\u0432\u043d\u0430\u044f \u0417\u0430\u0434\u0430\u0447\u0430 2: \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u043f\u043e\u0438\u0441\u043a     result = agent.run(\"\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Viacheslav \u0441 email Viacheslav@test.com \u0438 \u043d\u0430\u0439\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Ivan\")     print(result)<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 <em>Prompt <\/em>\u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">          \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0435\u0448\u0430\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432         \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c FINISH \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430                   **\u0417\u0430\u0434\u0430\u0447\u0430**: \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Ivan \u0441 email ivan@test.com          **\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b**:         register_user - \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435     username: \u041b\u043e\u0433\u0438\u043d (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)     email: Email (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)     phone: \u041d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 +7XXX... (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439) search_db - \u0418\u0449\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0431\u0430\u0437\u0435     username: \u041b\u043e\u0433\u0438\u043d (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)     limit: \u041b\u0438\u043c\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439) FINISH  - \u0432\u044b\u0431\u0435\u0440\u0438 \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430                  **\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438**:         -\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0437\u0430\u0434\u0430\u0447\u0443          -\u043f\u0440\u043e\u0430\u043d\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u044e          -\u0432\u044b\u0431\u0435\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.          -\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u044b \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435         -\u0435\u0441\u043b\u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u044b \u0443\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438  \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0438\u043b\u0438 \u043a FINISH.         -\u0435\u0441\u043b\u0438 \u0442\u044b \u0432\u044b\u0431\u0435\u0440\u0430\u0435\u0448\u044c FINISH  \u0442\u043e action_input: \"\"          **\u0422\u0432\u043e\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432**:         \u041d\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u0438                     **\u041e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON**:         {             \"action\": \"\u0438\u043c\u044f_\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\",             \"action_input\": {                 \"arg1\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\",                 \"arg2\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\"             },             \"though\": \"\u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\"         }                  \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0432\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438. \u041d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432         <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"python\">       **\u0422\u0432\u043e\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432**: \u0422\u044b \u0432\u044b\u0437\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442:register_user({'username': 'Viacheslav', 'email': 'Viacheslav@test.com'}) \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: User Viacheslav \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0422\u044b \u0432\u044b\u0437\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442:search_db({'username': 'Ivan'}) \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u041d\u0430\u0439\u0434\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c ivan@test.com'         <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"python\">\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c Ivan \u0441 email ivan@test.com \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d<\/code><\/pre>\n<p><strong>\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433 \u043f\u043e <em>React Agent<\/em>:<\/strong><\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c (\u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432)<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u0420\u0438\u0441\u043a \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 LLM. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, GigaChat-Lite \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<h2>Reflection Agent<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0430\u0433\u0435\u043d\u0442\u043e\u0432. \u041e\u043d \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 <em>ReAct<\/em>, \u043d\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c: <em>\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u043d\u0435\u0435. <\/em> \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u044f \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443 \u043f\u043e\u0434 Reflection \u0430\u0433\u0435\u043d\u0442\u043e\u043c, \u0430\u0433\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<p><strong>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0438 \u044f \u0432\u044b\u043b\u043e\u0436\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e. <\/strong><\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: <em>ReAct <\/em>\u0441\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0435\u043b\u0438 GigaChat-2. \u0414\u043b\u044f<em> Reflection agent<\/em> \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b GigaChat-2-Max, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043b\u0430\u0434\u0448\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430. <\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 != <em>FINISH <\/em>-&gt; \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u0443\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a 1<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u0443\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435: \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 -&gt; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 prompt -&gt; \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0448\u0430\u0433\u0443 1 <\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u0439\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443 \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0448\u0430\u0433\u0443 \u0441 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0434<strong> \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u0441\u0445\u0435\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/strong>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<p>\u0414\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u043c\u043d\u0435 \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c  \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0435\u0433\u043e \u0438\u0434\u0435\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u044e\u0434\u0430. <\/p>\n<p>\u0425\u043e\u0442\u044f&#8230; \u041a\u0430\u0436\u0434\u044b\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u0435\u043d)<\/p>\n<p>\u041a\u0430\u0440\u043a\u0430\u0441 \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\n<p><em>run<\/em>()  &#8212; \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0433\u0435\u043d\u0442 <\/p>\n<\/li>\n<li>\n<p><em>exectute_exction<\/em>()  &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p><em>needs_reflection<\/em>()  &#8212; \u043c\u0435\u0442\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<\/li>\n<li>\n<p><em>perform_reflection<\/em>() &#8212; \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u0443\u044e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044e \u043f\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438<\/p>\n<\/li>\n<li>\n<p><em>build_prompt<\/em>() &#8212; \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 prompt \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439, \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <\/p>\n<\/li>\n<li>\n<p><em>build_reflection_prompt<\/em>() &#8212; \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 prompt \u0441 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0435\u0439 \u043f\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438 <\/p>\n<\/li>\n<li>\n<p><em>store_memory<\/em>() &#8212; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e<\/p>\n<\/li>\n<\/ol>\n<p><em>perform_reflection() \u0438 build_reflection_prompt()<\/em> \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430.<\/p>\n<p>\u041a\u0430\u0440\u043a\u0430\u0441 \u043d\u0430 Python:<\/p>\n<pre><code class=\"python\"> class ReflectionAgent:     \"\"\"\u0410\u0433\u0435\u043d\u0442 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0430\u043c\u043e\u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u0432\u043e\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439\"\"\"      def __init__(self,                  llm,                  tools: list,                  max_iterations: int = 5,                  timeout: int = 10):          self.llm = llm         self.tools = {tool.name: tool for tool in tools}         self.max_iterations = max_iterations         self.timeout = timeout         self.history = []         self.iteration = 0      @property     def tool_desc(self):         #\u0420\u0415\u0410\u041b\u0418\u0417\u0410\u0426\u0418\u042f \u041a\u0410\u041a \u0423 ReAct agent            def run(self, task: str) -&gt; str:         pass      def _execute_action(self, action: str, action_input: str) -&gt; str:        pass            def _perform_reflection(self) -&gt; str:        pass      def _build_prompt(self, task: str) -&gt; str:       pass          def _parse_response(self, response: str) -&gt; tuple:        pass      def _reset_state(self):        pass      def _store_memory(self, thought: str, action: str, action_input: str, observation: str):        pass            def _handle_finish(self, result: str) -&gt; str:        pass      def _handle_max_iterations_reached(self) -&gt; str:        pass  <\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 <em>execute_action<\/em>:<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f: <\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0435\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043b\u0438 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0430\u0447\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/strong>: \u0432 \u043e\u0448\u0438\u0431\u043a\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0432\u043e &#171;\u041e\u0448\u0438\u0431\u043a\u0430 \/ error \u0438\u043b\u0438 \u0442.\u043f&#187;<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\"> def _execute_action(self, action: str, action_input: str) -&gt; str:         # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430         if action not in self.tools:             return f\"\u041e\u0448\u0438\u0431\u043a\u0430: \u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 '{action}' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b: {self.tool_desc}\"          try:             tool = self.tools[action]             result = tool.run(action_input)             return result         except Exception as e:             return f\"Error executing '{action}': {str(e)}\"<\/code><\/pre>\n<p><strong>\u0411\u043b\u043e\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0435\u0439<\/strong><\/p>\n<p><em>needs_reflection.<\/em> \u0415\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435: <\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0435\u0442 -&gt; \u0430\u043d\u0430\u043b\u0438\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0435\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e <\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0438 (observation) \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0435\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430 -&gt; return True<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043f\u043e\u0434\u0440\u044f\u0434 \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 -&gt; return True<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445: return False<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f<\/p>\n<pre><code class=\"python\">   def _needs_reflection(self) -&gt; bool:         \"\"\"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e\"\"\"         if not self.history:             return False         last_action = self.history[-1]                  # \u0420\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f \u043f\u0440\u0438 \u044f\u0432\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0430\u0445         if any(keyword in last_action['observation'].lower()                for keyword in [\"error\", \"fail\", \"unknown\", \"\u043e\u0448\u0438\u0431\u043a\u0430\"]):             return True              # \u0418\u043b\u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u043e\u0434\u0440\u044f\u0434         if len(self.history) &gt; 2:             last_actions = [m['action'] for m in self.history[-3:]]             if len(set(last_actions)) == 1:  # \u0412\u0441\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435                 return True         return False <\/code><\/pre>\n<p><strong><em>perform_reflection<\/em><\/strong><\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 \u043f\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438. \u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c<em> \u0441\u0432\u043e\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 prompt, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u0445 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432<\/em>. \u042f \u043d\u0430\u043f\u0438\u0448\u0443 \u043e\u0431\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443. <\/p>\n<pre><code class=\"python\">   def _perform_reflection(self) -&gt; str:         history = \"\\n\".join(             f\"Iteration {i}: {m['action']}({m['action_input']}) =&gt; {m['observation'][:100]}...\"             for i, m in enumerate(self.history)         )          reflection_prompt = f\"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 AI \u0430\u0433\u0435\u043d\u0442\u0443 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (tools)         \u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432:         {history}                  \u0422\u0432\u043e\u044f \u0437\u0430\u0434\u0430\u0447\u0430: \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0437\u043e\u0432, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043e\u0448\u0438\u0431\u043a\u0438. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438 \u0438\u0437 \u0437\u0430 \u0447\u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u043a\u0430\u043a \u0435\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.          \u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u043a\u0440\u0430\u0442\u043a\u043e.         \"\"\"         return self.llm.invoke(reflection_prompt).content<\/code><\/pre>\n<p><strong><em>build_reflection_prompt<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 <em>prompt<\/em>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442. <\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u041f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c (\u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439). \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0442\u0430\u043b\u0438\u0441\u044c, \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e. \u0412\u0441\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044e \u043a \u043e\u0448\u0438\u0431\u043a\u0435. <\/p>\n<pre><code class=\"python\"> def _build_reflection_prompt(self, task: str, reflection: str) -&gt; str:         \"\"\"\u0421\u0442\u0440\u043e\u0438\u0442 \u043f\u0440\u043e\u043c\u043f\u0442 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438\"\"\"         history = \"\\n\".join(             f\"\"\"Iteration {i}:             Thought: {m['thought']}             Action: {m['action']}             ActionInput: {m['action_input']}             Observation: {m['observation'][:200]}...         \"\"\"             for i, m in enumerate(self.history)         )          return f\"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.          \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043e\u043a:         {reflection}          \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:         {history}          \u0422\u0432\u043e\u044f \u0437\u0430\u0434\u0430\u0447\u0430: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438, \u0440\u0435\u0448\u0438 \u0437\u0430\u0434\u0430\u0447\u0443:         {task}          \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0439 \u0442\u043e\u0442 \u0436\u0435 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0432\u043e\u0434\u0430 \u0447\u0442\u043e \u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0435 \u043f\u0438\u0448\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043a\u0440\u043e\u043c\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.          \u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u0441\u0442\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a. \u0420\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u0439 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c.          \"\"\"<\/code><\/pre>\n<p><strong><em>build_prompt<\/em><\/strong><\/p>\n<p>\u0412 \u043d\u0435\u043c \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 <em>prompt<\/em> \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435 \u0438 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0430\u0431\u0437\u0430\u0446\u0435\u0432. <\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>: \u0432 \u043f\u0440\u043e\u043c\u043f\u0442\u0435 \u043c\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c <em>FINISH<\/em>. <\/p>\n<pre><code class=\"python\">    def _build_prompt(self, task: str) -&gt; str:         \"\"\"\u0421\u0442\u0440\u043e\u0438\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442\"\"\"         history = \"\\n\".join(             [                 f\"iteration: {d['iteration']}. thought: {d['thought']}. action: {d['action']}. action_input: {str(d['action_input'])} observation: {d['observation']}\"                 for d in self.history             ]         ) if self.history else \"\u041d\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u0438\"            return f\"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0435\u0448\u0430\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u044b \u0434\u043e\u043b\u0436\u0435\u043d          \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u044b\u043d\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430          **\u0417\u0430\u0434\u0430\u0447\u0430** {task}                  **\u0422\u0432\u043e\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432**:         {history}                  **\u0414\u043e\u0441\u0442\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b**         {self.tool_desc}                  **\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438**:         -\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0437\u0430\u0434\u0430\u0447\u0443          -\u043f\u0440\u043e\u0430\u043d\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u044e          -\u0432\u044b\u0431\u0435\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.          -\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u044b \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435         -\u0435\u0441\u043b\u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u044b \u0443\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438  \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0438\u043b\u0438 \u043a FINISH.         -\u0435\u0441\u043b\u0438 \u0442\u044b \u0432\u044b\u0431\u0435\u0440\u0430\u0435\u0448\u044c FINISH  \u0442\u043e action_input: \"\"          **\u041e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON**:         {{             \"action\": \"\u0438\u043c\u044f_\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\",             \"action_input\": {{                 \"arg1\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\",                 \"arg2\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\"             }},             \"thought\": \"\u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\"         }}          \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0432\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438. \u041d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432        \"\"\"<\/code><\/pre>\n<p><strong><em>parse_response<\/em><\/strong><\/p>\n<p>\u041e\u043d \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 <em>ReAct <\/em>\u0430\u0433\u0435\u043d\u0442\u0430<\/p>\n<pre><code class=\"python\">  def _parse_response(self, response: str) -&gt; tuple:         \"\"\"\u041f\u0430\u0440\u0441\u0438\u0442 \u043e\u0442\u0432\u0435\u0442 LLM\"\"\"         data = json.loads(response.strip())         return data[\"thought\"], data[\"action\"], data[\"action_input\"]<\/code><\/pre>\n<p><em>store_memory<\/em><\/p>\n<p>\u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<pre><code class=\"python\"> def _store_memory(self, thought: str, action: str, action_input: str, observation: str):         \"\"\"\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u0430\"\"\"         self.history.append({             'iteration': self.iteration,             'thought': thought,             'action': action,             'action_input': action_input,             'observation': observation         })<\/code><\/pre>\n<p>\u0414\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u043b\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 <em>run<\/em>. <\/p>\n<p><strong><em>handle_finish<\/em><\/strong><\/p>\n<pre><code class=\"python\">   def _handle_finish(self, result: str) -&gt; str:         \"\"\"\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438\"\"\"         print(f\"\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\")         return result<\/code><\/pre>\n<p><strong><em>handle_max_iterations_reached<\/em><\/strong><\/p>\n<pre><code class=\"python\"> def _handle_max_iterations_reached(self) -&gt; str:         \"\"\"\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439\"\"\"         last_observation = self.history[-1]['observation'] if self.history else \"No actions taken\"         return f\"Max iterations reached. Last state: {last_observation}\"<\/code><\/pre>\n<p>\u041c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. <\/p>\n<p><strong><em>run<\/em><\/strong><\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 <em>prompt <\/em><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c <\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442 <\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 != FINISH, \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044c, \u043d\u0443\u0436\u043d\u0430 \u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0430\u0434 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 <\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0448\u0430\u0433\u0443  2<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\"> def run(self, task: str) -&gt; str:         prompt = self._build_prompt(task)                while self.iteration &lt; self.max_iterations:             response = self.llm.invoke(prompt)             thought, action, action_input = self._parse_response(response.content)              if action == \"FINISH\":                 return self._handle_finish(action_input)              observation = self._execute_action(action, action_input)              self._store_memory(thought, action, action_input, observation)              if self._needs_reflection():                 reflection = self._perform_reflection()                 prompt = self._build_reflection_prompt(task, reflection)             else:                 prompt = self._build_prompt(task)             self.iteration += 1          return self._handle_max_iterations_reached()<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b ReAct \u0430\u0433\u0435\u043d\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u043e\u0437\u0434\u0430\u043c \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 , \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430: email -&gt; user_email. <\/p>\n<pre><code class=\"python\">INIT PROMPT          \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0435\u0448\u0430\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u044b \u0434\u043e\u043b\u0436\u0435\u043d          \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u044b\u043d\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430          **\u0417\u0430\u0434\u0430\u0447\u0430** \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Ivan \u0441 email ivan@test.com                  **\u0422\u0432\u043e\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432**:         \u041d\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u0438                  **\u0414\u043e\u0441\u0442\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b**         ['register_user - \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435\\n    username: \u041b\u043e\u0433\u0438\u043d (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)\\n    email: Email (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)\\n    phone: \u041d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 +7XXX... (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439)', 'search_db - \u0418\u0449\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0431\u0430\u0437\u0435\\n    username: \u041b\u043e\u0433\u0438\u043d\/\u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)\\n    limit: \u041b\u0438\u043c\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439)', 'FINISH  - \u0432\u044b\u0431\u0435\u0440\u0438 \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430']                  **\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438**:         -\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0437\u0430\u0434\u0430\u0447\u0443          -\u043f\u0440\u043e\u0430\u043d\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u044e          -\u0432\u044b\u0431\u0435\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.          -\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u044b \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435         -\u0435\u0441\u043b\u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u044b \u0443\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438  \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0438\u043b\u0438 \u043a FINISH.         -\u0435\u0441\u043b\u0438 \u0442\u044b \u0432\u044b\u0431\u0435\u0440\u0430\u0435\u0448\u044c FINISH  \u0442\u043e action_input: \"\"          **\u041e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON**:         {             \"action\": \"\u0438\u043c\u044f_\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\",             \"action_input\": {                 \"arg1\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\",                 \"arg2\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\"             },             \"thought\": \"\u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\"         }          \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0432\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438. \u041d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432          RESPONSE content='{\\n    \"action\": \"register_user\",\\n    \"action_input\": {\\n        \"username\": \"Ivan\",\\n        \"email\": \"ivan@test.com\"\\n    },\\n    \"thought\": \"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0418\u0432\u0430\u043d \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0435\u043c\u0435\u0439\u043b\u043e\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438.\"\\n}' additional_kwargs={} response_metadata={'token_usage': {'prompt_tokens': 394, 'completion_tokens': 59, 'total_tokens': 453, 'precached_prompt_tokens': 3}, 'model_name': 'GigaChat-2-Max:2.0.28.2', 'x_headers': {'x-request-id': 'e1509dc9-13c6-4c97-b84d-31e363a80243', 'x-session-id': '5fb1ce37-f276-4ab1-a5cb-4110b43903a5', 'x-client-id': None}, 'finish_reason': 'stop'} id='e1509dc9-13c6-4c97-b84d-31e363a80243' usage_metadata={'output_tokens': 59, 'input_tokens': 394, 'total_tokens': 453, 'input_token_details': {'cache_read': 3}} {     \"action\": \"register_user\",     \"action_input\": {         \"username\": \"Ivan\",         \"email\": \"ivan@test.com\"     },     \"thought\": \"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0418\u0432\u0430\u043d \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0435\u043c\u0435\u0439\u043b\u043e\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438.\" }<\/code><\/pre>\n<p>\u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"python\">[Action Log] Iteration: 0 Tool: register_user Input: {'username': 'Ivan', 'email': 'ivan@test.com'} Result: \u041e\u0448\u0438\u0431\u043a\u0430 : \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 email. \u0414\u043e\u0441\u0442\u043f\u0443\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b: user_email, username...<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<pre><code class=\"python\">REFLECTION \u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0438\u0437-\u0437\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 `email`, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 `user_email`. \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432: ```python register_user({'username': 'Ivan', 'user_email': 'ivan@test.com'}) ```<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 prompt \u0441 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u043e\u0439 \u043f\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\">PROMPT AFTER REFLECTION          \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.          \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043e\u043a:         \u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0438\u0437-\u0437\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 `email`, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 `user_email`. \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432: ```python register_user({'username': 'Ivan', 'user_email': 'ivan@test.com'}) ```          \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:         Iteration 0:             Thought: \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0418\u0432\u0430\u043d \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0435\u043c\u0435\u0439\u043b\u043e\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438.             Action: register_user             ActionInput: {'username': 'Ivan', 'email': 'ivan@test.com'}             Observation: \u041e\u0448\u0438\u0431\u043a\u0430 : \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 email. \u0414\u043e\u0441\u0442\u043f\u0443\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b: user_email, username...                   \u0422\u0432\u043e\u044f \u0437\u0430\u0434\u0430\u0447\u0430: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438, \u0440\u0435\u0448\u0438 \u0437\u0430\u0434\u0430\u0447\u0443:         \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Ivan \u0441 email ivan@test.com          \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0439 \u0442\u043e\u0442 \u0436\u0435 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0432\u043e\u0434\u0430 \u0447\u0442\u043e \u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0435 \u043f\u0438\u0448\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043a\u0440\u043e\u043c\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.          \u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u0441\u0442\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a. \u0420\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u0439 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c.  <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441<strong> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 email<\/strong>:<\/p>\n<pre><code>RESPONSE content='{\\n    \"thought\": \"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0418\u0432\u0430\u043d \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0435\u043c\u0435\u0439\u043b\u043e\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.\",\\n    \"action\": \"register_user\",\\n    \"action_input\": {\"username\": \"Ivan\", \"user_email\": \"ivan@test.com\"}\\n}' additional_kwargs={} response_metadata={'token_usage': {'prompt_tokens': 264, 'completion_tokens': 60, 'total_tokens': 324, 'precached_prompt_tokens': 3}, 'model_name': 'GigaChat-2-Max:2.0.28.2', 'x_headers': {'x-request-id': 'af90213d-6751-4ced-980c-9f9a26de140d', 'x-session-id': 'b104631f-f553-4ff6-8200-2e1d7bd9ed27', 'x-client-id': None}, 'finish_reason': 'stop'} id='af90213d-6751-4ced-980c-9f9a26de140d' usage_metadata={'output_tokens': 60, 'input_tokens': 264, 'total_tokens': 324, 'input_token_details': {'cache_read': 3}} RESPONSE IN PARSE {     \"thought\": \"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0418\u0432\u0430\u043d \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0435\u043c\u0435\u0439\u043b\u043e\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.\",     \"action\": \"register_user\",     \"action_input\": {\"username\": \"Ivan\", \"user_email\": \"ivan@test.com\"} }<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u043a \u0441\u0438\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421 \u043a\u0430\u0436\u0434\u044b\u043c \u043c\u0435\u0441\u044f\u0446\u0435\u043c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e ReAct) \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c\u0438. \u0418 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0441\u044c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043b\u043e\u0433\u0438\u043a\u0443. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d\u0430 \u0434\u0430\u0436\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u0432 AI \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f, \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c. <a href=\"https:\/\/t.me\/+otyoa0mN5nVmZjIy\" rel=\"noopener noreferrer nofollow\"><em>\u0413\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c  \u043a\u043e\u0434 \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c<\/em><\/a><em>, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435<\/em>)<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/933372\/\"> https:\/\/habr.com\/ru\/articles\/933372\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! <\/p>\n<p>\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f AI \u0430\u0433\u0435\u043d\u0442\u044b \u0441\u0442\u0430\u043b\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0442\u0440\u0435\u043d\u0434\u043e\u043c. \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>create_react_agent <\/em>\u0438\u0437 <em>langchain<\/em>, \u043d\u043e \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0430\u0433\u0435\u043d\u0442\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0438 \u043f\u0440\u0438\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e <em>ReAct <\/em>\u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e <em>Reflection <\/em>\u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 <em>prompt <\/em>\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 <\/p>\n<\/li>\n<li>\n<p>\u041a\u0435\u0439\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 <\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 AI \u0430\u0433\u0435\u043d\u0442<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043a\u043e\u0434\u0443, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u043e\u043c. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<ul>\n<li>\n<p><em>AI \u0430\u0433\u0435\u043d\u0442<\/em>  &#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043e\u0439 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0430\u0433\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447<\/p>\n<\/li>\n<li>\n<p><em>AI \u0430\u0433\u0435\u043d\u0442<\/em> &#8212; \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0441\u0435 \u043e\u043d\u0438 \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c: \u0430\u0433\u0435\u043d\u0442\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u043c\u0435\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e \u0438 \u0441\u0430\u043c\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0440\u0430\u0441\u043f\u043b\u044b\u0432\u0447\u0430\u0442\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u0432\u0430\u043b\u0438 \u043a\u0435\u0439\u0441\u044b, \u043a\u043e\u0433\u0434\u0430 \u0430\u0433\u0435\u043d\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0448\u0430\u0433\u0430\u0445, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0431\u044b\u043b\u0430 \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439.  <\/p>\n<p><strong>\u0421\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 AI \u0430\u0433\u0435\u043d\u0442\u043e\u0432:<\/strong><\/p>\n<ol>\n<li>\n<p><em>System Prompt <\/em><\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0435\u0442 \u0440\u043e\u043b\u044c <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>Tools <\/em>(\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b)<\/p>\n<ul>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0430\u0433\u0435\u043d\u0442\u0443 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0438\u0441\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438\u043b\u0438 \u0431\u0430\u0437\u0435<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/em><\/p>\n<ul>\n<li>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0441\u0440\u043e\u0447\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c <\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043b\u0433\u043e\u0441\u0440\u043e\u0447\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <em>LLM <\/em>\u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438\u043b\u0438 \u0434\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441\u043d\u043e-\u043e\u0442\u0432\u0435\u0442\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b, \u0442\u043e \u0432\u0430\u0448\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>LLM <\/em>&#8212; \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u043e\u043c, \u0430 \u043d\u0435 \u0430\u0433\u0435\u043d\u0442\u043e\u043c. <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 &#8212; \u0432 \u043c\u043e\u0438\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445:<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/918048\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439 RAG: \u043e\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0441 LangGraph. \u0427\u0430\u0441\u0442\u044c 2 \/ \u0425\u0430\u0431\u0440<\/a>  <\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/876844\/\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 AI-\u0430\u0433\u0435\u043d\u0442\u0430\u0445. \u0427\u0430\u0441\u0442\u044c 2. Retrievers, TextSplitters<\/a>  <\/p>\n<p> \u0438 \u043c\u043e\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0435. \u0412 \u043d\u0435\u043c \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<li>\n<p>\u0424\u0430\u0439\u043b \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\u043c\u0438 (<em>Supervisor<\/em>, <em>plan-and-execute<\/em>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0432 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0430<\/strong>: <a href=\"https:\/\/t.me\/+otyoa0mN5nVmZjIy\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0439 \u043a\u0430\u043d\u0430\u043b<\/a><\/p>\n<h2>\u0412\u0438\u0434\u044b \u0430\u0433\u0435\u043d\u0442\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440<\/h2>\n<p>\u0410\u0433\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0434\u0432\u0435 \u0433\u0440\u0443\u043f\u043f\u044b:<\/p>\n<ul>\n<li>\n<p>\u0410\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0435<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u0433\u0435\u043d\u0442\u044b \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u0443\u043c\u0435\u044e\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \/ \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u044b. <\/p>\n<p>\u0410\u0433\u0435\u043d\u0442\u044b \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043b\u0430\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044e, \u043d\u043e \u043f\u0440\u043e\u0449\u0435 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0432\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f. \u0421\u0444\u0435\u0440\u0430 AI \u0435\u0449\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043e\u043b\u043e\u0434\u0430\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0441\u0435\u0431\u044f. <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <\/h2>\n<p>\u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>langchain<\/em>, <em>langchain_gigachat<\/em>. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c langgraph <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:<\/p>\n<pre><code class=\"python\">!pip install langchain langchain-gigachat<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">from langchain_gigachat import GigaChat llm = GigaChat(     verify_ssl_certs=False,     credentials=\"\u0442\u043e\u043a\u0435\u043d\",     model=\"GigaChat-2\",     temperature=0.1 )<\/code><\/pre>\n<p>\u0422\u043e\u043a\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e <\/strong>\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 GigaChat<\/p>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/strong><\/p>\n<pre><code class=\"python\">from langchain.tools import BaseTool from pydantic import BaseModel, Field from typing import Optional, Any, Type import json<\/code><\/pre>\n<h2>ReAct agent<\/h2>\n<p>\u042f\u0440\u043a\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>ReAct <\/em>\u0430\u0433\u0435\u043d\u0442. <\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0433\u0435\u043d\u0442\u0430: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 <em>FINISH <\/em><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0421\u043d\u043e\u0432\u0430 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 (\u0448\u0430\u0433 1)<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e  &#8212; \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u0430. <\/p>\n<p>\u041a\u0435\u0439\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f: <\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0434\u043d\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u043f\u0438\u0448\u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 10 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0425\u0430\u0431\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 \u0418\u0418. <\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u0433\u0435\u043d\u0442\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442: <\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a API \u0445\u0430\u0431\u0440\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0441\u0443\u043c\u043c\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e <\/p>\n<\/li>\n<li>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 <\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <\/strong><\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0448\u0443 \u0434\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0438\u043c\u043f\u0440\u043e\u0432\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0438 \u0447\u0442\u0435\u043d\u0438\u0435. <strong>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/strong> \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u044f \u0437\u0430\u0434\u0430\u044e \u0441\u0445\u0435\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<strong> <\/strong><\/p>\n<pre><code class=\"python\">#\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0431\u0430\u0437\u0443 (\u0441\u043b\u043e\u0432\u0430\u0440\u044c) class RegisterUserInput(BaseModel):     username: str = Field(..., description=\"\u041b\u043e\u0433\u0438\u043d\", examples=[\"ViacheslavVoo\"])     email: str = Field(..., description=\"Email\", examples=[\"Viacheslav@test.com\"])     phone: Optional[str] = Field(None, description=\"\u041d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 +7XXX...\", examples=[\"+7999999999\"])   class RegisterUserTool(BaseTool):     name: str = \"register_user\"     description: str = \"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435\"     args_schema: Type[BaseModel] = RegisterUserInput      def _run(self, **kwargs):         users[kwargs[\"username\"]] = kwargs[\"email\"]         return f\"User {kwargs['username']} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\"   # \u043f\u043e\u0438\u0441\u043a \u0432 \u0431\u0430\u0437\u0435 (\u0441\u043b\u043e\u0432\u0430\u0440\u0435)       class SearchDBInput(BaseModel):     username: str = Field(..., description=\"\u041b\u043e\u0433\u0438\u043d\/\u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\", examples=[\"ViacheslavVoo\"])     limit: Optional[int] = Field(5, description=\"\u041b\u0438\u043c\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432\")   class SearchDBTool(BaseTool):     name: str = \"search_db\"     description: str = \"\u0418\u0449\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435\"     args_schema: Type[BaseModel] = SearchDBInput      def _run(self, username: str, limit: int = 5):         return f\"\u041d\u0430\u0439\u0434\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {users[username]}'\" <\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0442\u044f\u0436\u0435\u043b\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c, \u043d\u0435 \u0438\u043c\u0435\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u044b, \u044f \u043d\u0430\u0447\u043d\u0443 \u0441 \u043e\u0431\u0449\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. <\/p>\n<p><strong>\u041a\u0430\u0440\u043a\u0430\u0441 \u0430\u0433\u0435\u043d\u0442\u0430<\/strong><\/p>\n<ol>\n<li>\n<p><em>run()<\/em><\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0433\u0435\u043d\u0442\u0430 <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>build_prompt()<\/em><\/p>\n<ul>\n<li>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><em>parse_response<\/em>()<\/p>\n<ul>\n<li>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0448\u0430\u0433  &#8212; \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 &#8212; <em>final_answer()<\/em><\/p>\n<p>\u041a\u0430\u0440\u043a\u0430\u0441 \u0430\u0433\u0435\u043d\u0442\u0430 \u043d\u0430 Python:<\/p>\n<pre><code class=\"python\">class ReactAgent:    def __init__(self, tools: list[BaseTool], llm, max_iterations: int = 5):         self.tools = {tool.name: tool for tool in tools}         self.llm = llm         self.max_iterations = max_iterations         self.history = []      @property     def tool_desc(self):       pass      def run(self, task: str) -&gt; str:         pass      def _build_prompt(self, task: str) -&gt; str:        pass      def _parse_response(self, response: str) -&gt; tuple[str, dict]:        pass      def _final_answer(self, task: str) -&gt; str:       pass<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0433\u0435\u043d\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 <\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. <\/p>\n<p><strong>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<em> tool_desc<\/em>. <\/strong><\/p>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u043c\u043f\u0442\u0435. <\/p>\n<pre><code class=\"python\">@property def  tool_desc(self):   tools_desc = []         for tool in self.tools.values():             args_desc = \"\\n\".join(                 f\"    {field}: {value.description} ({'\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439' if value.is_required() else '\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439'})\"                 for field, value in tool.args_schema.model_fields.items()             )             tools_desc.append(f\"{tool.name} - {tool.description}\\n{args_desc}\")         tools_desc.append(f\"FINISH  - \u0432\u044b\u0431\u0435\u0440\u0438 \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430\")         return tools_desc<\/code><\/pre>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <em>build_prompt.<\/em><\/strong><\/p>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>prompt<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0420\u043e\u043b\u044c \u0430\u0433\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b <\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043c\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 <em>FINISH <\/em>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430 <em>action_input<\/em>. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">  def _build_prompt(self, task: str) -&gt; str:         history = \"\\n\".join(self.history[-3:]) if self.history else \"\u041d\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u0438\"          return f\"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0435\u0448\u0430\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432         \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c FINISH \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430                   **\u0417\u0430\u0434\u0430\u0447\u0430**: {task}          **\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b**:         {chr(10).join(self.tool_desc)}                  **\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438**:         -\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0437\u0430\u0434\u0430\u0447\u0443          -\u043f\u0440\u043e\u0430\u043d\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u044e          -\u0432\u044b\u0431\u0435\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 FINISH, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.          -\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u044b \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435         -\u0435\u0441\u043b\u0438 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u044b \u0443\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438  \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0438\u043b\u0438 \u043a FINISH.         -\u0435\u0441\u043b\u0438 \u0442\u044b \u0432\u044b\u0431\u0435\u0440\u0430\u0435\u0448\u044c FINISH  \u0442\u043e action_input: \"\"          **\u0422\u0432\u043e\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432**:         {history}                        **\u041e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON**:         {{             \"action\": \"\u0438\u043c\u044f_\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\",             \"action_input\": {{                 \"arg1\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\",                 \"arg2\": \"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\"             }},             \"though\": \"\u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\"         }}                  \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0432\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438. \u041d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432         \"\"\" <\/code><\/pre>\n<p><strong><em>parse_response<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 <em>LLM  <\/em>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. <\/p>\n<pre><code class=\"python\">  def _parse_response(self, response: str) -&gt; tuple[str, dict]:         data = json.loads(response.strip())         return data[\"action\"], data[\"action_input\"]<\/code><\/pre>\n<p><strong><em>final_answer<\/em><\/strong><\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442. \u042d\u0442\u043e\u0442 \u0448\u0430\u0433 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435. <\/p>\n<pre><code class=\"python\">    def _final_answer(self, task: str) -&gt; str:         prompt = \"\"\"         \u0422\u044b  - \u0443\u043c\u043d\u044b\u0439 \u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.                   \u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: {user_input}                  \u0418\u0442\u0441\u043e\u0440\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: {history}                  \u0412\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442  - \u0432\u044b\u0432\u043e\u0434 \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438.         \"\"\"         chain = ChatPromptTemplate.from_template(prompt) | self.llm | StrOutputParser()         return chain.invoke({\"user_input\": task, \"history\": self.history})<\/code><\/pre>\n<p><strong><em>run<\/em><\/strong><\/p>\n<p>\u0412 \u043d\u0435\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>prompt<\/em><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c <em>action\/action_input<\/em><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\"> def run(self, task: str) -&gt; str:         for _ in range(self.max_iterations):             prompt = self._build_prompt(task)             llm_response = self.llm.invoke(prompt)              try:        <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-469604","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469604","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=469604"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469604\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=469604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=469604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=469604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}