diff --git a/.env.example b/.env.example index 97b68f3..91f6e1a 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,9 @@ LOG_CHAT=true CACHE_CHAT_COMPLETION=true # `CACHE_BACKEND`: Options (MEMORY, LMDB, LevelDB) -CACHE_BACKEND=LMDB +CACHE_BACKEND=LevelDB +CACHE_ROOT_PATH_OR_URL=./FLAXKV_DB +DEFAULT_REQUEST_CACHING_VALUE=false BENCHMARK_MODE=true diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index e9187dc..2299792 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -10,22 +10,41 @@ on: jobs: - deploy: + release-build: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine build hatch - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python -m build - twine upload dist/* \ No newline at end of file + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: build release distributions + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine build hatch + python -m build + + - name: upload dists + uses: actions/upload-artifact@v3 + with: + name: release-dists + path: dist/ + + pypi-publish: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + id-token: write + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v3 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/README.md b/README.md index b927139..a25db85 100644 --- a/README.md +++ b/README.md @@ -196,15 +196,19 @@ curl --location 'https://api.openai-forward.com/v1/images/generations' \ ### 代理其它云端模型 -- **适用场景:** - 例如可通过 [LiteLLM](https://github.com/BerriAI/litellm) 可以将 众多云模型的 API 格式转换为 openai - 的api格式, - 然后使用本服务进行代理。 +- **场景1:** + 使用通用转发,由环境变量中`EXTRA_BASE_URL`与`EXTRA_ROUTE_PREFIX` 两变量控制,可对任意来源服务进行转发, + 可获得请求速率控制与token速率控制;但通用转发不支持自定义秘钥、实时日志和缓存AI响应. + +- **场景2:** + 可通过 [LiteLLM](https://github.com/BerriAI/litellm) 可以将 众多云模型的 API 格式转换为 openai + 的api格式,然后使用openai风格转发(即`OPENAI_BASE_URL`) + (更多) ### 代理ChatGPT -参考根路径下 `docker-compose.yaml` 和 `.env.chatgpt` +[参考](./deploy.md) @@ -248,6 +252,7 @@ curl --location 'https://api.openai-forward.com/v1/images/generations' \ | LOG_CHAT | 开关聊天内容的日志记录,用于调试和监控 | `false` | | CACHE_BACKEND | cache后端,支持内存后端和数据库后端,默认为内存后端,可选lmdb、leveldb数据库后端 | `lmdb` | | CACHE_CHAT_COMPLETION | 是否缓存/v1/chat/completions 结果 | `false` | +| DEFAULT_REQUEST_CACHING_VALUE | 是否默认开启缓存 | `false` | 详细配置说明可参见 [.env.example](.env.example) 文件。(待完善) diff --git a/deploy.md b/deploy.md index a27ce51..66e6e90 100644 --- a/deploy.md +++ b/deploy.md @@ -25,8 +25,12 @@ **一键免费云平台部署** 1. [Render一键部署](deploy.md#render-一键部署) -2. [CloudFlare AI Gateway](https://developers.cloudflare.com/ai-gateway/get-started/creating-gateway/) -3. 更多部署: https://github.com/KenyonY/openai-forward/blob/0.5.x/deploy.md +2. 更多部署: https://github.com/KenyonY/openai-forward/blob/0.5.x/deploy.md + +**其它反代** +[CloudFlare AI Gateway](https://developers.cloudflare.com/ai-gateway/get-started/creating-gateway/) +[ChatGPT](https://github.com/pandora-next/deploy) + --- ## pip部署 diff --git a/docker-compose.yaml b/docker-compose.yaml index 51d74d9..d8c7483 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,19 +17,3 @@ services: restart: unless-stopped depends_on: - chatgpt - - chatgpt: - # use project: https://github.com/gngpp/ninja - image: ghcr.io/gngpp/ninja:latest - container_name: chatgpt - restart: unless-stopped - environment: - - TZ=Asia/Shanghai - command: - - run - - --arkose-gpt4-har-dir=/root/.gpt4 -# - --level=debug - volumes: - - ./har:/root/.gpt4 -# ports: -# - "7999:7999" diff --git a/pyproject.toml b/pyproject.toml index d865943..7d3c380 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "pytz", "slowapi==0.1.8", "aiohttp>=3.8.5", - "flaxkv[client]>=0.2.2", + "flaxkv[client]>=0.2.4", "msgpack", "tiktoken>=0.5.1", "tomli",