Code Monkey home page Code Monkey logo

chatgpt-web's Introduction

chatgpt-web

Pure Javascript ChatGPT demo based on nginx with OpenAI API (gpt-3.5-turbo)

纯JS实现的ChatGPT项目,基于nginx和OpenAI gpt-3.5-turbo API.

部署一个HTML文件,配合nginx反代即可使用。

支持复制,刷新,语音输入,朗读等功能,以及众多自定义选项

参考项目: markdown-it, highlight.js, github-markdown-css, chatgpt-html, markdown-it-copy, markdown-it-texmath, awesome-chatgpt-prompts-zh

示例

Demo

在线预览 (使用需配置自定义API key,可正常访问api.openai.com

使用方法

注意:反代服务器需要正常访问api.openai.com

  1. 配合nginx反代使用, 示例配置如下
#开启openai接口的gzip压缩,大量重复文本的压缩率高,节省服务端流量
gzip  on;
gzip_min_length 1k;
gzip_types text/event-stream;

#如需部署在网站子路径,如/chatgpt,配置如下
#location ^~ /chatgpt/v1 {
location ^~ /v1 {
    proxy_pass https://api.openai.com/v1;
    proxy_set_header Host api.openai.com;
    #如需用户自定义API key,可注释掉下一行配置
    proxy_set_header  Authorization "Bearer 替换为API KEY";
    proxy_pass_header Authorization;
    #流式传输,不关闭buffering缓存会卡顿卡死,必须配置!!!
    proxy_buffering off;
}
#与上面反代接口的路径保持一致
#location /chatgpt {
location / {
    alias /usr/share/nginx/html/;
    index index.html;
}

如果服务器无法正常访问api.openai.com, 可配合socat反代和http代理使用,proxy_pass配置改成

    proxy_pass https://127.0.0.1:8443/v1;

并打开socat

socat TCP4-LISTEN:8443,reuseaddr,fork PROXY:http代理地址:api.openai.com:443,proxyport=http代理端口
  1. 配合Caddy使用,可以自动生产HTTPS证书
yourdomain.example.com {
	reverse_proxy /v1/* https://api.openai.com {
		header_up Host api.openai.com
		header_up Authorization "{http.request.header.Authorization}"
		header_up Authorization "Bearer sk-your-token"
	}

	file_server / {
		root /var/wwwroot/chatgpt-web
		index index.html
	}
}

自定义选项

  1. 可选API key,默认不设置,如需使用,建议Nginx一定要配置https,公网以http方式明文传输API key极易被中间人截获。

  2. 可选系统角色,默认不开启,有三个预设角色,并动态加载awesome-chatgpt-prompts-zh中的角色。

  3. 可选角色性格,默认灵活创新,对应接口文档的top_p参数。

  4. 可选回答质量,默认平衡,对应接口文档的temperature参数。

  5. 修改打字机速度,默认较快,值越大速度越快。

  6. 允许连续对话,默认开启,对话中包含上下文信息,会导致api费用增加。

  7. 允许长回复,默认关闭,开启后可能导致api费用增加,并丢失大部分上下文,对于一些要发送继续才完整的回复,不用发继续了。

  8. 选择语音,默认Bing语音,不可用则使用本地语音,可分开设置提问语音和回答语音。

  9. 音量,默认最大。

  10. 语速,默认正常。

  11. 音调,默认正常。

  12. 允许连续朗读,默认开启,连续郎读到所有对话结束。

  13. 允许自动朗读,默认关闭,自动朗读新的回答。

  14. 支持语音输入,默认识别为普通话,可长按修改语音识别选项。如浏览器不支持语音输入,则不显示语音按钮(HTTPS+Edge浏览器体验最佳)。如点击语音按钮没反应,则未允许麦克风权限,或者没安装麦克风设备。

chatgpt-web's People

Contributors

evlon avatar xqdoo00o avatar

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.