在服务器部署 Clewd

Reno 于 2024-11-25 发布

本教程使用的是 clew修改版,修改版支持多账号轮询

环境变量(括号内代表默认值)

配置建议

下面是官方仓库给的配置建议

PreventImperson: true

PromptExperiments: true

RenewAlways: true

PreserveChats: true

PreventImperson: true

PromptExperiments: false

SystemExperiments: true

RenewAlways: false

RetryRegenerate: true

AllSamples: true

安装nvm

博客发布时 nvm 最新版本v0.40.1,可前往nvm官方网站查看最新版本:访问地址

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

查看安装版本,安装成功会返回版本号如0.40.1,如果没能查到,可以重新登陆ssh后尝试查询

node -v

安装node

博客发布时 node 最新版本v23.3.0,可前往nodejs 官方网站查看最新版本:访问地址

nvm install node 23.3.0

查看版本,确保返回 v20.4.0 以上的版本

node -v

安装clewd

git clone https://github.com/teralomaniac/clewd
cd clewd
npm install

配置文件

首次运行 clewd.js 会生成配置文件 config.js

node clewd.js

编辑 config.js,配置了 CookieArrayCookie 参数就不再生效,此时可留空

module.exports = {
    "Cookie": "sessionKey=sk-ant-sid01-******AA",
    "CookieArray": [
        "sessionKey=sk-ant-sid01-******AA",
        "sessionKey=sk-ant-sid01-******AA",
        "sessionKey=sk-ant-sid01-******AA",
    ],
    "WastedCookie": [],
    "unknownModels": [],
    "Cookiecounter": 3,
    "CookieIndex": 0,
    "ProxyPassword": "abcdefg",
    "Ip": "127.0.0.1",
    "Port": 4444,
    "localtunnel": false,
    "BufferSize": 7,
    "SystemInterval": 3,
    "rProxy": "",
    "api_rProxy": "",
    "placeholder_token": "",
    "placeholder_byte": "",
    "PromptExperimentFirst": "",
    "PromptExperimentNext": "",
    "PersonalityFormat": "'s personality: ",
    "ScenarioFormat": "Dialogue scenario: ",
    "Settings": {
        "RenewAlways": true,
        "RetryRegenerate": false,
        "PromptExperiments": true,
        "SystemExperiments": true,
        "PreventImperson": true,
        "AllSamples": false,
        "NoSamples": false,
        "StripAssistant": false,
        "StripHuman": false,
        "PassParams": false,
        "ClearFlags": true,
        "PreserveChats": true,
        "LogMessages": false,
        "FullColon": true,
        "padtxt": "1000,1000,15000",
        "xmlPlot": true,
        "SkipRestricted": false,
        "Artifacts": false,
        "Superfetch": true
    }
}

再次运行clew.js

node clewd.js

请求示例

curl --request POST \
  --url http://localhost:4444/v1/chat/completions \
  --header 'content-type: application/json' \
  --data '{
    "model": "claude-3-5-sonnet-20241022",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Can you explain how OpenAI API works?"
      }
    ],
    "max_tokens": 1000,
    "temperature": 0.7
  }'

参考链接

ahsk/clewd(原版)

teralomaniac/clewd(修改版)