{"id":382742,"date":"2024-06-29T04:28:13","date_gmt":"2024-06-29T04:28:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=382742"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=382742","title":{"rendered":"<span>\u041a\u0430\u043a \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 ChatGPT \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 Telegram<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/wu\/_e\/_d\/wu_e_d5vi5xzb9bfddgincwdzpc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/wu\/_e\/_d\/wu_e_d5vi5xzb9bfddgincwdzpc.png\"\/><\/div>\n<p>  \u041f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u043d\u0430\u0437\u0430\u0434 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441 ChatGPT \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c VPN \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenAI, \u0430 \u043f\u0440\u043e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u044b\u0442\u044c \u0432\u043e\u0432\u0441\u0435. <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0434\u0435\u043b\u044e\u0441\u044c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c ChatGPT Telegram-\u0431\u043e\u0442\u0430 \u043d\u0430 NodeJS \u0438 \u0437\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 <a href=\"https:\/\/selectel.ru\/services\/cloud\/sharedline\/?utm_source=habr.com&amp;utm_medium=referral&amp;utm_campaign=cloud_article_tgbot_030523_content\">\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440<\/a>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c!<br \/>  <a name=\"habracut\"><\/a><br \/>  <font color=\"#EB4247\"><\/p>\n<h2>\u041a\u0430\u0440\u043a\u0430\u0441 Telegram-\u0431\u043e\u0442\u0430<\/h2>\n<p><\/font>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<pre><code class=\"plaintext\">npm init -y  npm i -D nodemon cross-env <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b package.json. \u0410 \u0432\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u0434\u0442\u044f\u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f NodeJS \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 ES-\u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 package.json \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430. <\/p>\n<pre><code class=\"plaintext\">\"type\": \"module\", \"scripts\": {   \"start\": \"cross-env NODE_ENV=production node .\/src\/main.js\",   \"dev\": \"cross-env NODE_ENV=development nodemon .\/src\/main.js\" }, <\/code><\/pre>\n<p>  <i>package.json<\/i><\/p>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Telegraf \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0431\u043e\u0442\u0430<\/h3>\n<p>  \u0420\u0430\u0431\u043e\u0447\u0435\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u2014 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u0431\u043e\u0442\u0430. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>.\/src\/main.js<\/code>, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"https:\/\/telegraf.js.org\">Telegraf<\/a> \u0438 config.<\/p>\n<pre><code class=\"plaintext\">npm i config telegraf <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0433\u043e \u0431\u043e\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Telegraf \u0438 config, \u0430 \u043f\u043e\u0441\u043b\u0435 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Telegram. <\/p>\n<pre><code class=\"plaintext\">import { Telegraf } from 'telegraf' import config from 'config' const bot = new Telegraf(config.get('TELEGRAM_BOT')) bot.launch() process.once('SIGINT', () => bot.stop('SIGINT')) process.once('SIGTERM', () => bot.stop('SIGTERM')) <\/code><\/pre>\n<p>  <i>.\/src\/main.js <br \/>  \u041e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 config.get() \u043d\u0438\u0436\u0435. <\/i> <\/p>\n<p>  API-\u043a\u043b\u044e\u0447 \u0434\u043b\u044f Telegram \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443 <a href=\"https:\/\/t.me\/BotFather\">@BotFather<\/a>, \u0432\u0432\u0435\u0434\u044f \/newbot \u2014 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/cu\/xn\/nq\/cuxnnqjrmyalpstzx--lkngk0aw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/cu\/xn\/nq\/cuxnnqjrmyalpstzx--lkngk0aw.png\"\/><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u00ab\u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0438\u00bb \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f Telegram-\u0431\u043e\u0442\u0430. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u2014 <code>.\/config\/default.json<\/code> \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 <code>.\/config\/default.json<\/code> \u2014 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0430. <\/p>\n<pre><code class=\"plaintext\">{ \"TELEGRAM_TOKEN\": \"token dev\" } <\/code><\/pre>\n<p>  <i>config\/default.json<\/i><\/p>\n<pre><code class=\"plaintext\">{ \"TELEGRAM_TOKEN\": \"token prod\" } <\/code><\/pre>\n<p>  <i>config\/production.json<\/i><\/p>\n<p>  \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0435\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 API-\u0442\u043e\u043a\u0435\u043d \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043e\u0434\u043d\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u043b\u044c\u043a\u043e <code>config\/default.json<\/code>.<\/p>\n<p>  <font color=\"#EB4247\"><\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430<\/h2>\n<p><\/font><br \/>  \u0411\u043e\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b: \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0430 \u043d\u0438\u0445 \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ogg, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 mp3.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0442\u0435\u043a\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441\u044b OpenAI. \u041e\u043d\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0444\u0430\u0439\u043b\u044b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 ogg. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 <a href=\"https:\/\/platform.openai.com\/docs\/guides\/speech-to-text\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435<\/a>. <\/p>\n<h3>\u0424\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 <\/h3>\n<p>  \u041e\u0442\u0431\u0438\u0440\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430 Telegraph \u2014 message. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 voice \u2014 \u0438 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u00ab\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u00bb \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. <\/p>\n<pre><code class=\"plaintext\">import { Telegraf } from 'telegraf' import { message } from 'telegraf\/filters' import { code } from 'telegraf\/format' import config from 'config' import { ogg } from '.\/ogg.js'  const bot = new Telegraf(config.get('TELEGRAM_BOT'))  bot.on(message('voice'), async (ctx) => {   try {     await ctx.reply(code('\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u044f\u043b. \u0416\u0434\u0443 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430...'))     const link = await ctx.telegram.getFileLink(ctx.message.voice.file_id)     const userId = String(ctx.message.from.id)     const oggPath = await ogg.create(link.href, userId)     const mp3Path = await ogg.toMp3(oggPath, userId)   } catch (e) { console.log(`Error while voice message`, e.message)   } }) <\/code><\/pre>\n<p>  <i>.\/src\/main.js<\/i><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 <code>getFileLink<\/code> \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440. <\/p>\n<h3>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ogg<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 <code>getFileLink<\/code> \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, .\/src\/ogg.js \u2014 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445. <\/p>\n<pre><code class=\"plaintext\">npm i axios fluent-ffmpeg @ffmpeg-installer\/ffmpeg mkdir voices touch voices\/keep <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432 .\/src\/ogg.js \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>OggConverter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c ogg-\u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. <\/p>\n<pre><code class=\"plaintext\">import ffmpeg from 'fluent-ffmpeg' import installer from '@ffmpeg-installer\/ffmpeg' class OggConverter {   constructor() {     ffmpeg.setFfmpegPath(installer.path)   }   toMp3(input, output) {        }   async create(url, filename) {    } } export const ogg = new OggConverter() <\/code><\/pre>\n<p>  <i>.\/src\/ogg.js<\/i><\/p>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>create<\/code> \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c ogg \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 Telegram, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0432 \u0444\u0430\u0439\u043b \u0447\u0435\u0440\u0435\u0437 <code>stream<\/code>. \u0413\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0439 ogg-\u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 <code>.\/voices\/${user id}.ogg<\/code>.<\/p>\n<pre><code class=\"plaintext\">import axios from 'axios' import { createWriteStream } from 'fs' import { dirname, resolve } from 'path' import { fileURLToPath } from 'url' const __dirname = dirname(fileURLToPath(import.meta.url)) \/\/ ==== async create(url, filename) {   try {     const oggPath = resolve(__dirname, '..\/voices', `${filename}.ogg`)     const response = await axios({       method: 'get',       url,       responseType: 'stream',     })     return new Promise((resolve) => {       const stream = createWriteStream(oggPath)       response.data.pipe(stream)       stream.on('finish', () => resolve(oggPath))     })   } catch (e) {     console.log('Error while creating ogg', e.message)   } } <\/code><\/pre>\n<p>  <i>OggConverter.create()<\/i><\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c ogg \u0432 mp3 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>toMp3<\/code>. \u0412\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <code>.\/voices\/${user id}.mp3<\/code><\/p>\n<pre><code class=\"plaintext\">toMp3(input, output) {   try {     const outputPath = resolve(dirname(input), `${output}.mp3`)     return new Promise((resolve, reject) => {       ffmpeg(input)         .inputOption('-t 30')         .output(outputPath)         .on('end', () => resolve(outputPath))         .on('error', (err) => reject(err.message))         .run()     })   } catch (e) {     console.log('Error while creating mp3', e.message)   } } <\/code><\/pre>\n<p>  <i>OggConverter.toMp3<\/i><\/p>\n<p>  \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432 mp3 \u0444\u0430\u0439\u043b\u044b ogg \u0443\u0434\u0430\u043b\u044f\u043b\u0438\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443. <\/p>\n<pre><code class=\"plaintext\">import { unlink } from 'fs\/promises' export async function removeFile(path) {   try {     await unlink(path)   } catch (e) {     console.log('Error while removing file', e.message)   } } <\/code><\/pre>\n<p>  <i>.\/src\/utils.js<\/i><\/p>\n<h3>\u0413\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0439 \u0447\u0430\u0442 \u0441 ChatGPT<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 mp3 \u0432 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ChatGPT \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c API ChatGPT: \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, <a href=\"https:\/\/platform.openai.com\/account\/api-keys\">\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <\/a>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447. <\/p>\n<pre><code class=\"plaintext\">npm i openai <\/code><\/pre>\n<p>  <i>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 openai.<\/i><\/p>\n<pre><code class=\"plaintext\">https:\/\/platform.openai.com\/account\/api-keys {   \"TELEGRAM_TOKEN\": \"bot token\",   \"OPENAI_KEY\": \"open ai key\" } <\/code><\/pre>\n<p>  <i>.\/config\/default.json<\/i><\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API OpenAI \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>.\/src\/openai.js<\/code> \u0438 \u043e\u043f\u0438\u0448\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0412 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u044b OpenAI, \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a API. <\/p>\n<pre><code class=\"plaintext\">import { Configuration, OpenAIApi } from 'openai' import config from 'config' import { createReadStream } from 'fs' class OpenAI {   roles = {     ASSISTANT: 'assistant',     USER: 'user',     SYSTEM: 'system',   }   constructor(apiKey) {     const configuration = new Configuration({       apiKey,     })     this.openai = new OpenAIApi(configuration)   }   async chat(messages) {        }   async transcription(filepath) {    } } export const openai = new OpenAI(config.get('OPENAI_KEY')) <\/code><\/pre>\n<p>  <i>.\/src\/openai.js<\/i><\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c <code>roles<\/code> \u2014 \u0444\u043e\u0440\u043c\u0430\u0442 \u0440\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 openai. <code>assistant<\/code> \u2014 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 gpt-\u0447\u0430\u0442\u0430; <code>user<\/code> \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f; <code>system<\/code> \u2014 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0447\u0430\u0442\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00abChatGPT, \u0432\u0435\u0434\u0438 \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0441 \u043c\u043d\u043e\u0433\u043e\u043b\u0435\u0442\u043d\u0438\u043c \u0441\u0442\u0430\u0436\u0435\u043c\u00bb).<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>transcription<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 mp3 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0435\u043b\u0438 whisper-1. \u041f\u0440\u0438\u0442\u043e\u043c \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a. <\/p>\n<pre><code class=\"plaintext\">async transcription(filepath) {   try {     const response = await this.openai.createTranscription(       createReadStream(filepath),       'whisper-1'     )     return response.data.text   } catch (e) {     console.log('Error while transcription', e.message)   } } <\/code><\/pre>\n<p>  <i>OpenAI.transcription()<\/i><\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>chat<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 ChatGPT \u043d\u0430 \u0431\u0430\u0437\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 gpt-3.5-turbo. \u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u044f\u0432\u043a\u0435. <\/p>\n<pre><code class=\"plaintext\">async chat(messages) {   try {     const response = await this.openai.createChatCompletion({       model: 'gpt-3.5-turbo',       messages,     })     return response.data.choices[0].message   } catch (e) {     console.log('Error while gpt chat', e.message)   } } <\/code><\/pre>\n<p>  <i>OpenAI.chat()<\/i><\/p>\n<p>  \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>chat<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 messages \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438, \u0440\u043e\u043b\u044f\u043c\u0438 \u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439. \u0410 \u043f\u043e\u0441\u043b\u0435 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 <code>response<\/code>, \u043e\u0442\u0432\u0435\u0442 ChatGPT. <\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>OpenAI.transcription<\/code> \u0438 <code>OpenAI.chat<\/code> \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 .\/src\/main.js. <\/p>\n<pre><code class=\"plaintext\">import { openai } from '.\/openai.js' import { removeFile } from '.\/utils.js' \/\/ ===== bot.on(message('voice'), async (ctx) => {   try {     await ctx.reply(code('\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u044f\u043b. \u0416\u0434\u0443 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430...'))     const link = await ctx.telegram.getFileLink(ctx.message.voice.file_id)     const userId = String(ctx.message.from.id)     const oggPath = await ogg.create(link.href, userId)     const mp3Path = await ogg.toMp3(oggPath, userId)     removeFile(oggPath)     const text = await openai.transcription(mp3Path)     await ctx.reply(code(`\u0412\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441: ${text}`)) const messages = [{role: openai.roles.USER, content: text}]     const response = await openai.chat(messages)     await ctx.reply(response.content)   } catch (e) {     console.error(`Error while proccessing voice message`, e.message)   } }) <\/code><\/pre>\n<p>  <i>src\/main.js<\/i><\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e \u2014 \u0431\u043e\u0442 \u00ab\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u00bb \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0443\u043c\u0435\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u043d\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u043c. \u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435: \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u043e\u0442 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043d\u0435 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0434\u0440\u0443\u0433, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e, \u0447\u0442\u043e \u0432\u044b \u0435\u043c\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c. <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/hf\/h0\/ag\/hfh0agfh_ibmz0vyyjxkyrnpkcy.png\" data-src=\"https:\/\/habrastorage.org\/webt\/hf\/h0\/ag\/hfh0agfh_ibmz0vyyjxkyrnpkcy.png\"\/><\/div>\n<p>  <i>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 OpenAI.chat(). \u0417\u0430\u043f\u0438\u0441\u044c \u0433\u043e\u043b\u043e\u0441\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e <a href=\"https:\/\/youtu.be\/-6ufFPvp6CY?t=3534\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/i><\/p>\n<h3>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0438<\/h3>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043a\u043e\u0434\u0443. <\/p>\n<pre><code class=\"plaintext\">\/\/ \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 Telegraf \u043f\u0430\u043a\u0435\u0442 session import { Telegraf, session } from 'telegraf' import { initCommand, processTextToChat, INITIAL_SESSION } from '.\/logic.js' \/\/ ====== const bot = new Telegraf(config.get('TELEGRAM_TOKEN'))  \/\/ \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0431\u043e\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b session bot.use(session())   \/\/ \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b new \u0438 start \u0431\u043e\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0431\u0435\u0441\u0435\u0434\u0443, \/\/ \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 bot.command('new', initCommand) bot.command('start', initCommand)  bot.on(message('voice'), async (ctx) => {    \/\/ \u0435\u0441\u043b\u0438 \u0441\u0435\u0441\u0441\u0438\u044f \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0430\u0441\u044c, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e   ctx.session ??= INITIAL_SESSION   try {     await ctx.reply(code('\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u044f\u043b. \u0416\u0434\u0443 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430...'))     const link = await ctx.telegram.getFileLink(ctx.message.voice.file_id)     const userId = String(ctx.message.from.id)     const oggPath = await ogg.create(link.href, userId)     const mp3Path = await ogg.toMp3(oggPath, userId)     removeFile(oggPath)     const text = await openai.transcription(mp3Path)     await ctx.reply(code(`\u0412\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441: ${text}`))     await processTextToChat(ctx, text)   } catch (e) {     console.log(`Error while voice message`, e.message)   } }) <\/code><\/pre>\n<p>  <i>.\/src\/main.js<\/i><\/p>\n<pre><code class=\"plaintext\">import { openai } from '.\/openai.js' export const INITIAL_SESSION = {   messages: [], } export async function initCommand(ctx) {   ctx.session = INITIAL_SESSION   await ctx.reply('\u0416\u0434\u0443 \u0432\u0430\u0448\u0435\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f') } export async function processTextToChat(ctx, content) {   try {     \/\/ \u043f\u0443\u0448\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0435\u0441\u0441\u0438\u044e (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442)     ctx.session.messages.push({ role: openai.roles.USER, content })     \/\/ \u043f\u0443\u0448\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0431\u043e\u0442\u0430 \u0432 \u0441\u0435\u0441\u0441\u0438\u044e (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442)     const response = await openai.chat(ctx.session.messages)     ctx.session.messages.push({       role: openai.roles.ASSISTANT,       content: response.content,     })     await ctx.reply(response.content)   } catch (e) {     console.log('Error while proccesing text to gpt', e.message)   } } <\/code><\/pre>\n<p>  <i>.\/src\/openai.js<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/ik\/vg\/u7\/ikvgu7o_nf0spdpdqowd4se8f04.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/ik\/vg\/u7\/ikvgu7o_nf0spdpdqowd4se8f04.jpeg\" data-blurred=\"true\"\/><\/div>\n<p>  <\/p>\n<blockquote><p>\u0411\u043e\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e.  <\/p><\/blockquote>\n<p>  <\/p>\n<h3>\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0447\u0430\u0442 \u0441 ChatGPT<\/h3>\n<p>  \u0411\u043e\u0442 \u0443\u043c\u0435\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0441\u0435\u0441\u0441\u0438\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0435\u0437 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0444\u0438\u043b\u044c\u0442\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0442\u0438\u043f\u043e\u043c <code>text<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 ChatGPT. <\/p>\n<pre><code class=\"plaintext\">bot.on(message('text'), async (ctx) => {   ctx.session ??= INITIAL_SESSION   try {     await ctx.reply(code('\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u044f\u043b. \u0416\u0434\u0443 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430...'))     await processTextToChat(ctx, ctx.message.text)   } catch (e) {     console.log(`Error while voice message`, e.message)   } }) <\/code><\/pre>\n<p>  <i>.\/src\/logic.js<\/i><\/p>\n<p>  <a href=\"https:\/\/selectel.ru\/services\/cloud\/sharedline\/?utm_source=habr.com&amp;utm_medium=referral&amp;utm_campaign=cloud_article_tgbot_030523_banner_25_ord\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/f1\/ue\/2l\/f1ue2l9jfmdsk_wexxo70-hhk9c.png\" data-src=\"https:\/\/habrastorage.org\/webt\/f1\/ue\/2l\/f1ue2l9jfmdsk_wexxo70-hhk9c.png\"\/><\/div>\n<p><\/a><\/p>\n<p>  <font color=\"#EB4247\"><\/p>\n<h2>\u0414\u0435\u043f\u043b\u043e\u0439 \u0431\u043e\u0442\u0430 \u043d\u0430 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440<\/h2>\n<p><\/font><br \/>  \u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435. \u042d\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043a\u0440\u0443\u0433\u043b\u043e\u0441\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0431\u043e\u0442\u0430. \u0412\u0435\u0434\u044c \u0442\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0431\u0435\u0441\u043f\u0435\u0440\u0435\u0431\u043e\u0439\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0431\u043e\u0442\u0430 \u0432 \u043e\u0431\u043b\u0430\u043a\u043e \u2014 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c Dockerfile, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u0410 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 <code>docker build<\/code> \u0438 <code>docker run<\/code> \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0441\u0442\u0438 Makefile. <\/p>\n<pre><code class=\"plaintext\">FROM node:16-alpine WORKDIR \/app COPY package*.json .\/ RUN npm ci COPY . . ENV PORT=3000 EXPOSE $PORT CMD [\"npm\", \"start\"] <\/code><\/pre>\n<p>  <i>Dockerfile<\/i><\/p>\n<pre><code class=\"plaintext\">build: docker build -t tgbot . run: docker run -d -p 3000:3000 --name tgbot --rm tgbot <\/code><\/pre>\n<p>  <i>Makefile<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>make run<\/code>. <\/p>\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u043e\u0442\u0430<\/h3>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 ChatGPT \u0447\u0435\u0440\u0435\u0437 API \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u0434\u043b\u044f \u0434\u0435\u043f\u043b\u043e\u044f \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 <a href=\"https:\/\/selectel.ru\/services\/cloud\/sharedline\/?utm_source=habr.com&amp;utm_medium=referral&amp;utm_campaign=cloud_article_tgbot_030523_content\">\u0441\u0435\u0440\u0432\u0435\u0440 \u043b\u0438\u043d\u0435\u0439\u043a\u0438 Shared Line<\/a>. \u042d\u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043a\u0430 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u043f\u043b\u0430\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0438 \u044f\u0434\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 10, 20 \u0438\u043b\u0438 50%. Shared Line \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043b\u0430\u043a\u0430 \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0437\u0430 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <b>\u041e\u0431\u043b\u0430\u0447\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430<\/b>. \u0417\u0430\u0442\u0435\u043c \u2014 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0435\u0433\u043e. <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/mv\/ki\/gu\/mvkigu_k43ppvzp68xvutpoilug.png\" data-src=\"https:\/\/habrastorage.org\/webt\/mv\/ki\/gu\/mvkigu_k43ppvzp68xvutpoilug.png\"\/><\/div>\n<p>  <i>\u0411\u043e\u0442\u0443 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u041e\u0421 Ubuntu 22.04 LTS, 1 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0434\u0440\u0430 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0432 20% \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, 512 \u041c\u0411 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 5 \u0413\u0411 \u043d\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u0434\u0438\u0441\u043a\u0435 (\u0431\u0430\u0437\u043e\u0432\u044b\u0439 HDD). \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u043d\u043e\u0432\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u043f\u043e\u0434\u0441\u0435\u0442\u0438 (\/29, 5 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 IPv4) \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u0439\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 41 \u20bd\/\u0434\u0435\u043d\u044c. <\/i><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 Docker \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e <a href=\"https:\/\/selectel.ru\/blog\/what-is-docker\/#vmashine\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/a>, git \u0438 \u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 API-\u043a\u043b\u044e\u0447\u0438, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u0447\u0435\u0440\u0435\u0437 <code>make build<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c c \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>make run<\/code>!<\/p>\n<div class=\"oembed\">\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/645249a2ba194ffbd3451895\" data-style=\"\" id=\"645249a2ba194ffbd3451895\" width=\"\"><\/div>\n<\/div>\n<p>  <i>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u0442\u0430.<\/i><\/p>\n<p>  \u0421\u0443\u043f\u0435\u0440 \u2014 \u0431\u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442! \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0434\u0438\u0430\u043b\u043e\u0433\u0430 \u0441 \u0431\u043e\u0442\u043e\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0443 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<blockquote><p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 Telegram-\u0431\u043e\u0442\u043e\u0432 \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u044f \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u0443\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0430: \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043e\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438 pay-as-you-go. \u0412\u0438\u0434\u0435\u043e\u0432\u0435\u0440\u0441\u0438\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e <a href=\"https:\/\/www.youtube.com\/watch?v=MzO-0IYkZMU\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.  <\/p><\/blockquote>\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\/731692\/\"> https:\/\/habr.com\/ru\/articles\/731692\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/wu\/_e\/_d\/wu_e_d5vi5xzb9bfddgincwdzpc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/wu\/_e\/_d\/wu_e_d5vi5xzb9bfddgincwdzpc.png\"\/><\/div>\n<p>  \u041f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u043d\u0430\u0437\u0430\u0434 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441 ChatGPT \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c VPN \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenAI, \u0430 \u043f\u0440\u043e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u044b\u0442\u044c \u0432\u043e\u0432\u0441\u0435. <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0434\u0435\u043b\u044e\u0441\u044c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c ChatGPT Telegram-\u0431\u043e\u0442\u0430 \u043d\u0430 NodeJS \u0438 \u0437\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 <a href=\"https:\/\/selectel.ru\/services\/cloud\/sharedline\/?utm_source=habr.com&amp;utm_medium=referral&amp;utm_campaign=cloud_article_tgbot_030523_content\">\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440<\/a>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c!  <\/p>\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-382742","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/382742","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=382742"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/382742\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}