Skip to content

Commit

Permalink
chore: Update docs and env
Browse files Browse the repository at this point in the history
  • Loading branch information
KenyonY committed Jan 12, 2024
1 parent 92e983a commit ae3c479
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 42 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
53 changes: 36 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
- 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
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


<a>
Expand Down Expand Up @@ -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) 文件。(待完善)

Expand Down
8 changes: 6 additions & 2 deletions deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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部署
Expand Down
16 changes: 0 additions & 16 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ae3c479

Please sign in to comment.