{"id":345637,"date":"2023-02-18T21:01:28","date_gmt":"2023-02-18T21:01:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=345637"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2023-02-18T21:01:28","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=345637","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 Python c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c API ChatGPT<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f1f\/3c2\/38c\/f1f3c238c99c9bc534d15653eafee760.png\" width=\"1590\" height=\"1037\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f1f\/3c2\/38c\/f1f3c238c99c9bc534d15653eafee760.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 <a href=\"https:\/\/medium.com\/@AleksanderLutken\/chatgpt-api-python-30ca187e2aef\" rel=\"noopener noreferrer nofollow\">medium.com<\/a>, \u043f\u043b\u044e\u0441\u043e\u043c \u043e\u0442 \u0441\u0435\u0431\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f API ChatGPT \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0435.<\/p>\n<p>\u0422\u0435\u043c\u0430 \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u0441\u0442\u0430\u0442\u0435\u0439 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u043e\u043b\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u044f \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u043d\u0438\u0436\u0435 \u0432\u044b\u043b\u043e\u0436\u0443 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u043e\u0442\u0438\u0432\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e <a href=\"https:\/\/chat.openai.com\/chat\" rel=\"noopener noreferrer nofollow\">ChatGPT<\/a> \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0440\u044f\u0434\u0435 \u0441\u0442\u0440\u0430\u043d, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u0420\u043e\u0441\u0441\u0438\u0438, \u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c.<\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b\u0439\/\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442 ChatGPT <a href=\"https:\/\/t.me\/ChatGPT_ForTelegramBot\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d<\/a> <a href=\"https:\/\/t.me\/ChatGPT_ForTelegramBot\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u041d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 &#171;\u041a\u0442\u043e \u0442\u044b?&#187; \u0441\u0430\u043c\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 &#171;\u042f &#8212; ChatGPT, \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0430\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f OpenAI. \u042f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0438 \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0442\u0435\u043c\u044b \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u043c\u044b&#187;.<\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0437\u0430\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043c \u0441\u0438\u0434\u0438\u0442 \u0436\u0438\u0432\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0430 \u043d\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f AI \u043c\u043e\u0434\u0435\u043b\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u0447\u0430\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c, \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043e\u0442 \u0447\u0430\u0442\u0430 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u044b\u0445 \u0438 \u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u043b\u0438 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430, \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0430 \u043d\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c, \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043d\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 <a href=\"https:\/\/chat.openai.com\/chat\" rel=\"noopener noreferrer nofollow\">ChatGPT<\/a> \u0438\u0437 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/704600\/\" rel=\"noopener noreferrer nofollow\">\u0445\u0430\u0431\u0440\u0435<\/a>, \u0445\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c gmail \u043f\u043e\u0447\u0442\u0443 \u0441 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0421\u041c\u0421 \u043d\u0430 \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 ChatGPT \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u043f\u043e \u0421\u041c\u0421, \u0438 \u044d\u0442\u0438 \u0434\u0432\u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043f\u043e \u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0441\u043c\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u0433\u043e\u0434\u044f\u0442\u0441\u044f.<\/p>\n<p><strong>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u0430<\/strong><\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432 python:<\/p>\n<pre><code class=\"python\"># Install openai  pip install openai   # Import Library  import openai  <\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 API OpenAI \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p><a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/introduction\" rel=\"noopener noreferrer nofollow\">https:\/\/beta.openai.com\/docs\/api-reference\/introduction<\/a><\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c API \u043a\u043b\u044e\u0447<\/p>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c API \u043a\u043b\u044e\u0447 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443:<\/p>\n<p><a href=\"https:\/\/beta.openai.com\/account\/api-keys\" rel=\"noopener noreferrer nofollow\">https:\/\/beta.openai.com\/account\/api-keys<\/a><\/p>\n<pre><code class=\"python\"># \u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u044e\u0447 API  openai.api_key = \"Your_Key\"<\/code><\/pre>\n<p><strong>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c<\/strong><\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u201ctext-davinci-003\u201d, \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e GPT-3 \u0438 \u043e\u0431\u0443\u0447\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0438\u044e\u043d\u044f 2021 \u0433\u043e\u0434\u0430. \u0423\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0434\u0435\u0441\u044c:<\/p>\n<p><a href=\"https:\/\/beta.openai.com\/docs\/models\/gpt-3\" rel=\"noopener noreferrer nofollow\">https:\/\/beta.openai.com\/docs\/models\/gpt-3<\/a><\/p>\n<pre><code class=\"python\"># \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c engine=\"text-davinci-003\" <\/code><\/pre>\n<p> <strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c<\/strong><\/p>\n<p>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c! \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c ChatGPT \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0443\u044e Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\"># \u0417\u0430\u043f\u0440\u043e\u0441  prompt = \"\u041d\u0430\u0437\u043e\u0432\u0438 \u043b\u0443\u0447\u0448\u0443\u044e Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e\"   # \u041c\u043e\u0434\u0435\u043b\u044c  completion = openai.Completion.create(engine=engine,                                        prompt=prompt,                                        temperature=0.5,                                        max_tokens=1000) <\/code><\/pre>\n<p> \u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u201ctext-davinci-003\u201d, \u0441 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u043e\u0439 0,5. \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 1. \u041c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0431\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0440\u0438\u0441\u043a. \u041e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"python\"># \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u0432\u0435\u0442  print(completion)  <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/05e\/095\/206\/05e0952062d5af8aae9a648e3681d90d.png\" width=\"1024\" height=\"683\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/05e\/095\/206\/05e0952062d5af8aae9a648e3681d90d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"python\"># \u041f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 print( completion.choices[0]['text'] ) \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442: Scikit-learn.<\/code><\/pre>\n<p>\u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435! \u041a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0438 \u0442\u0430\u043c \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"python\">prompt = str(input()) completion = openai.Completion.create(engine=engine,                                       prompt=prompt,                                       temperature=0.5,                                       max_tokens=1000)                                       print('\\n\u041e\u0442\u0432\u0435\u0442:') print( completion.choices[0]['text'] )<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u0432\u044b\u0448\u0435 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0441\u043a\u0440\u0438\u043f\u0442 \u0436\u0434\u0435\u0442 \u0432\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437-\u0437\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 input(). \u041e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h2>\u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u0434 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/h2>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043e\u0431\u0435\u0440\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 Python \u0432 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\"># \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f ChatGPT def ask(prompt):     completion = openai.Completion.create(engine=\"text-davinci-003\",                                            prompt=prompt,                                            temperature=0.5,                                            max_tokens=1000)     print( '\u0412\u043e\u043f\u0440\u043e\u0441:', prompt )     print( '\\n\u041e\u0442\u0432\u0435\u0442:' )     print( completion.choices[0]['text'] )<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00abask()\u00bb.<\/p>\n<pre><code class=\"python\">ask('\u0441\u0430\u043c\u0430\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u0436\u0435\u043d\u0449\u0438\u043d\u0430 \u043d\u0430 \u0437\u0435\u043c\u043b\u0435') # \u041e\u0442\u0432\u0435\u0442 # \u041d\u0430 \u0437\u0435\u043c\u043b\u0435 \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0439 \u0436\u0435\u043d\u0449\u0438\u043d\u044b. \u041a\u0440\u0430\u0441\u043e\u0442\u0430 \u0438 \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043a\u0443\u0441\u0430\u043c \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f\u043c.<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c API ChatGPT \u043f\u0440\u043e\u0441\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u043d\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0434\u0430\u0435\u0442, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430 100% \u0432\u0435\u0440\u043d\u044b.<\/p>\n<h2>\u041f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c API ChatGPT \u043a \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0443<\/h2>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u0432 <a href=\"https:\/\/github.com\/ViktorAllayarov\/ChatGPT_telegram_bot\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/a><\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443 <a href=\"https:\/\/t.me\/BotFather\" rel=\"noopener noreferrer nofollow\">BotFather<\/a>. \u0422\u0430\u043c \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.<\/p>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre><code class=\"bash\">git clone git@github.com:ViktorAllayarov\/ChatGPT_telegram_bot.git  # \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c cd ChatGPT_telegram_bot<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>python3 -m venv env # \u0438\u043b\u0438 py -3.10 -m venv env<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 pip:<\/p>\n<pre><code># \u0434\u043b\u044f Linux\/macOS source env\/bin\/activate  \u0434\u043b\u044f Windows source env\/scripts\/activate  \u0434\u0430\u043b\u0435\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c pip python -m pip install --upgrade pip  \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 pip install -r requirements.txt<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 main.py \u0435\u0441\u0442\u044c \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u044f\u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>dotenv<\/code>:<\/p>\n<pre><code class=\"python\">env = {     **dotenv_values(\".env.prod\"),     **dotenv_values(\".env.dev\"),  # override } openai.api_key = env[\"API_KEY_CHATGPT\"] bot = telebot.TeleBot(env[\"TG_BOT_TOKEN\"]) db_link = env[\"DB_LINK\"]<\/code><\/pre>\n<p>\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u00a0<code>.env.prod<\/code> \u0438\u043b\u0438\u00a0<code>.env.dev<\/code> (\u0438\u043b\u0438 \u043e\u0431\u0430 \u0444\u0430\u0439\u043b\u0430) \u0438 \u0437\u0430\u0434\u0430\u0442\u044c \u0442\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435\u00a0<\/p>\n<pre><code class=\"powershell\"># \u0444\u0430\u0439\u043b .env.prod API \u043a\u043b\u044e\u0447 CHATGPT API_KEY_CHATGPT= # \u0442\u043e\u043a\u0435\u043d \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 TG_BOT_TOKEN= # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0411\u0414 SQLite3, # \u0444\u0430\u0439\u043b \u0431\u0430\u0437\u044b \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 # \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432 \u0431\u043e\u0442\u0435 # \u0431\u0430\u0437\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u043e\u0442\u043e\u043c DB_LINK=db.db<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"python\">python main.py<\/code><\/pre>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u0441\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0438 \u0435\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u0441\u0430\u0439\u0442\u0435.<\/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\/post\/717816\/\"> https:\/\/habr.com\/ru\/post\/717816\/<\/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<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 <a href=\"https:\/\/medium.com\/@AleksanderLutken\/chatgpt-api-python-30ca187e2aef\" rel=\"noopener noreferrer nofollow\">medium.com<\/a>, \u043f\u043b\u044e\u0441\u043e\u043c \u043e\u0442 \u0441\u0435\u0431\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f API ChatGPT \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0435.<\/p>\n<p>\u0422\u0435\u043c\u0430 \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u0441\u0442\u0430\u0442\u0435\u0439 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u043e\u043b\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u044f \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u043d\u0438\u0436\u0435 \u0432\u044b\u043b\u043e\u0436\u0443 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u043e\u0442\u0438\u0432\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e <a href=\"https:\/\/chat.openai.com\/chat\" rel=\"noopener noreferrer nofollow\">ChatGPT<\/a> \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0440\u044f\u0434\u0435 \u0441\u0442\u0440\u0430\u043d, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u0420\u043e\u0441\u0441\u0438\u0438, \u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c.<\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b\u0439\/\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442 ChatGPT <a href=\"https:\/\/t.me\/ChatGPT_ForTelegramBot\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d<\/a> <a href=\"https:\/\/t.me\/ChatGPT_ForTelegramBot\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u041d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 &#171;\u041a\u0442\u043e \u0442\u044b?&#187; \u0441\u0430\u043c\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 &#171;\u042f &#8212; ChatGPT, \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0430\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f OpenAI. \u042f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0438 \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0442\u0435\u043c\u044b \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u043c\u044b&#187;.<\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0437\u0430\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043c \u0441\u0438\u0434\u0438\u0442 \u0436\u0438\u0432\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0430 \u043d\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f AI \u043c\u043e\u0434\u0435\u043b\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u0447\u0430\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c, \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043e\u0442 \u0447\u0430\u0442\u0430 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u044b\u0445 \u0438 \u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u043b\u0438 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430, \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0430 \u043d\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c, \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043d\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 <a href=\"https:\/\/chat.openai.com\/chat\" rel=\"noopener noreferrer nofollow\">ChatGPT<\/a> \u0438\u0437 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/704600\/\" rel=\"noopener noreferrer nofollow\">\u0445\u0430\u0431\u0440\u0435<\/a>, \u0445\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c gmail \u043f\u043e\u0447\u0442\u0443 \u0441 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0421\u041c\u0421 \u043d\u0430 \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 ChatGPT \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u043f\u043e \u0421\u041c\u0421, \u0438 \u044d\u0442\u0438 \u0434\u0432\u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043f\u043e \u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0441\u043c\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u0433\u043e\u0434\u044f\u0442\u0441\u044f.<\/p>\n<p><strong>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u0430<\/strong><\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432 python:<\/p>\n<pre><code class=\"python\"># Install openai  pip install openai   # Import Library  import openai  <\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 API OpenAI \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p><a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/introduction\" rel=\"noopener noreferrer nofollow\">https:\/\/beta.openai.com\/docs\/api-reference\/introduction<\/a><\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c API \u043a\u043b\u044e\u0447<\/p>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c API \u043a\u043b\u044e\u0447 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443:<\/p>\n<p><a href=\"https:\/\/beta.openai.com\/account\/api-keys\" rel=\"noopener noreferrer nofollow\">https:\/\/beta.openai.com\/account\/api-keys<\/a><\/p>\n<pre><code class=\"python\"># \u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u044e\u0447 API  openai.api_key = \"Your_Key\"<\/code><\/pre>\n<p><strong>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c<\/strong><\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u201ctext-davinci-003\u201d, \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e GPT-3 \u0438 \u043e\u0431\u0443\u0447\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0438\u044e\u043d\u044f 2021 \u0433\u043e\u0434\u0430. \u0423\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0434\u0435\u0441\u044c:<\/p>\n<p><a href=\"https:\/\/beta.openai.com\/docs\/models\/gpt-3\" rel=\"noopener noreferrer nofollow\">https:\/\/beta.openai.com\/docs\/models\/gpt-3<\/a><\/p>\n<pre><code class=\"python\"># \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c engine=\"text-davinci-003\" <\/code><\/pre>\n<p> <strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c<\/strong><\/p>\n<p>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c! \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c ChatGPT \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0443\u044e Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\"># \u0417\u0430\u043f\u0440\u043e\u0441  prompt = \"\u041d\u0430\u0437\u043e\u0432\u0438 \u043b\u0443\u0447\u0448\u0443\u044e Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e\"   # \u041c\u043e\u0434\u0435\u043b\u044c  completion = openai.Completion.create(engine=engine,                                        prompt=prompt,                                        temperature=0.5,                                        max_tokens=1000) <\/code><\/pre>\n<p> \u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u201ctext-davinci-003\u201d, \u0441 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u043e\u0439 0,5. \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 1. \u041c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0431\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0440\u0438\u0441\u043a. \u041e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"python\"># \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u0432\u0435\u0442  print(completion)  <\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"python\"># \u041f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 print( completion.choices[0]['text'] ) \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442: Scikit-learn.<\/code><\/pre>\n<p>\u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435! \u041a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0438 \u0442\u0430\u043c \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"python\">prompt = str(input()) completion = openai.Completion.create(engine=engine,                                       prompt=prompt,                                       temperature=0.5,                                       max_tokens=1000)                                       print('\\n\u041e\u0442\u0432\u0435\u0442:') print( completion.choices[0]['text'] )<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u0432\u044b\u0448\u0435 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0441\u043a\u0440\u0438\u043f\u0442 \u0436\u0434\u0435\u0442 \u0432\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437-\u0437\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 input(). \u041e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h2>\u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u0434 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/h2>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043e\u0431\u0435\u0440\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 Python \u0432 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\"># \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f ChatGPT def ask(prompt):     completion = openai.Completion.create(engine=\"text-davinci-003\",                                            prompt=prompt,                                            temperature=0.5,                                            max_tokens=1000)     print( '\u0412\u043e\u043f\u0440\u043e\u0441:', prompt )     print( '\\n\u041e\u0442\u0432\u0435\u0442:' )     print( completion.choices[0]['text'] )<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00abask()\u00bb.<\/p>\n<pre><code class=\"python\">ask('\u0441\u0430\u043c\u0430\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u0436\u0435\u043d\u0449\u0438\u043d\u0430 \u043d\u0430 \u0437\u0435\u043c\u043b\u0435') # \u041e\u0442\u0432\u0435\u0442 # \u041d\u0430 \u0437\u0435\u043c\u043b\u0435 \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0439 \u0436\u0435\u043d\u0449\u0438\u043d\u044b. \u041a\u0440\u0430\u0441\u043e\u0442\u0430 \u0438 \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043a\u0443\u0441\u0430\u043c \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f\u043c.<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c API ChatGPT \u043f\u0440\u043e\u0441\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u043d\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0434\u0430\u0435\u0442, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430 100% \u0432\u0435\u0440\u043d\u044b.<\/p>\n<h2>\u041f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c API ChatGPT \u043a \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0443<\/h2>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u0432 <a href=\"https:\/\/github.com\/ViktorAllayarov\/ChatGPT_telegram_bot\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/a><\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443 <a href=\"https:\/\/t.me\/BotFather\" rel=\"noopener noreferrer nofollow\">BotFather<\/a>. \u0422\u0430\u043c \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.<\/p>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre><code class=\"bash\">git clone git@github.com:ViktorAllayarov\/ChatGPT_telegram_bot.git  # \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c cd ChatGPT_telegram_bot<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>python3 -m venv env # \u0438\u043b\u0438 py -3.10 -m venv env<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 pip:<\/p>\n<pre><code># \u0434\u043b\u044f Linux\/macOS source env\/bin\/activate  \u0434\u043b\u044f Windows source env\/scripts\/activate  \u0434\u0430\u043b\u0435\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c pip python -m pip install --upgrade pip  \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 pip install -r requirements.txt<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 main.py \u0435\u0441\u0442\u044c \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u044f\u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>dotenv<\/code>:<\/p>\n<pre><code class=\"python\">env = {     **dotenv_values(\".env.prod\"),     **dotenv_values(\".env.dev\"),  # override } openai.api_key = env[\"API_KEY_CHATGPT\"] bot = telebot.TeleBot(env[\"TG_BOT_TOKEN\"]) db_link = env[\"DB_LINK\"]<\/code><\/pre>\n<p>\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u00a0<code>.env.prod<\/code> \u0438\u043b\u0438\u00a0<code>.env.dev<\/code> (\u0438\u043b\u0438 \u043e\u0431\u0430 \u0444\u0430\u0439\u043b\u0430) \u0438 \u0437\u0430\u0434\u0430\u0442\u044c \u0442\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435\u00a0<\/p>\n<pre><code class=\"powershell\"># \u0444\u0430\u0439\u043b .env.prod API \u043a\u043b\u044e\u0447 CHATGPT API_KEY_CHATGPT= # \u0442\u043e\u043a\u0435\u043d \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 TG_BOT_TOKEN= # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0411\u0414 SQLite3, # \u0444\u0430\u0439\u043b \u0431\u0430\u0437\u044b \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 # \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432 \u0431\u043e\u0442\u0435 # \u0431\u0430\u0437\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u043e\u0442\u043e\u043c DB_LINK=db.db<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"python\">python main.py<\/code><\/pre>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u0441\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0438 \u0435\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u0441\u0430\u0439\u0442\u0435.<\/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\/post\/717816\/\"> https:\/\/habr.com\/ru\/post\/717816\/<\/a><br \/><\/br><\/br><\/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-345637","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/345637","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=345637"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/345637\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}