Giter VIP home page Giter VIP logo

chatgpt-vercel's Introduction

ChatGPT-API Vercel

diu8081/chatgpt-demo 进行功能上的增强。

预览: https://vercel-chatgpt-github.vercel.app

部署一个你自己的(免费)

本项目主要面向中文用户,所以用中文,原版是英文的。

如果你只需要部署一个你自己用的网站,而不需要定制,那么你完全不需要在本地跑起来,你可以直接点击下面的按钮,然后按照提示操作即可。 Vercel 域名已经被墙,所以你需要绑定自己的域名才行。

Deploy with Vercel

如果你需要部署给更多人用,那么你可能需要将上面创建的你自己的仓库 git clone 到本地。

  1. .env.example 文件修改为 .env,然后在里面填入你的 OpenAI API key。如果用户不填自己的 key,那么就会使用你的 key。

    OPENAI_API_KEY=sk-xxx...
    // 你可以填写多个,用 | 分隔,随机调用。最好是多填几个,不太清楚有没有并发上的限制。
    OPENAI_API_KEY=sk-xxx|sk-yyy
    
  2. 默认设置在 这里,自行修改。目前已经移除了一些之前的默认设置,比如默认添加 系统角色指令,默认关闭 开启连续对话

    const defaultSetting = {
        // 连续对话,每次都需要将上下文传给 API,比较费钱,而且同样有 4096 token 的限制
        continuousDialogue: true,
        // 记录对话内容,刷新后不会清空对话
        archiveSession: false,
        openaiAPIKey: "",
        // 0-100 越高 ChatGPT 思维就越发散,开始乱答
        openaiAPITemperature: 60,
        // 系统角色指令,会在每次提问时添加到开头。主要用于对 ChatGPT 的语气,口头禅这些进行定制。
        systemRule: ""
    }
  3. 之前版本我设置了每次刷新重置 开启连续对话 选项,因为一般用不上这个,比较费钱。当前版本我已经移除了这个特性,如果你需要给更多人用,建议打开,只要将 这行代码 取消注释即可。

  4. git commit & push 即可重新部署,vscode 上点几下就可以了。

如果你需要在本地开发和调试,有点麻烦

  1. 升级到 node18,要用到原生的 fetch
  2. API 被墙了,自己想办法开代理,不然要报错。
  3. pnpm i 安装依赖。
  4. pnpm dev 启动项目。

API

POST /api

await fetch("/api", {
    method: "POST",
    body: JSON.stringify({
        message: "xxx",
        key: "xxxx"
    })
})

License

MIT

chatgpt-vercel's People

Contributors

awarewen avatar

Stargazers

 avatar  avatar

Forkers

mmtrucefacts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.