{"id":393693,"date":"2024-06-29T11:09:52","date_gmt":"2024-06-29T11:09:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=393693"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=393693","title":{"rendered":"<span>LangChain \u0434\u043b\u044f \u0431\u044b\u0432\u0430\u043b\u044b\u0445 \u2014 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0430\u0433\u0435\u043d\u0442\u044b. \u0447\u0430\u0441\u0442\u044c 2<\/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>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u00a0\u0432\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u00a0\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 LangChain. \u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/733262\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0432\u00a0\u0434\u0438\u0430\u043b\u043e\u0433\u0438 \u0441\u00a0LLM, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f \u043a\u00a0\u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Google. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u0430\u00a0\u0425\u0430\u0431\u0440\u0435 \u0438 \u043e\u043d\u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 <s>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0446\u0435\u043d\u0437\u0443\u0440\u044b<\/s> \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e. \u041d\u043e\u00a0\u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e\u00a0\u0440\u0443\u043a\u043e\u043f\u0438\u0441\u0438 \u043d\u0435\u00a0\u0433\u043e\u0440\u044f\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u00a0\u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/bit.ly\/3phBobh\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>\u041a\u0430\u043a\u00a0\u0443\u0436\u0435 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0432\u00a0\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u0430\u0433\u0435\u043d\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 LangChain. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a\u00a0\u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u0447\u0442\u043e\u00a0\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412\u00a0\u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a\u00a0\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f\u00a0\u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<h3>C\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u043a\u00a0\u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e\u00a0\u043d\u0430\u0448 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u0431\u043e\u0442\u0430\u00a0\u2014 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0441\u00a0\u043f\u0440\u0438\u043d\u0442\u0430\u043c\u0438. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0433\u043e \u0431\u0430\u0437\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>tshirts<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>type: \u0422\u0438\u043f \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, &#171;Type 1&#187;, &#171;Type 2&#187; \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>color: \u0426\u0432\u0435\u0442 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>size: \u0420\u0430\u0437\u043c\u0435\u0440 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>quantity: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>print_id: \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#171;prints&#187;<\/p>\n<\/li>\n<li>\n<p>price: \u0426\u0435\u043d\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>prints<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>name: \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>image_url: URL \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>clients<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>name: \u0418\u043c\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>address: \u0410\u0434\u0440\u0435\u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>contact_info: \u041a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>orders<\/strong>\u00a0:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<\/li>\n<li>\n<p>order_date: \u0414\u0430\u0442\u0430 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<\/li>\n<li>\n<p>client_id: \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#171;clients&#187;<\/p>\n<\/li>\n<li>\n<p>price: \u041e\u0431\u0449\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430 \u0435\u0435 \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u043f\u043b\u043e\u0442\u0438\u0442\u044c \u0438\u0434\u0435\u044e \u0432\u00a0\u043a\u043e\u0434\u0435. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>SQLAlchemy<\/em>. \u0421\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>SQLAlchemy<\/em> \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u00a0\u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u00a0\u043d\u0438\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 python. \u041e\u043d\u0430 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u00a0\u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u00a0\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c SQL\u2011\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443\u00a0\u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u0437\u0430\u0447\u0435\u043c \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. \u041d\u043e\u00a0\u0437\u0430\u00a0\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u043c\u044b \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043e\u0439 \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e. \u041a\u00a0\u0442\u043e\u043c\u0443\u00a0\u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b LangChain \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u00a0\u0430\u043b\u0445\u0438\u043c\u0438\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0432\u00a0\u0440\u0430\u0431\u043e\u0442\u0435.<\/p>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b:<\/p>\n<pre><code class=\"python\">from sqlalchemy import Column, Integer, String, ForeignKey, Date, Numeric, Table   from sqlalchemy.orm import relationship   from sqlalchemy.orm import declarative_base      from sqlalchemy import create_engine      Base = declarative_base()         class TShirt(Base):       __tablename__ = 'tshirts'       id = Column(Integer, primary_key=True)       type = Column(String)  # \u0422\u0438\u043f \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \"Type 1\", \"Type 2\" \u0438 \u0442.\u0434.)       color = Column(String)        size = Column(String)       quantity = Column(Integer)  # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438       print_id = Column(Integer, ForeignKey('prints.id'))  # \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"Prints\"       print = relationship(\"Print\")  # \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u043d\u0442\u0430\u043c\u0438       price = Column(Numeric(10, 2))  # \u0426\u0435\u043d\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432          def calculate_tshirt_price(self):           base_price = 500.0           type_multiplier = 1.2           color_multiplier = 1.3           size_multiplier = 1           if self.size in ['XL', 'XXL']:               size_multiplier = 1.5           price = base_price * type_multiplier * color_multiplier * size_multiplier           self.price = round(price, 2)         class Print(Base):       __tablename__ = 'prints'       id = Column(Integer, primary_key=True)       name = Column(String)  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0442\u0430       image_url = Column(String)  # URL \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0442\u0430         class Client(Base):       __tablename__ = 'clients'       id = Column(Integer, primary_key=True)       name = Column(String)  # \u0418\u043c\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430       address = Column(String)  # \u0410\u0434\u0440\u0435\u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430       contact_info = Column(String)  # \u041a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430       orders = relationship(\"Order\", back_populates=\"client\")  # \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435         order_tshirt_table = Table('order_tshirt', Base.metadata,                              Column('order_id', Integer, ForeignKey('orders.id'), primary_key=True),                              Column('tshirt_id', Integer, ForeignKey('tshirts.id'), primary_key=True)                              )         class Order(Base):       __tablename__ = 'orders'       id = Column(Integer, primary_key=True)       order_date = Column(Date)  # \u0414\u0430\u0442\u0430 \u0437\u0430\u043a\u0430\u0437\u0430       client_id = Column(Integer, ForeignKey('clients.id'))  # \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"Clients\"       client = relationship(\"Client\", back_populates=\"orders\")  # \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438       tshirts = relationship(\"TShirt\", secondary=order_tshirt_table)       quantity = Column(Integer)       price = Column(Numeric(10, 2))  # \u041e\u0431\u0449\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0430          def calculate_order_price(self):           total_price = 0.0           self.quantity = len(self.tshirts)           for tshirt in self.tshirts:               total_price += tshirt.price           self.price = round(total_price, 2) * self.quantity         def create_tables(engine):       Base.metadata.create_all(engine)       print('Tables created successfully!')         if __name__ == '__main__':       # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0432\u0438\u0436\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445       engine = create_engine('sqlite:\/\/\/tshirt_store.db')       print('\u0421reate engine')          # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b       create_tables(engine)<\/code><\/pre>\n<h3>\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0430\u0437\u0443<\/h3>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u0441\u0435\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SQLAlchemy:<\/p>\n<pre><code class=\"python\">import random   from random import randint      from create_database import TShirt, Print   from sqlalchemy import create_engine   from sqlalchemy.orm import sessionmaker         def random_color():       colors = ['Red', 'Blue', 'Green', 'Yellow', 'Black', 'White']       return random.choice(colors)         def random_size():       sizes = ['S', 'M', 'L', 'XL', 'XXL']       return random.choice(sizes)         def create_tshirt_samples(session, num_samples):       tshirt_samples = []       print_samples = []       for _ in range(num_samples):           tshirt = TShirt(               type=f'Type {randint(1, 5)}',               color=random_color(),               size=random_size(),               quantity=randint(1, num_samples \/\/ 5),               print_id=0,  # \u0417\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u043d\u0438\u0436\u0435               price=0.0           )           tshirt.calculate_tshirt_price()  # \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u044b \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438           tshirt_samples.append(tshirt)              print = Print(               name=f'Print_{randint(1, num_samples * 2)}',               image_url=f'https:\/\/example.com\/print_{randint(1, 10)}.jpg'           )           print_samples.append(print)          session.add_all(print_samples)       session.flush()  # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 ID \u043f\u0440\u0438\u043d\u0442\u043e\u0432          for i, tshirt in enumerate(tshirt_samples):           tshirt.print_id = print_samples[i].id          session.add_all(tshirt_samples)       session.commit()         if __name__ == '__main__':       # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0432\u0438\u0436\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445       engine = create_engine('sqlite:\/\/\/tshirt_store.db')       print('\u0421reate engine')          Session = sessionmaker(bind=engine)       session = Session()          create_tshirt_samples(session, 50)       print('Shirts successfully added into DB')          session.close()<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u0442, \u0442\u043e \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0441 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d37\/02f\/f5e\/d3702ff5e5586aaee5c3383492c9f953.png\" alt=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438\" title=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438\" width=\"1696\" height=\"820\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d37\/02f\/f5e\/d3702ff5e5586aaee5c3383492c9f953.png\"\/><\/p>\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u044b. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441 \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430.<\/p>\n<pre><code class=\"python\">import random from datetime import datetime, timedelta from random import randint from create_database import Order, Client, TShirt from sqlalchemy.orm import sessionmaker from sqlalchemy import create_engine, func  from math import sin, pi   def create_random_client(n):     # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u043d\u0438, \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438     name = f'Client_{randint(1, n)}'     address = f'Address_{randint(1, n)}'     contact_info = f'Contact_{randint(1, n)}'     return Client(name=name, address=address, contact_info=contact_info)   def get_random_client(session, r_id=1000, client_proba=0.5):     # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445     client = session.query(Client).order_by(func.random()).first()     if client is None or client_proba &lt; 0.5:         # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0435\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u0443\u0441\u0442\u0430 \u0438\u043b\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 0.5         client = create_random_client(r_id)         session.add(client)         session.commit()     return client   def get_random_tshirts(session, num_tshirts):     # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445     tshirts = session.query(TShirt).order_by(func.random()).limit(num_tshirts).all()     return tshirts   def create_orders(         session,         start_date,         end_date,         order_function, ):     current_date = start_date     while current_date &lt;= end_date:         # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0430\u0442\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 order_function         num_orders = order_function(current_date)         for _ in range(num_orders):             # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430             client = get_random_client(session, client_proba=random.random())             # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Order \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0434\u0430\u0442\u043e\u0439 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c             order = Order(order_date=current_date, client=client)             order.client = client             # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a             tshirts = get_random_tshirts(session, randint(1, num_orders))             order.tshirts = tshirts              # \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0439 \u0446\u0435\u043d\u044b \u0437\u0430\u043a\u0430\u0437\u0430             order.calculate_order_price()              session.add(order)          current_date += timedelta(days=1)      session.commit()   def order_function(date):       day_of_year = date.timetuple().tm_yday       amplitude = 10  # \u0410\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432       period = 7  # \u041f\u0435\u0440\u0438\u043e\u0434 \u0441\u0438\u043d\u0443\u0441\u043e\u0438\u0434\u044b \u0432 \u0434\u043d\u044f\u0445          angle = 2 * pi * (day_of_year % period) \/ period       num_orders = amplitude * (sin(angle) + 1)          return int(num_orders * day_of_year \/ 365)   if __name__ == '__main__':     # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0432\u0438\u0436\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445     engine = create_engine('sqlite:\/\/\/tshirt_store.db')     print('\u0421reate engine')      Session = sessionmaker(bind=engine)     session = Session()      start_date = datetime(2023, 5, 1)     end_date = datetime(2023, 6, 30)      create_orders(session, start_date, end_date, order_function)    print('Orders successfully added into DB')    session.close()<\/code><\/pre>\n<p>\u0414\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u043d\u0430 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dd9\/740\/790\/dd97407903adf4886853648565555440.png\" alt=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438\" title=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438\" width=\"1870\" height=\"686\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dd9\/740\/790\/dd97407903adf4886853648565555440.png\"\/><\/p>\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443\u00a0\u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0433\u0435\u043d\u0442\u0430.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u0433\u0435\u043d\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f\u00a0\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0434 \u044f \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u00a0\u0441\u043d\u0438\u043f\u043f\u0435\u0442\u0430\u0445, \u0430\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u00a0\u0432\u0438\u0434\u0435 \u0441\u043a\u0440\u0438\u043d\u043e\u0432 \u044f\u0447\u0435\u0435\u043a jupyter notebook. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u0442\u0440\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430, \u0442\u0440\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\n<p>\u042f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p>\u0422\u0435\u043b\u043e \u0430\u0433\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">import os  from langchain.sql_database import SQLDatabase from langchain.chains import SQLDatabaseChain  from langchain.chat_models import ChatOpenAI from langchain.agents import Tool from langchain.agents import initialize_agent  # \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c llm = ChatOpenAI( openai_api_key=open_ai_api_key, model_name='gpt-3.5-turbo', temperature=0 ) # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 engine = create_engine('sqlite:\/\/\/tshirt_store.db')  # \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0438\u0436\u043e\u043a \u0432 langchain db = SQLDatabase(engine)  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 sql_chain = SQLDatabaseChain( llm=llm, database=db, verbose=True )  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 db_tool = Tool(     name='tshirt store db',     func=sql_chain.run,     description='Use for extaract data from database'  )  # \u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430(\u043f\u043e\u043a\u0430 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438) db_agent = initialize_agent(     agent='zero-shot-react-description',      tools=[db_tool],      llm=llm,     verbose=True,     max_iterations=5, )<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0448\u0435\u043c\u0443 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e45\/526\/4fe\/e455264feb79bcd8fb15944354e31b99.png\" alt=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432\" title=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432\" width=\"2320\" height=\"482\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e45\/526\/4fe\/e455264feb79bcd8fb15944354e31b99.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/78c\/189\/a72\/78c189a72d66f0ddd6b2fb7da7fa5914.png\" alt=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438\" title=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438\" width=\"2320\" height=\"360\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/78c\/189\/a72\/78c189a72d66f0ddd6b2fb7da7fa5914.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u0432\u0435\u0440\u043d\u0430. \u0410\u0433\u0435\u043d\u0442 \u0434\u0430\u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u043b, \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0440\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0431\u0435\u0437 \u0430\u0433\u0435\u043d\u0442\u0430, \u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443\u00a0<code>sql_chain<\/code>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2de\/bfa\/f50\/2debfaf50ab698746629128c5f9fd3e5.png\" alt=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443\" title=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443\" width=\"2322\" height=\"276\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2de\/bfa\/f50\/2debfaf50ab698746629128c5f9fd3e5.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u043e \u0432\u043e\u0442 \u0443\u0436\u0435 \u0441\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f63\/863\/016\/f638630169ab4f42260cad4656df25ff.png\" alt=\"\" title=\"\" width=\"2324\" height=\"496\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f63\/863\/016\/f638630169ab4f42260cad4656df25ff.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u043c\u043f\u0442\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ab4\/5ed\/b3d\/ab45edb3daa5ffe80cfe7326e61c05d8.png\" alt=\"\u041f\u0440\u043e\u043c\u043f\u0442 \u0430\u0433\u0435\u043d\u0442\u0430\" title=\"\u041f\u0440\u043e\u043c\u043f\u0442 \u0430\u0433\u0435\u043d\u0442\u0430\" width=\"2324\" height=\"482\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab4\/5ed\/b3d\/ab45edb3daa5ffe80cfe7326e61c05d8.png\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u043c\u043f\u0442 \u0430\u0433\u0435\u043d\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u043c\u043f\u0442 \u0434\u043b\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6f7\/bb0\/e3e\/6f7bb0e3e16acb122d31dfc0b2e1bd82.png\" alt=\"\u041f\u0440\u043e\u043c\u043f\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0438\" title=\"\u041f\u0440\u043e\u043c\u043f\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0438\" width=\"2320\" height=\"446\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6f7\/bb0\/e3e\/6f7bb0e3e16acb122d31dfc0b2e1bd82.png\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u043c\u043f\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043d\u0430\u043c \u043e\u00a0\u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u043c\u043f\u0442\u043e\u0432 \u0434\u043b\u044f\u00a0\u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0433\u0440\u0430\u043c\u043e\u0442\u0443 \u043f\u0440\u043e\u043c\u043f\u0442\u0438\u043d\u0433\u0430, \u0442\u043e \u042d\u043d\u0434\u0440\u044e \u042b\u043d \u0437\u0430\u043f\u0438\u043b\u0438\u043b \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 <a href=\"https:\/\/www.deeplearning.ai\/short-courses\/chatgpt-prompt-engineering-for-developers\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0443\u0440\u0441<\/a>, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0430\u043a\u0446\u0435\u043d\u0442 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0430\u0445, \u043d\u043e\u00a0\u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043e\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d.<\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u00a0\u0430\u0433\u0435\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e\u00a0\u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/11b\/6f7\/e73\/11b6f7e7376087c5d1c30e53b1ccc6de.png\" alt=\"\u041f\u0430\u0434\u0435\u043d\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430\" title=\"\u041f\u0430\u0434\u0435\u043d\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430\" width=\"2322\" height=\"660\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/11b\/6f7\/e73\/11b6f7e7376087c5d1c30e53b1ccc6de.png\"\/><\/p>\n<div><figcaption>\u041f\u0430\u0434\u0435\u043d\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c? \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u043f\u0442. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c &#8212; \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u0412 LangChain \u0435\u0441\u0442\u044c\u00a0<code>SQLDatabaseToolkit<\/code>, \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u043e\u0433\u043e \u043d\u043e\u0436\u0430 \u0441\u0440\u0430\u0437\u0443 4 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<ul>\n<li>\n<p>QuerySQLDataBaseTool<\/p>\n<\/li>\n<li>\n<p>InfoSQLDatabaseTool<\/p>\n<\/li>\n<li>\n<p>ListSQLDatabaseTool<\/p>\n<\/li>\n<li>\n<p>QueryCheckerTool<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0441\u043c\u043e\u0433\u0443\u0442 \u043b\u0438 \u043e\u043d\u0438 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0447\u044c. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"python\">from langchain.agents import create_sql_agent from langchain.agents.agent_toolkits import SQLDatabaseToolkit  toolkit = SQLDatabaseToolkit(db=db, llm=llm)  db_agent_toolkit = create_sql_agent(     llm=llm,     toolkit=toolkit,     verbose=True )<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u0442\u043e\u0442 \u0436\u0435 \u0432\u043e\u043f\u0440\u043e\u0441:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/efe\/57a\/74d\/efe57a74d69099eb89d360974d5d124e.png\" alt=\"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c SQLDatabaseToolkit\" title=\"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c SQLDatabaseToolkit\" width=\"2464\" height=\"1074\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/efe\/57a\/74d\/efe57a74d69099eb89d360974d5d124e.png\"\/><\/p>\n<div><figcaption>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c SQLDatabaseToolkit<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u043b\u0438\u0446\u043e: \u0432\u043e\u2011\u043f\u0435\u0440\u0432\u044b\u0445, \u0430\u0433\u0435\u043d\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b; \u0432\u043e\u2011\u0432\u0442\u043e\u0440\u044b\u0445, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0433\u0435\u043d\u0442\u0443 \u0443\u043f\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u00a0\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0435.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437\u00a0\u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0447\u0435\u043c\u0443\u00a0\u0431\u044b \u043d\u0430\u043c \u043d\u0435\u00a0\u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445? \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u043e\u00a0\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u00a0\u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u00a0\u0432\u0438\u0434\u0435 <code>PythonREPLTool<\/code>. \u041d\u0443 \u0447\u0442\u043e\u00a0\u0436, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438 \u044d\u0442\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u00a0\u043d\u0430\u0448 \u0430\u0440\u0441\u0435\u043d\u0430\u043b.<\/p>\n<pre><code class=\"python\">from langchain.agents.agent_toolkits import create_python_agent from langchain.tools.python.tool import PythonREPLTool  agent_model = create_python_agent(     llm=llm,     tool=PythonREPLTool(),     verbose=True )<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u044b \u043d\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/891\/bc2\/cdd\/891bc2cdd489f2754c21e2e9e1219c75.png\" alt=\"\u0410\u0433\u0435\u043d\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ml \u043c\u043e\u0434\u0435\u043b\u044c\" title=\"\u0410\u0433\u0435\u043d\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ml \u043c\u043e\u0434\u0435\u043b\u044c\" width=\"2466\" height=\"1134\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/891\/bc2\/cdd\/891bc2cdd489f2754c21e2e9e1219c75.png\"\/><\/p>\n<div><figcaption>\u0410\u0433\u0435\u043d\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ml \u043c\u043e\u0434\u0435\u043b\u044c<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u043a\u043e\u0436\u0430\u043d\u044b\u0435, \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u044b? \u0412\u0440\u0435\u043c\u044f\u00a0<s>\u044d\u043b\u044c\u0444\u043e\u0432<\/s>\u00a0\u043b\u044e\u0434\u0435\u0439 \u043f\u0440\u043e\u0448\u043b\u043e, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0430\u0433\u0435\u043d\u0442\u043e\u0432. \u041d\u0430 \u044d\u0442\u043e \u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0439 \u043d\u043e\u0442\u0435 \u0441 \u0430\u0433\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c. \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0433\u0435\u043d\u0442\u0430\u043c\u0438. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p>\u041f\u0438\u0448\u0443 \u043f\u0440\u043e AI \u0438 NLP \u0432\u00a0<a href=\"https:\/\/bit.ly\/3Mg0BMy\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c<\/a>.<\/p>\n<\/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\/734146\/\"> https:\/\/habr.com\/ru\/articles\/734146\/<\/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>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u00a0\u0432\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u00a0\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 LangChain. \u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/733262\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0432\u00a0\u0434\u0438\u0430\u043b\u043e\u0433\u0438 \u0441\u00a0LLM, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f \u043a\u00a0\u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Google. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u0430\u00a0\u0425\u0430\u0431\u0440\u0435 \u0438 \u043e\u043d\u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 <s>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0446\u0435\u043d\u0437\u0443\u0440\u044b<\/s> \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e. \u041d\u043e\u00a0\u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e\u00a0\u0440\u0443\u043a\u043e\u043f\u0438\u0441\u0438 \u043d\u0435\u00a0\u0433\u043e\u0440\u044f\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u00a0\u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/bit.ly\/3phBobh\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>\u041a\u0430\u043a\u00a0\u0443\u0436\u0435 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0432\u00a0\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u0430\u0433\u0435\u043d\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 LangChain. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a\u00a0\u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u0447\u0442\u043e\u00a0\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412\u00a0\u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a\u00a0\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f\u00a0\u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<h3>C\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u043a\u00a0\u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e\u00a0\u043d\u0430\u0448 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u0431\u043e\u0442\u0430\u00a0\u2014 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0441\u00a0\u043f\u0440\u0438\u043d\u0442\u0430\u043c\u0438. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0433\u043e \u0431\u0430\u0437\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>tshirts<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>type: \u0422\u0438\u043f \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, &#171;Type 1&#187;, &#171;Type 2&#187; \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>color: \u0426\u0432\u0435\u0442 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>size: \u0420\u0430\u0437\u043c\u0435\u0440 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>quantity: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>print_id: \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#171;prints&#187;<\/p>\n<\/li>\n<li>\n<p>price: \u0426\u0435\u043d\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>prints<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>name: \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>image_url: URL \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>clients<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>name: \u0418\u043c\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>address: \u0410\u0434\u0440\u0435\u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>contact_info: \u041a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u00a0<strong>orders<\/strong>\u00a0:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>id: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<\/li>\n<li>\n<p>order_date: \u0414\u0430\u0442\u0430 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<\/li>\n<li>\n<p>client_id: \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#171;clients&#187;<\/p>\n<\/li>\n<li>\n<p>price: \u041e\u0431\u0449\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430 \u0435\u0435 \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u043f\u043b\u043e\u0442\u0438\u0442\u044c \u0438\u0434\u0435\u044e \u0432\u00a0\u043a\u043e\u0434\u0435. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>SQLAlchemy<\/em>. \u0421\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>SQLAlchemy<\/em> \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u00a0\u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u00a0\u043d\u0438\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 python. \u041e\u043d\u0430 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u00a0\u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u00a0\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c SQL\u2011\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443\u00a0\u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u0437\u0430\u0447\u0435\u043c \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. \u041d\u043e\u00a0\u0437\u0430\u00a0\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u043c\u044b \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043e\u0439 \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e. \u041a\u00a0\u0442\u043e\u043c\u0443\u00a0\u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b LangChain \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u00a0\u0430\u043b\u0445\u0438\u043c\u0438\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0432\u00a0\u0440\u0430\u0431\u043e\u0442\u0435.<\/p>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b:<\/p>\n<pre><code class=\"python\">from sqlalchemy import Column, Integer, String, ForeignKey, Date, Numeric, Table   from sqlalchemy.orm import relationship   from sqlalchemy.orm import declarative_base      from sqlalchemy import create_engine      Base = declarative_base()         class TShirt(Base):       __tablename__ = 'tshirts'       id = Column(Integer, primary_key=True)       type = Column(String)  # \u0422\u0438\u043f \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \"Type 1\", \"Type 2\" \u0438 \u0442.\u0434.)       color = Column(String)        size = Column(String)       quantity = Column(Integer)  # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438       print_id = Column(Integer, ForeignKey('prints.id'))  # \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"Prints\"       print = relationship(\"Print\")  # \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u043d\u0442\u0430\u043c\u0438       price = Column(Numeric(10, 2))  # \u0426\u0435\u043d\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432          def calculate_tshirt_price(self):           base_price = 500.0           type_multiplier = 1.2           color_multiplier = 1.3           size_multiplier = 1           if self.size in ['XL', 'XXL']:               size_multiplier = 1.5           price = base_price * type_multiplier * color_multiplier * size_multiplier           self.price = round(price, 2)         class Print(Base):       __tablename__ = 'prints'       id = Column(Integer, primary_key=True)       name = Column(String)  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0442\u0430       image_url = Column(String)  # URL \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0442\u0430         class Client(Base):       __tablename__ = 'clients'       id = Column(Integer, primary_key=True)       name = Column(String)  # \u0418\u043c\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430       address = Column(String)  # \u0410\u0434\u0440\u0435\u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430       contact_info = Column(String)  # \u041a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430       orders = relationship(\"Order\", back_populates=\"client\")  # \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435         order_tshirt_table = Table('order_tshirt', Base.metadata,                              Column('order_id', Integer, ForeignKey('orders.id'), primary_key=True),                              Column('tshirt_id', Integer, ForeignKey('tshirts.id'), primary_key=True)                              )         class Order(Base):       __tablename__ = 'orders'       id = Column(Integer, primary_key=True)       order_date = Column(Date)  # \u0414\u0430\u0442\u0430 \u0437\u0430\u043a\u0430\u0437\u0430       client_id = Column(Integer, ForeignKey('clients.id'))  # \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"Clients\"       client = relationship(\"Client\", back_populates=\"orders\")  # \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438       tshirts = relationship(\"TShirt\", secondary=order_tshirt_table)       quantity = Column(Integer)       price = Column(Numeric(10, 2))  # \u041e\u0431\u0449\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0430          def calculate_order_price(self):           total_price = 0.0           self.quantity = len(self.tshirts)           for tshirt in self.tshirts:               total_price += tshirt.price           self.price = round(total_price, 2) * self.quantity         def create_tables(engine):       Base.metadata.create_all(engine)       print('Tables created successfully!')         if __name__ == '__main__':       # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0432\u0438\u0436\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445       engine = create_engine('sqlite:\/\/\/tshirt_store.db')       print('\u0421reate engine')          # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b       create_tables(engine)<\/code><\/pre>\n<h3>\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0430\u0437\u0443<\/h3>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u0441\u0435\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SQLAlchemy:<\/p>\n<pre><code class=\"python\">import random   from random import randint      from create_database import TShirt, Print   from sqlalchemy import create_engine   from sqlalchemy.orm import sessionmaker         def random_color():       colors = ['Red', 'Blue', 'Green', 'Yellow', 'Black', 'White']       return random.choice(colors)         def random_size():       sizes = ['S', 'M', 'L', 'XL', 'XXL']       return random.choice(sizes)         def create_tshirt_samples(session, num_samples):       tshirt_samples = []       print_samples = []       for _ in range(num_samples):           tshirt = TShirt(               type=f'Type {randint(1, 5)}',               color=random_color(),               size=random_size(),               quantity=randint(1, num_samples \/\/ 5),               print_id=0,  # \u0417\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u043d\u0438\u0436\u0435               price=0.0           )           tshirt.calculate_tshirt_price()  # \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u044b \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0438           tshirt_samples.append(tshirt)              print = Print(               name=f'Print_{randint(1, num_samples * 2)}',               image_url=f'https:\/\/example.com\/print_{randint(1, 10)}.jpg'           )           print_samples.append(print)          session.add_all(print_samples)       session.flush()  # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 ID \u043f\u0440\u0438\u043d\u0442\u043e\u0432          for i, tshirt in enumerate(tshirt_samples):           tshirt.print_id = print_samples[i].id          session.add_all(tshirt_samples)       session.commit()         if __name__ == '__main__':       # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0432\u0438\u0436\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445       engine = create_engine('sqlite:\/\/\/tshirt_store.db')       print('\u0421reate engine')          Session = sessionmaker(bind=engine)       session = Session()          create_tshirt_samples(session, 50)       print('Shirts successfully added into DB')          session.close()<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u0442, \u0442\u043e \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0441 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0444\u0443\u0442\u0431\u043e\u043b\u043a\u0430\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u044b. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441 \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430.<\/p>\n<pre><code class=\"python\">import random from datetime import datetime, timedelta from random import randint from create_database import Order, Client, TShirt from sqlalchemy.orm import sessionmaker from sqlalchemy import create_engine, func  from math import sin, pi   def create_random_client(n):     # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u043d\u0438, \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438     name = f'Client_{randint(1, n)}'     address = f'Address_{randint(1, n)}'     contact_info = f'Contact_{randint(1, n)}'     return Client(name=name, address=address, contact_info=contact_info)   def get_random_client(session, r_id=1000, client_proba=0.5):     # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445     client = session.query(Client).order_by(func.random()).first()     if client is None or client_proba &lt; 0.5:         # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0435\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u0443\u0441\u0442\u0430 \u0438\u043b\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 0.5         client = create_random_client(r_id)         session.add(client)         session.commit()     return client   def get_random_tshirts(session, num_tshirts):     # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445     tshirts = session.query(TShirt).order_by(func.random()).limit(num_tshirts).all()     return tshirts   def create_orders(         session,         start_date,         end_date,         order_function, ):     current_date = start_date     while current_date &lt;= end_date:         # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0430\u0442\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 order_function         num_orders = order_function(current_date)         for _ in range(num_orders):             # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430             client = get_random_client(session, client_proba=random.random())             # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Order \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0434\u0430\u0442\u043e\u0439 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c             order = Order(order_date=current_date, client=client)             order.client = client             # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0444\u0443\u0442\u0431\u043e\u043b\u043e\u043a             tshirts = get_random_tshirts(session, randint(1, num_orders))             order.tshirts = tshirts              #<\/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-393693","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393693","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=393693"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393693\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=393693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=393693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}