{"id":8207,"date":"2024-11-05T19:11:09","date_gmt":"2024-11-05T11:11:09","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=8207"},"modified":"2024-11-05T19:17:08","modified_gmt":"2024-11-05T11:17:08","slug":"ddg-chat","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/de\/ddg-chat\/","title":{"rendered":"DDG-Chat\uff1a\u4e00\u952e\u90e8\u7f72Chat2API\u540e\u7aef\uff0cDuckDuckGo\u8f6cAPI"},"content":{"rendered":"<p>DDG-Chat \u662f\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u53ef\u4ee5\u4e00\u952e\u90e8\u7f72\u5230\u591a\u79cd\u5e73\u53f0\u7684 <a href=\"https:\/\/www.kdjingpai.com\/pt\/chatgpt-6\/\">ChatGPT<\/a> API \u540e\u7aef\u3002\u8be5\u9879\u76ee\u652f\u6301\u591a\u79cd\u6a21\u578b\uff0c\u5305\u62ec GPT-4o mini\u3001Claude 3 Haiku\u3001Llama 3.1 70B \u548c Mixtral 8x7B\uff0c\u6240\u6709\u6a21\u578b\u5747\u7531 DuckDuckGo \u533f\u540d\u63d0\u4f9b\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 Vercel\u3001Cloudflare Workers\u3001Docker \u7b49\u5e73\u53f0\u8f7b\u677e\u90e8\u7f72\u548c\u4f7f\u7528\u8be5 API \u540e\u7aef\u3002<\/p>\n<p>\u7531\u4e8e DDG API \u9650\u5236\u5355 IP \u5e76\u53d1\u6570\uff0c\u63a8\u8350\u4f7f\u7528 Vercel \u8fdb\u884c\u90e8\u7f72\uff0c\u5982\u679c\u4f7f\u7528 Docker \u4e4b\u7c7b\u7684\u672c\u5730\u90e8\u7f72\uff0c\u8bf7\u786e\u4fdd\u9879\u76ee\u8fd0\u884c\u5728\u4ee3\u7406\u6c60\u4e2d\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li>\u652f\u6301\u591a\u79cd ChatGPT \u6a21\u578b<\/li>\n<li>\u4e00\u952e\u90e8\u7f72\u5230 Vercel\u3001Cloudflare Workers\u3001Docker \u7b49\u5e73\u53f0<\/li>\n<li>\u63d0\u4f9b API \u63a5\u53e3\uff0c\u65b9\u4fbf\u7b2c\u4e09\u65b9\u5e94\u7528\u8c03\u7528<\/li>\n<li>\u652f\u6301\u591a\u79cd\u90e8\u7f72\u65b9\u5f0f\uff0c\u5305\u62ec\u4e91\u7aef\u548c\u672c\u5730\u90e8\u7f72<\/li>\n<li>\u63d0\u4f9b\u8be6\u7ec6\u7684\u90e8\u7f72\u548c\u4f7f\u7528\u6587\u6863<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u4e0e\u90e8\u7f72<\/h3>\n<h4>Vercel \u90e8\u7f72<\/h4>\n<ol>\n<li>\u4e91\u7aef Fork \u4ed3\u5e93\u90e8\u7f72\uff1a\uff08<a href=\"https:\/\/vercel.com\/new\/clone?repository-url=https%3A%2F%2Fgithub.com%2Fleafmoes%2Fddg-chat&amp;project-name=ddg-chat&amp;repository-name=ddg-chat\">Vercel\u4e00\u952e\u90e8\u7f72<\/a>\uff09\n<ul>\n<li>Fork \u8fd9\u4e2a\u4ed3\u5e93\u5230\u4f60\u7684 GitHub \u8d26\u6237\u3002<\/li>\n<li>\u8fdb\u5165 Vercel \u65b0\u5efa\u9879\u76ee\u9875\u9762\uff0c\u5bfc\u5165\u4f60\u521a\u624d Fork \u7684\u4ed3\u5e93\u3002<\/li>\n<li>\u70b9\u51fb Deploy \u5373\u53ef\u5b8c\u6210\u90e8\u7f72\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u672c\u5730 Clone \u4ed3\u5e93\u90e8\u7f72\uff1a\n<ul>\n<li>\u786e\u4fdd\u4f60\u6709 Node.js \u73af\u5883\u3002<\/li>\n<li>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code>npm i -g vercel\r\nvercel login\r\ngit clone https:\/\/github.com\/leafmoes\/DDG-Chat.git ddg-chat\r\ncd ddg-chat\r\nnpm run publish\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>Cloudflare Workers \u90e8\u7f72<\/h4>\n<ol>\n<li>\u8fdb\u5165 Cloudflare Workers \u548c Pages \u63a7\u5236\u53f0\uff0c\u521b\u5efa\u4e00\u4e2a Workers\u3002<\/li>\n<li>\u5728 Workers \u8bbe\u7f6e\u4e2d\uff0c\u5c06\u8fd0\u884c\u65f6\u8bbe\u7f6e\u4e3a nodejs_compat\u3002<\/li>\n<li><a href=\"https:\/\/github.com\/leafmoes\/DDG-Chat\/blob\/master\/dist\/index.js\">\u7c98\u8d34\u4ed3\u5e93\u4e2d\u7684\u4ee3\u7801<\/a>\u5230\u4f60\u7684 Workers\uff0c\u7136\u540e\u70b9\u51fb\u90e8\u7f72\u3002<\/li>\n<\/ol>\n<h4>Docker \u90e8\u7f72<\/h4>\n<ol>\n<li>\u547d\u4ee4\u884c\u6784\u5efa\uff1a\n<pre><code>docker run -it -d --name ddg-chat -p 8787:8787 ghcr.io\/leafmoes\/ddg-chat:latest\r\n<\/code><\/pre>\n<\/li>\n<li>\u4f7f\u7528 docker-compose.yml \u6587\u4ef6\u6784\u5efa\uff1a\n<ul>\n<li>\u4e0b\u8f7d\u5e76\u4fdd\u5b58 docker-compose.yml \u6587\u4ef6\u3002<\/li>\n<li>\u5728\u8be5\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u670d\u52a1\uff1a\n<pre><code>docker-compose up -d\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u73af\u5883\u53d8\u91cf<\/h3>\n<pre># API \u8c03\u7528\u7684\u524d\u7f00\u5730\u5740\r\nAPI_PREFIX = '\/'\r\n# \u4f5c\u4e3a\u8c03\u7528 API \u9a8c\u8bc1\u7684 API Key\r\nAPI_KEY = 'dummy_key'\r\n# \u5411 DDG \u53d1\u9001\u8bf7\u6c42\u5931\u8d25\u7684\u91cd\u8bd5\u6b21\u6570\r\nMAX_RETRY_COUNT = 3\r\n# \u5411 DDG \u53d1\u9001\u8bf7\u6c42\u5931\u8d25\u7684\u91cd\u8bd5\u5ef6\u8fdf\uff0c\u5355\u4f4d ms\r\nRETRY_DELAY = 5000<\/pre>\n<h3>\u4f7f\u7528 API<\/h3>\n<h4>\u8c03\u7528\u63a5\u53e3<\/h4>\n<p>\u4f7f\u7528\u7b2c\u4e09\u65b9 ChatGPT \u5e94\u7528\u6765\u8c03\u7528\u63a5\u53e3\uff0c\u4f8b\u5982 ChatNextWeb\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5bf9\u8bdd\u8bf7\u6c42\u793a\u4f8b\uff1a<\/p>\n<pre><code>curl --request POST 'https:\/\/\u4f60\u7684\u57df\u540d\/v1\/chat\/completions' \\\r\n--header 'Content-Type: application\/json' \\\r\n--data '{\r\n\"messages\": [\r\n{\r\n\"role\": \"user\",\r\n\"content\": \"\u4f60\u597d\uff01\"\r\n}\r\n],\r\n\"model\": \"gpt-4o-mini\",\r\n\"stream\": true\r\n}'\r\n<\/code><\/pre>\n<h4>\u6a21\u578b\u67e5\u8be2<\/h4>\n<p>\u8bbf\u95ee <code>https:\/\/\u4f60\u7684\u57df\u540d\/v1\/models<\/code> \u53ef\u67e5\u770b\u5f53\u524d\u652f\u6301\u7684\u6a21\u578b\u3002<\/p>\n<h3>\u5e38\u89c1\u95ee\u9898<\/h3>\n<ul>\n<li><strong>Vercel \u90e8\u7f72\u9650\u5236<\/strong>\uff1a\u514d\u8d39\u7248\u5355\u6b21 API \u8bf7\u6c42\u65f6\u957f\u4e3a 60 \u79d2\uff0c\u6bcf\u6708 API \u8c03\u7528\u6b21\u6570\u4e3a 100,000 \u6b21\u3002<\/li>\n<li><strong>\u62a5\u9519 429 ERR_SERVICE_UNAVAILABLE<\/strong>\uff1a\u975e Vercel \u5bb9\u6613\u51fa\u73b0\u6b64\u95ee\u9898\uff0c\u7531\u4e8e DDG API \u9650\u5236\u5355 IP \u5e76\u53d1\uff0c\u5efa\u8bae\u51cf\u5c11\u5e76\u53d1\u91cf\uff0c\u540c\u65f6\u4f7f\u7528\u4ee3\u7406\u6c60\u8fdb\u884c\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2 dir=\"auto\">\u5907\u9009go\u7248\u672c\u90e8\u7f72\uff1a\u514d\u8d39\u670d\u52a1\u5668serv00\u90e8\u7f72\u5e38\u9a7b\u670d\u52a1<\/h2>\n<p><a href=\"https:\/\/github.com\/xqdoo00o\/ChatGPT-to-API\">\u9879\u76ee\u6765\u6e90<\/a><\/p>\n<ol dir=\"auto\">\n<li>\u8fdb\u5165serv00\u9762\u677f \u70b9\u51fb DNS zones \u70b9\u51fb Add new zone \u6dfb\u52a0\u81ea\u5df1\u7684\u81ea\u5b9a\u4e49\u57df\u540d<\/li>\n<li>\u5230cf\u6dfb\u52a0A\u8bb0\u5f55\u89e3\u6790<\/li>\n<li>\u70b9\u51fbAdditional services \u70b9\u51fbRun your own applications \u9009\u62e9\u00a0<strong><code>Enabled<\/code><\/strong><\/li>\n<li>\u5f00\u653e\u4e00\u4e2a\u7aef\u53e3 \u6211\u5f00\u653e\u7684\u662f5005<\/li>\n<li>\u70b9\u51fb WWW Websites \u70b9\u51fb Add website Domain\u586b\u81ea\u5df1\u7684\u57df\u540d<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"\" title=\"ChatGPT\u8f6cAPI\uff0c\u5229\u7528serv00\u90e8\u7f72\u5e38\u9a7b\u670d\u52a1\u3002-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/04706586bf8a5de.jpg\" alt=\"ChatGPT\u8f6cAPI\uff0c\u5229\u7528serv00\u90e8\u7f72\u5e38\u9a7b\u670d\u52a1\u3002-1\" width=\"603\" height=\"409\" \/><\/p>\n<ol dir=\"auto\">\n<li><a href=\"https:\/\/github.com\/Shadownc\/DDG-Chat-go\/releases\/download\/v0.0.2\/ddgchatgo-freebsd-amd64\">\u70b9\u51fb\u4e0b\u8f7d\u6587\u4ef6<\/a>\u00a0\u8d4b\u4e88\u6587\u4ef6\u53ef\u6267\u884c\u6743\u9650\n<pre><code>chmod +x ddgchatgo-freebsd-amd64\r\n<\/code><\/pre>\n<\/li>\n<li>\u5728<code>public_html<\/code>\u4e0b\u521b\u5efa\u542f\u52a8\u811a\u672c<code>start_ddgchatgo.sh<\/code>\n<pre><code>#!\/bin\/bash\r\n# \u5b9a\u4e49\u8fdb\u7a0b\u540d\u79f0\u548c\u542f\u52a8\u547d\u4ee4\r\nPROCESS_NAME=\"ddgchatgo\"\r\nSTART_COMMAND=\"PORT=5005 \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/ddgchatgo-freebsd-amd64 &gt; \/home\/\u4f60\u7684Serv00\u7528\u6237\/domains\/example.com\/public_html\/ddgchatgo.log 2&gt;&amp;1 &amp;\"\r\n# \u68c0\u67e5\u8fdb\u7a0b\u662f\u5426\u5728\u8fd0\u884c\r\nif ! pgrep -f \"$PROCESS_NAME\" &gt; \/dev\/null\r\nthen\r\necho \"\u8fdb\u7a0b $PROCESS_NAME \u672a\u8fd0\u884c\uff0c\u6b63\u5728\u542f\u52a8...\"\r\n# \u542f\u52a8\u8fdb\u7a0b\r\neval \"$START_COMMAND\"\r\nif [ $? -eq 0 ]; then\r\necho \"\u8fdb\u7a0b $PROCESS_NAME \u542f\u52a8\u6210\u529f\u3002\"\r\nelse\r\necho \"\u8fdb\u7a0b $PROCESS_NAME \u542f\u52a8\u5931\u8d25\u3002\"\r\nfi\r\nelse\r\necho \"\u8fdb\u7a0b $PROCESS_NAME \u5df2\u7ecf\u5728\u8fd0\u884c\u3002\"\r\nfi\r\n<\/code><\/pre>\n<\/li>\n<li>\u8d4b\u4e88\u811a\u672c\u6267\u884c\u6743\u9650\n<pre><code>chmod +x start_api.sh\r\n<\/code><\/pre>\n<\/li>\n<li>cron\u4fdd\u6d3b \u9996\u6b21\u8fd0\u884c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5373\u53ef\n<pre><code>nohup \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/start_ddgchatgo.sh &gt; \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/start_ddgchatgo.log 2&gt;&amp;1 &amp;\r\n<\/code><\/pre>\n<p>\u4f60\u7684Serv00\u7528\u6237\u540d \u6362\u6210\u81ea\u5df1\u7684<br \/>\nexample.com\u00a0\u6362\u6210\u81ea\u5df1\u7684\u57df\u540d<br \/>\nPORT \u5982\u679c\u5f00\u653e\u7684\u7aef\u53e3\u4e0d\u662f5005 \u53ef\u81ea\u884c\u4fee\u6539<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p dir=\"auto\"><a href=\"https:\/\/linux.do\/t\/topic\/235325#p-2133274-h-2\" name=\"p-2133274-h-2\"><\/a><strong>\u4e00\u952e\u5b89\u88c5\u811a\u672c<\/strong><\/p>\n<pre dir=\"auto\"><code>#!\/bin\/bash\r\n# Step 1: \u8fdb\u5165\u5de5\u4f5c\u76ee\u5f55\r\ncd ~\/domains\/example.com\/public_html\/\r\n# Step 2: \u4e0b\u8f7d\u53ef\u6267\u884c\u7a0b\u5e8f\r\nwget https:\/\/github.com\/Shadownc\/DDG-Chat-go\/releases\/download\/v0.0.2\/ddgchatgo-freebsd-amd64\r\n# Step 3: \u8d4b\u4e88\u89e3\u538b\u540efreechatgpt\u6587\u4ef6\u53ef\u6267\u884c\u6743\u9650\r\nchmod +x ddgchatgo-freebsd-amd64\r\n# Step 4: \u521b\u5efastart_ddgchatgo.sh\u811a\u672c\r\ncat &lt;&lt;EOL &gt; start_ddgchatgo.sh\r\n#!\/bin\/bash\r\n# \u5b9a\u4e49\u8fdb\u7a0b\u540d\u79f0\u548c\u542f\u52a8\u547d\u4ee4\r\nPROCESS_NAME=\"ddgchatgo\"\r\nSTART_COMMAND=\"PORT=5005 \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/ddgchatgo-freebsd-amd64 &gt; \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/ddgchatgo.log 2&gt;&amp;1 &amp;\"\r\n# \u68c0\u67e5\u8fdb\u7a0b\u662f\u5426\u5728\u8fd0\u884c\r\nif ! pgrep -f \"\\$PROCESS_NAME\" &gt; \/dev\/null\r\nthen\r\necho \"\u8fdb\u7a0b \\$PROCESS_NAME \u672a\u8fd0\u884c\uff0c\u6b63\u5728\u542f\u52a8...\"\r\n# \u542f\u52a8\u8fdb\u7a0b\r\neval \"\\$START_COMMAND\"\r\nif [ \\$? -eq 0 ]; then\r\necho \"\u8fdb\u7a0b \\$PROCESS_NAME \u542f\u52a8\u6210\u529f\u3002\"\r\nelse\r\necho \"\u8fdb\u7a0b \\$PROCESS_NAME \u542f\u52a8\u5931\u8d25\u3002\"\r\nfi\r\nelse\r\necho \"\u8fdb\u7a0b \\$PROCESS_NAME \u5df2\u7ecf\u5728\u8fd0\u884c\u3002\"\r\nfi\r\nEOL\r\n# Step 5: \u8d4b\u4e88start_ddgchatgo.sh\u53ef\u6267\u884c\u6743\u9650\r\nchmod +x start_ddgchatgo.sh\r\n# Step 6: \u8fd0\u884cstart_ddgchatgo.sh\u811a\u672c\u5e76\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230start_ddgchatgo.log\r\nnohup \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/start_ddgchatgo.sh &gt; \/home\/\u4f60\u7684Serv00\u7528\u6237\u540d\/domains\/example.com\/public_html\/start_ddgchatgo.log 2&gt;&amp;1 &amp;\r\n<\/code><\/pre>\n<p>\u4e00\u952e\u811a\u672c\u4e2d<code>https:\/\/github.com\/Shadownc\/DDG-Chat-go\/releases\/download\/v0.0.2\/ddgchatgo-freebsd-amd64<\/code>\u66ff\u6362\u4e3a<code>https:\/\/github.com\/Shadownc\/DDG-Chat-go\/releases\/download\/v0.0.4\/ddgchatgo-freebsd-amd64<\/code>\u53ef\u8bbe\u7f6eAPI KEY\u3002<\/p>\n<p>\u4f60\u7684Serv00\u7528\u6237\u540d \u6362\u6210\u81ea\u5df1\u7684<br \/>\nexample.com\u00a0\u6362\u6210\u81ea\u5df1\u7684\u57df\u540d<br \/>\nPORT \u5982\u679c\u5f00\u653e\u7684\u7aef\u53e3\u4e0d\u662f5005 \u53ef\u81ea\u884c\u4fee\u6539<\/p>\n<p>&nbsp;<\/p>\n<p>\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u8bbf\u95ee\u57df\u540d\u8fd4\u56de\u4ee5\u4e0b\u5185\u5bb9\u8868\u793a\u6210\u529f\uff1a<\/p>\n<pre>{\r\n\"message\": \"Welcome to the API\"\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p dir=\"auto\"><strong>\u642d\u5efa\u5b8c\u63a5\u5165newapi<\/strong><\/p>\n<p dir=\"auto\">new api\/one api\u9009\u62e9\u81ea\u5b9a\u4e49\u6e20\u9053<br \/>\n<code>http:\/\/chat.xxl.serv00.net\/v1\/chat\/completions<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>DDG-Chat \u662f\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u53ef\u4ee5\u4e00\u952e\u90e8\u7f72\u5230\u591a\u79cd\u5e73\u53f0\u7684 ChatGPT API \u540e\u7aef\u3002\u8be5\u9879\u76ee\u652f\u6301\u591a\u79cd\u6a21\u578b\uff0c\u5305\u62ec GPT-4o mini\u3001Claude 3 Haiku\u3001Llama 3.1 70B \u548c Mixtral 8x7B\uff0c&#8230;<\/p>\n","protected":false},"author":1,"featured_media":61199,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,255],"class_list":["post-8207","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-mianfeidamoxingapi"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/8207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/comments?post=8207"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/8207\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media\/61199"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media?parent=8207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/categories?post=8207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/tags?post=8207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}