{"id":3420,"date":"2023-04-08T19:28:26","date_gmt":"2023-04-08T11:28:26","guid":{"rendered":"https:\/\/www.bytetape.com\/?p=3420"},"modified":"2023-09-01T22:56:24","modified_gmt":"2023-09-01T14:56:24","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e5%bc%80%e6%ba%90%e8%81%8a%e5%a4%a9%e5%b7%a5%e5%85%b7%e4%b8%ad%e4%bd%bf%e7%94%a8chatgpt","status":"publish","type":"post","link":"https:\/\/www.bytetape.com\/?p=3420","title":{"rendered":"\u5982\u4f55\u5728\u5f00\u6e90\u804a\u5929\u5de5\u5177\u4e2d\u4f7f\u7528chatGPT"},"content":{"rendered":"\n<p><a href=\"https:\/\/github.com\/bytetape\/rocketchat_chatGPT\/blob\/main\/README.md\">https:\/\/github.com\/bytetape\/rocketchat_chatGPT\/blob\/main\/README.md<\/a><\/p>\n\n\n\n<p>\u8fd9\u662f\u901a\u8fc7\u4f7f\u7528hubot\u673a\u5668\u4eba\u4f7f\u7528chatGPT API\u6765\u5b9e\u73b0\u5728rocketchat\u4e2d\u4f7f\u7528chatGPT\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u4f7f\u7528\u5883\u5916\u670d\u52a1\u5668\uff08\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5883\u5185rocketchat+\u5883\u5916hubot\u4e24\u53f0\u670d\u52a1\u5668\uff09\uff0c\u4e0b\u9762\u4ee5Debian\u7cfb\u7edf\u5b89\u88c5\u4e3a\u4f8b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/bytetape\/rocketchat_chatGPT\/blob\/main\/README.md#1-%E5%AE%89%E8%A3%85docker-compose\"><\/a>1. \u5b89\u88c5Docker Compose<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -i\napt-get update\n<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u5305\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release\n<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0 Docker \u7684 GPG \u5bc6\u94a5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg\n<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0 Docker \u7684 APT \u6e90\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \\\n  \"deb &#91;arch=amd64 signed-by=\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/debian \\\n  $(lsb_release -cs) stable\" | sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null\n<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5 Docker\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install -y docker-ce docker-ce-cli containerd.io\n<\/code><\/pre>\n\n\n\n<p>\u542f\u52a8 Docker \u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start docker\n<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5 Docker Compose\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo curl -L \"https:\/\/github.com\/docker\/compose\/releases\/latest\/download\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose\n<\/code><\/pre>\n\n\n\n<p>\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod +x \/usr\/local\/bin\/docker-compose\n<\/code><\/pre>\n\n\n\n<p>\u9a8c\u8bc1 Docker \u548c Docker Compose \u662f\u5426\u6210\u529f\u5b89\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker --version\ndocker-compose --version\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6709\u663e\u793adocker\u548cdocker compose\u7684\u7248\u672c\u53f7\u5373\u4ee3\u8868\u5b89\u88c5\u6210\u529f\uff01\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@VM-4-2-debian:~# docker --version\nDocker version 23.0.3, build 3e7cbfd\nroot@VM-4-2-debian:~# docker-compose --version\nDocker Compose version v2.17.2\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/bytetape\/rocketchat_chatGPT\/blob\/main\/README.md#2-%E5%AE%89%E8%A3%85rocketchat\"><\/a>2. \u5b89\u88c5rocketchat<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u76f4\u63a5\u4f7f\u7528\u5b98\u65b9yml\u6587\u4ef6\u5b89\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -LJO https:\/\/raw.githubusercontent.com\/RocketChat\/Docker.Official.Image\/master\/compose.yml\nsudo docker-compose up -d\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>\u5b89\u88c5\u6210\u529f\u540e\u5373\u53ef\u4f7f\u7528<strong>http:\/\/[\u4f60\u7684\u670d\u52a1\u5668IP]:3000<\/strong>\u8fdb\u5165rocketchat\u754c\u9762\u4e86\u3002<\/li>\n\n\n\n<li>\u7528\u81ea\u5df1\u90ae\u7bb1\u6ce8\u518crocketchat\u8d26\u53f7\u540e\uff0c\u8bb0\u5f97\u56de\u5230\u90ae\u7bb1\u70b9Verify registration\uff01<\/li>\n\n\n\n<li>\u521b\u5efa\u4e00\u4e2a\u673a\u5668\u4eba\uff0c\u547d\u540d\u4e3a\u201cchatGPT\u201d, \u5bc6\u7801chatGPT\uff0c\u8fd9\u91cc\u540d\u5b57\u548c\u5bc6\u7801\u548c\u4e0b\u4e00\u6b65\u7684.env\u6587\u4ef6\u8981\u4fdd\u6301\u4e00\u81f4\uff0cRoles\u9009\u62e9bot\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/bytetape\/rocketchat_chatGPT\/blob\/main\/README.md#3-%E5%AE%89%E8%A3%85hubot%E6%9C%BA%E5%99%A8%E4%BA%BA\"><\/a>3. \u5b89\u88c5hubot\u673a\u5668\u4eba<\/h2>\n\n\n\n<p>\u5b89\u88c5Node.js\u548cnpm<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/deb.nodesource.com\/setup_current.x | sudo -E bash -\nsudo apt-get install -y nodejs\nnode -v\nnpm -v\n<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5hubot\u673a\u5668\u4eba<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/RocketChat\/hubot-rocketchat-boilerplate\ncd hubot-rocketchat-boilerplate\nnpm install\nnpm install node-fetch --save\n<\/code><\/pre>\n\n\n\n<p>hubot-rocketchat-boilerplate\u76ee\u5f55\u4e0b\u521b\u5efa.env\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano .env\n<\/code><\/pre>\n\n\n\n<p>\u7c98\u8d34\u4e0b\u9762\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export ROCKETCHAT_USER=chatGPT\nexport ROCKETCHAT_PASSWORD=chatGPT\nexport ROCKETCHAT_ROOM=general\nexport ROCKETCHAT_AUTH=password\nexport ROCKETCHAT_URL=localhost:3000\nexport ROCKETCHAT_USE_SSL=false\nexport RESPOND_TO_DM=true\n<\/code><\/pre>\n\n\n\n<p>\u4fdd\u5b58\u6587\u4ef6 Ctrl + X, Y, Enter<\/p>\n\n\n\n<p>\u4e0b\u8f7dscript_chatGPT.js \u8fdb\u5165\/hubot-rocketchat-boilerplate\/scripts\u8def\u5f84\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd scripts\n<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528wget\u547d\u4ee4\u4eceGitHub\u4e0b\u8f7d.js\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo wget https:\/\/raw.githubusercontent.com\/bytetape\/rocketchat_chatGPT\/main\/script_chatGPT.js\n<\/code><\/pre>\n\n\n\n<p>\u4fee\u6539API_KEY<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim script_chatGPT.js\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8f93\u5165 i<\/li>\n\n\n\n<li>\u628a\u7b2c5\u884c\u7684YOUR API KEY\u4fee\u6539\u6210\u81ea\u5df1\u7684API_KEY<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5982const API_KEY = \"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\";\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>\u5b8c\u6210\u4fee\u6539\u540e\u6309ESC\uff0c\u8f93\u5165:wq<\/li>\n<\/ol>\n\n\n\n<p>\u8fd4\u56dehubot-rocketchat-boilerplate\u8def\u5f84\u4e0b\uff0c\u542f\u52a8hubot<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ..\nsource .env\nbin\/hubot -a rocketchat\n<\/code><\/pre>\n\n\n\n<p>\u5f85\u5b8c\u6210\u542f\u52a8\uff08\u4e00\u822c\u51e0\u79d2\u949f\uff09\u5982\u679c\u4e00\u5207\u987a\u5229\u7684\u8bdd\uff0c\u53ef\u4ee5\u56de\u5230rocketchat\u9875\u9762\u4e2d\u5c1d\u8bd5\u548cchatGPT\u5bf9\u8bdd\u4e86\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\u5982\u679c\u6211\u4eec\u5173\u95ed\u4e86SSH\u5ba2\u6237\u7aef\uff0c\u6b64\u65f6\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u4e5f\u4f1a\u4e2d\u65ad\u3002\u89e3\u51b3\u65b9\u6cd5\u5c31\u662f\u628a\u8fdb\u7a0b\u8f6c\u5165\u540e\u53f0\uff0c\u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>\u5148\u4f7f\u7528Ctrl+C\u7ec8\u6b62\u8fdb\u7a0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source .env;bin\/hubot -a rocketchat &gt; file.all 2&gt;&amp;1 &amp; disown -h\n<\/code><\/pre>\n\n\n\n<p>\u540e\u7eed\u5982\u679c\u9700\u8981\u5173\u95ed\u8fdb\u7a0b\u53ef\u7528\u4e0b\u9762\u547d\u4ee4\u627e\u5230\u540e\u53f0\u8fdb\u7a0b\uff0c\u5e76kill<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps -ef | grep hubot\nkill &lt;\u8fdb\u7a0b\u53f7&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/b&#8230; <\/p>\n","protected":false},"author":1,"featured_media":3422,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[38,50,51,52,49],"class_list":["post-3420","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-ai","tag-chatgpt","tag-hubot","tag-rocketchat","tag-49"],"_links":{"self":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts\/3420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3420"}],"version-history":[{"count":3,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts\/3420\/revisions"}],"predecessor-version":[{"id":3426,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts\/3420\/revisions\/3426"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/media\/3422"}],"wp:attachment":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}