16 Commits

Author SHA1 Message Date
Clivia
1fc6fa7784 支持gpt-4-gizmo-XXX,动态配置GPTS 2024-02-26 14:14:13 +08:00
Clivia
aae4fd64d7 动态适配gpts 2024-02-26 14:08:07 +08:00
Clivia
cd983f0a0c Update main.py 2024-02-26 14:04:04 +08:00
Clivia
76993fcce8 Rename docker-deploy.yml to ninja-image.yml 2024-02-20 01:28:26 +08:00
Clivia
fa645a80d8 Update docker-deploy.yml 2024-02-20 01:27:59 +08:00
Clivia
1e3e233adc 更新KEY_FOR_GPTS_INFO 2024-02-20 01:14:46 +08:00
Clivia
002ff558b0 优化gpts结构 2024-02-19 21:52:50 +08:00
Clivia
6f66431bb5 Update docker-compose.yml 2024-02-17 17:45:57 +08:00
Clivia
d815bf991e Update docker-compose.yml 2024-02-17 17:44:06 +08:00
Clivia
10488aeaa5 修正自定义更新access_token异常 2024-02-17 02:09:20 +08:00
Clivia
97f1c4f45f Update main.py 2024-02-14 21:57:14 +08:00
Clivia
0d0ae4a95a 适配ninja 2024-02-14 21:40:00 +08:00
Clivia
37b0dd7c36 适配ninja 2024-02-14 21:35:48 +08:00
Clivia
4a852bd070 适配ninja 2024-02-14 21:31:50 +08:00
Clivia
0ca230a853 适配ninja 2024-02-14 21:17:40 +08:00
Clivia
6eeadb49ac 修改适配ninja 2024-02-14 21:10:59 +08:00
10 changed files with 1098 additions and 942 deletions

View File

@@ -1,46 +0,0 @@
name: oaifree Build and Push Docker Image
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: 'Tag Name'
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set tag name
id: tag_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
fi
- name: Build and push Docker image with Release tag
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
yangclivia/pandora-to-api:${{ steps.tag_name.outputs.tag }}
platforms: linux/amd64,linux/arm64
build-args: TARGETPLATFORM=${{ matrix.platform }}

View File

@@ -1,46 +0,0 @@
name: xyhelper Build and Push Docker Image
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: 'Tag Name'
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set tag name
id: tag_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
fi
- name: Build and push Docker image with Release tag
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
yangclivia/pandora-to-api:${{ steps.tag_name.outputs.tag }}
platforms: linux/amd64,linux/arm64
build-args: TARGETPLATFORM=${{ matrix.platform }}

2
.gitignore vendored
View File

@@ -1,2 +0,0 @@
*.log

6
.idea/encodings.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/log/access.log" charset="GBK" />
</component>
</project>

View File

@@ -2,24 +2,20 @@
> [!IMPORTANT]
>
> Respect `oaiFree` , Respect `Wizerd`
> Respect Zhile大佬 , Respect Wizerd
感谢oaiFree、Ink-Osier大佬们的付出,敬礼!!!
感谢pandoraNext和Wizerd的付出,敬礼!!!
本项目支持:
1.oaiFree `proxy` 模式下的 `backend-api` 转为 `/v1/chat/completions` 接口,支持流式和非流式响应。
1.ninja `proxy` 模式下的 `backend-api` 转为 `/v1/chat/completions` 接口,支持流式和非流式响应。
2.oaiFree `proxy` 模式下的 `backend-api` 转为 `/v1/images/generations` 接口
2.ninja `proxy` 模式下的 `backend-api` 转为 `/v1/images/generations` 接口
3. 支持直接把refresh_token作为请求key方便接入one_api
4. 支持 gpt-4-mobile 、gpt-4-s 、基本所有的GPTS
* **oaiFree 的 免费 backend-api 接口,无需打码**
* 之后可能跟[Linux.do](https://linux.do/latest)论坛挂钩,请提前做好准备
如果本项目对你有帮助的话,请点个小星星吧~
如果有什么在项目的使用过程中的疑惑或需求,欢迎加入 Community Telegram Channel: [Inker 的魔法世界](https://t.me/InkerWorld) 来和大家一起交流一下~
@@ -38,7 +34,7 @@
- [x] 支持 gpt-3.5-turbo
- [x] 暂不 支持 gpts
- [x] 支持 gpts
- [x] 支持 流式输出
@@ -63,13 +59,13 @@
## 注意
> [!CAUTION]
> 1. 本项目的运行需要 oaiFree 的免费接口
> 1. 本项目的运行需要 ninja
>
> 2. 本项目实际为将来自 `/v1/chat/completions` 的请求转发到oaiFree免费接口的 `/backend-api/conversation` 接口,因此本项目并不支持高并发操作,请不要接入如 `沉浸式翻译` 等高并发项目。
> 2. 本项目实际为将来自 `/v1/chat/completions` 的请求转发到ninja的 `/backend-api/conversation` 接口,因此本项目并不支持高并发操作,请不要接入如 `沉浸式翻译` 等高并发项目。
>
> 3. 本项目支持使用apple平台的refresh_token作为请求key.
>
> 4. 本项目并不能绕过 OpenAI 和 oaiFree 官方的限制,只提供便利,不提供绕过。
> 4. 本项目并不能绕过 OpenAI 和 ninja 官方的限制,只提供便利,不提供绕过。
>
> 5. 提问的艺术:当出现项目不能正常运行时,请携带 `DEBUG` 级别的日志在 `Issue` 或者社区群内提问,否则将开启算命模式~
@@ -81,7 +77,7 @@
2. gpt-4-mobile支持代码解释器、bing联网、dalle绘图的 GPT-4对应的是官方的手机版 GPT-4截止至2023年12月15日本模型使用量不计入 GPT-4 用量(即不受每 3 小时 40 次的限制)
3. 由于oaiFree未提供GPTS接口暂不支持几乎所有的 GPTS配置方式见下文
3. 几乎所有的 GPTS配置方式见下文
4. gpt-3.5-turbo
@@ -95,19 +91,19 @@
- `need_log_to_file`: 用于设置是否需要将日志输出到文件,可选值为:`true``false`,默认为 `true`,日志文件路径为:`./log/access.log`,默认每天会自动分割日志文件。
- `process_workers`: 用于设置进程数,如果不需要设置,可以保持不变,如果需要设置,可以设置为需要设置的值,默认`2`
- `process_workers`: 用于设置进程数,如果不需要设置,可以保持不变,如果需要设置,可以设置为需要设置的值,如果设置`1`,则会强制设置为单进程模式
- `process_threads`: 用于设置线程数,如果不需要设置,可以保持不变,如果需要设置,可以设置为需要设置的值,默认`2`
- `process_threads`: 用于设置线程数,如果不需要设置,可以保持不变,如果需要设置,可以设置为需要设置的值,如果设置`1`,则会强制设置为单线程模式
- `upstream_base_url`: oaiFree 的接口地址,如:`https://chat.oaifree.com`,注意:不要以 `/` 结尾。
- `upstream_base_url`: ninja 的部署地址,如:`https://pandoranext.com`,注意:不要以 `/` 结尾。可以填写为本项目可以访问到的 PandoraNext 的内网地址。
- `upstream_api_prefix`: 默认为["dad04481-fa3f-494e-b90c-b822128073e5"],之后可多填
- `upstream_api_prefix`: PandoraNext Proxy 模式下的 API 前缀
- `backend_container_url`: 用于dalle模型生成图片的时候展示所用需要设置为使用如 [ChatGPT-Next-Web](https://github.com/ChatGPTNextWebTeam/ChatGPT-Next-Web) 的用户可以访问到的本项目地址,如:`http://1.2.3.4:50011`,同原环境变量中的 `UPLOAD_BASE_URL`
- `backend_container_api_prefix`: 用于设置本项目 `/v1/xxx` 接口的前缀如果留空则与官方api调用接口一致。设置示例`666 `
- `key_for_gpts_info(选填)`: 填入refresh_token每天自动转成access_token 推荐或者access_token(不推荐), 仅获取 GPTS 信息的 access_token需要该 access_token 能够访问所有配置的 GPTS。后续发送消息仍需要在请求头携带请求所用的 access_token如果未配置该项请将 `gpts.json` 文件修改为:
- `key_for_gpts_info`: 填入refresh_token每天自动转成access_token 推荐或者access_token(不推荐), 仅获取 GPTS 信息的 access_token需要该 access_token 能够访问所有配置的 GPTS。后续发送消息仍需要在请求头携带请求所用的 access_token如果未配置该项请将 `gpts.json` 文件修改为:
```json
{}
@@ -147,8 +143,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
- `enableOai`:用于设置是否使用官网通过refresh_token刷新access_token仅在 `enableOai``true` 时生效。
- `oaiFree_refreshToAccess_Url`:用于设置使用oaiFree来进行使用refresh_token刷新access_token,enableOai为false的时候必填
- 默认为"https://token.oaifree.com/api/auth/refresh"
- `ninja_refreshToAccess_Url`:用于设置使用ninja来进行使用refresh_token刷新access_token,enableOai为false的时候必填
- `redis`
@@ -187,7 +182,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
请求方式:`POST`
请求头:正常携带 `Authorization``Content-Type` 即可,`Authorization` 的值为 `Bearer <refresh_token>``Content-Type` 的值为 `application/json`
请求头:正常携带 `Authorization``Content-Type` 即可,`Authorization` 的值为 `Bearer <ninja 的 fk>``Content-Type` 的值为 `application/json`
请求体格式示例:
@@ -326,7 +321,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
version: '3'
services:
chatgpt-next-web:
image: yangclivia/chatgpt-next-web-langchain
image: yidadaa/chatgpt-next-web
ports:
- "50013:3000"
environment:
@@ -384,4 +379,4 @@ services:
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=Yanyutin753/oaiFreeV1Api_refresh&type=Date)](https://star-history.com/#Yanyutin753/oaiFreeV1Api_refresh&Date)
[![Star History Chart](https://api.star-history.com/svg?repos=Yanyutin753/ninjaToV1Api_refresh&type=Date)](https://star-history.com/#Yanyutin753/ninjaToV1Api_refresh&Date)

View File

@@ -4,8 +4,8 @@
"process_workers": 2,
"process_threads": 2,
"proxy": "",
"upstream_base_url": "https://chat.oaifree.com",
"upstream_api_prefix": ["dad04481-fa3f-494e-b90c-b822128073e5"],
"upstream_base_url": "",
"upstream_api_prefix": "",
"backend_container_url": "",
"backend_container_api_prefix": "",
"key_for_gpts_info": "",
@@ -26,8 +26,8 @@
},
"refresh_ToAccess": {
"stream_sleep_time": 0,
"enableOai":"false",
"oaifree_refreshToAccess_Url": "https://token.oaifree.com/api/auth/refresh"
"enableOai":"true",
"ninja_refreshToAccess_Url": ""
},
"redis": {
"host": "redis",

View File

@@ -1 +1,5 @@
{}
{
"gpt-4-classic": {
"id":"g-YyyyMT9XH-chatgpt-classic"
}
}

View File

@@ -2,7 +2,7 @@ version: '3'
services:
backend-to-api:
image: yangclivia/pandora-to-api:0.7.9
image: yangclivia/pandora-to-api:0.7.7
restart: always
ports:
- "50011:33333"

1881
main.py

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ if [ -z "$PROCESS_WORKERS" ]; then
export PROCESS_WORKERS
if [ -z "$PROCESS_WORKERS" ]; then
PROCESS_WORKERS=2
PROCESS_WORKERS=1
fi
fi