# chatgptProxy **Repository Path**: TianYuanDiKe_admin/chatgptProxy ## Basic Information - **Project Name**: chatgptProxy - **Description**: 灵感来自wechat-chatgpt, 本项目将wechat部分替换为了http接口的形式。最终达到能通过http接口的形式访问chatGpt - **Primary Language**: NodeJS - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2023-02-28 - **Last Updated**: 2023-04-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## chatGPT proxy 将chatGpt的服务暴露为http接口。 ## 使用 #### 阻塞式接口 本接口会等chatgpt将所有请求处理完后,再进行返回 ``` curl --location 'http://127.0.0.1:8081/v2/message' \ --header 'Content-Type: application/json' \ --data '{ "message": "给黑猫起个名字" }' ``` #### 流式接口 调用代码如下,JavaScript: ``` const source = new EventSource('http://127.0.0.1:8081/v2/stream/example?message=给黑猫起个名字'); source.onopen = () => console.log("Connected"); source.onerror = console.error; source.onmessage = change; ``` 项目提供了测试页面,src/test/index.html

Example usage

#### 部署 - 首先要具有node环境,最好是18.14.0的版本 - 在项目下执行,npm install - 将src/test/koa_sse_stream.d.ts复制到 node_modules/koa-sse-stream目录下 - 项目目录下创建config.yaml文件, 这是配置文件,内容如下: ``` chatGPTAccountPool: - email: "" # 这是chatgpt的账号 password: "" # 这是chatgpt的密码 isGoogleLogin: false chatPrivateTiggerKeyword: "" openAIProxy: "" debug: true # chatGptApi 的日志级别 ``` - 执行 `node run dev` 即可