Giter VIP home page Giter VIP logo

wx-chatgpt's Introduction

如何接入 ChatGPT

  1. 注册 openai 账号,并获取到 apiKey
  2. index.js 文件中,##your api key## 替换成你的 apiKey
  3. push 代码到 master 分支,云托管自动部署后即可运行
  4. 完成之后,记得在微信云托管在后台的「设置-全局设置」中,添加「消息推送」,并增加 path 为 /message/post 的配置。

下面为微信云托管的标准README

GitHub license GitHub package.json dependency version (prod) GitHub package.json dependency version (prod)

微信云托管 Node.js Koa 框架模版,实现简单的计数器读写接口,使用云托管 MySQL 读写、记录计数值。

快速开始

前往 微信云托管快速开始页面,选择相应语言的模板,根据引导完成部署。

本地调试

下载代码在本地调试,请参考微信云托管本地调试指南

实时开发

代码变动时,不需要重新构建和启动容器,即可查看变动后的效果。请参考微信云托管实时开发指南

Dockerfile最佳实践

请参考如何提高项目构建效率

项目结构说明

.
├── Dockerfile
├── README.md
├── container.config.json  
├── db.js
├── index.js
├── index.html
├── package.json
  • index.js:项目入口,实现主要的读写 API
  • db.js:数据库相关实现,使用 sequelize 作为 ORM
  • index.html:首页代码
  • package.json:Node.js 项目定义文件
  • container.config.json:模板部署「服务设置」初始化配置(二开请忽略)
  • Dockerfile:容器配置文件

服务 API 文档

GET /api/count

获取当前计数

请求参数

响应结果

  • code:错误码
  • data:当前计数值
响应结果示例
{
  "code": 0,
  "data": 42
}

调用示例

curl https://<云托管服务域名>/api/count

POST /api/count

更新计数,自增或者清零

请求参数

  • actionstring 类型,枚举值
    • 等于 "inc" 时,表示计数加一
    • 等于 "clear" 时,表示计数重置(清零)
请求参数示例
{
  "action": "inc"
}

响应结果

  • code:错误码
  • data:当前计数值
响应结果示例
{
  "code": 0,
  "data": 42
}

调用示例

curl -X POST -H 'content-type: application/json' -d '{"action": "inc"}' https://<云托管服务域名>/api/count

使用注意

如果不是通过微信云托管控制台部署模板代码,而是自行复制/下载模板代码后,手动新建一个服务并部署,需要在「服务设置」中补全以下环境变量,才可正常使用,否则会引发无法连接数据库,进而导致部署失败。

  • MYSQL_ADDRESS
  • MYSQL_PASSWORD
  • MYSQL_USERNAME 以上三个变量的值请按实际情况填写。如果使用云托管内MySQL,可以在控制台MySQL页面获取相关信息。

License

MIT

wx-chatgpt's People

Contributors

wuomzfx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

wx-chatgpt's Issues

API被墙

API目前被墙了,请问我需要修改哪些部分来调用我自建的API?非常感谢

一直回复正在编,openai的api次数一直没使用

我按照您的教程完整部署了一遍,只修改了api的key,改了下AI_THINKING_MESSAGE和LIMIT_COUNT_RESPONSE提示的文字描述。其余都没做变更。部署和发布也是正常完成的。但是在公众号上测试的时候一直回复AI_THINKING_MESSAGE的提示消息,看了下openai的api,次数也是一直未使用。还请大大有时间解惑下~

无法使用,请求时401 请求超时

02/28 16:56:53
koa-6y37-016
<-- POST /message/post
02/28 16:56:54
koa-6y37-016
at processTicksAndRejections (internal/process/task_queues.js:82:21)
02/28 16:56:54
koa-6y37-016
at endReadableNT (internal/streams/readable.js:1333:12)
02/28 16:56:54
koa-6y37-016
at IncomingMessage.emit (events.js:412:35)
02/28 16:56:54
koa-6y37-016
at IncomingMessage.handleStreamEnd (/app/node_modules/axios/lib/adapters/http.js:322:11)
02/28 16:56:54
koa-6y37-016
at settle (/app/node_modules/axios/lib/core/settle.js:17:12)
02/28 16:56:54
koa-6y37-016
at createError (/app/node_modules/axios/lib/core/createError.js:16:15)
02/28 16:56:54
koa-6y37-016
Error: Request failed with status code 401
02/28 16:56:54
koa-6y37-016
xxx POST /message/post 500 666ms -

同上个问题

对了,我还将仓库私有化了,这个有影响吗

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.