Skip to content

Commit

Permalink
Merge pull request #41 from RockChinQ/doc/docsify
Browse files Browse the repository at this point in the history
Doc: migrate docs to docsify
  • Loading branch information
RockChinQ authored Oct 16, 2023
2 parents a8b743f + 0f8cb73 commit 1582349
Show file tree
Hide file tree
Showing 30 changed files with 631 additions and 329 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build-docsify-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Docsify Image

on:
push:
branches:
- main
- doc/docsify
path:
- "docs/**"
workflow_dispatch:
defaults:
run:
shell: bash
working-directory: docs
jobs:
publish-docsify-docker-image:
runs-on: ubuntu-latest
name: Build and publish docker image

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build image
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/free-one-api.docs:latest .
- name: Publish image
run: |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/free-one-api.docs:latest
164 changes: 4 additions & 160 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,165 +46,9 @@

</details>

### 支持的 LLM 库
## 文档

|Adapter|Multi Round|Stream|Function Call|Status|Comment|
|---|---|---|---|---|---|
|[acheong08/ChatGPT](https://github.com/acheong08/ChatGPT)|||||ChatGPT 网页版|
|[KoushikNavuluri/Claude-API](https://github.com/KoushikNavuluri/Claude-API)|||||Claude 网页版|
|[dsdanielpark/Bard-API](https://github.com/dsdanielpark/Bard-API)|||||Google Bard 网页版|
|[xtekky/gpt4free](https://github.com/xtekky/gpt4free)|||||gpt4free 接入多个平台的破解|
|[Soulter/hugging-chat-api](https://github.com/Soulter/hugging-chat-api)|||||huggingface的对话模型|
|[xw5xr6/revTongYi](https://github.com/xw5xr6/revTongYi)|||||阿里云通义千问网页版|
部署、配置方式请参考文档:

### 支持的 API 路径

- `/v1/chat/completions`

欢迎提交 issue 或 pull request 来添加更多的 LLM 库和 API 路径支持。

## 部署

### Docker (推荐)

```bash
docker run -d -p 3000:3000 --restart always --name free-one-api -v ~/free-one-api/data:/app/data rockchin/free-one-api
```

此语句将启动 free-one-api 并指定 `~/free-one-api/data` 为容器的文件存储映射目录。
你可以在 `http://localhost:3000/` 打开管理页面。

### 手动

```bash
git clone https://github.com/RockChinQ/free-one-api.git
cd free-one-api

cd web && npm install && npm run build && cd ..

pip install -r requirements.txt
python main.py
```

你可以在 `http://localhost:3000/` 打开管理页面。

## 用法

1. 创建一个 channel,按照说明填写配置,然后创建一个新的 key。

<img width="400" alt="image" src="assets/add_channel.png">

2. 将 url (e.g. http://localhost:3000/v1 ) 设置为 OpenAI 的 api_base ,将生成的 key 设置为 OpenAI api key。
3. 现在你可以使用 OpenAI API 来访问逆向工程的 LLM 库了。

```curl
# curl example
curl http://localhost:3000/v1/chat/completions \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
"stream": true
}'
```

```python
# python example
import openai

openai.api_base = "http://localhost:3000/v1"
openai.api_key = "generated key"

response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "hello, how are you?"
}
],
stream=False,
)

print(response)
```

### 配置文件

配置文件位于`data/config.yaml`

```yaml
database:
# SQLite 数据库文件路径
path: ./data/free_one_api.db
type: sqlite
logging:
debug: false # 是否开启调试日志
misc:
# acheong08/ChatGPT 适配器的反向代理路径
# 默认的公共反代可能不稳定,建议自行搭建:
# https://github.com/acheong08/ChatGPT-Proxy-V4
chatgpt_api_base: https://chatproxy.rockchin.top/api/
# 随机广告
# 会随机追加到每个响应的末尾
random_ad:
# 广告列表
ad_list:
- ' (This response is sponsored by Free One API. Consider star the project on GitHub:
https://github.com/RockChinQ/free-one-api )'
# 是否开启随机广告
enabled: false
# 广告出现概率 (0-1)
rate: 0.05
router:
# 后端监听端口
port: 3000
# 管理页登录密码
token: '12345678'
watchdog:
heartbeat:
# 自动停用渠道前的心跳失败次数
fail_limit: 3
# 心跳检测间隔(秒)
interval: 1800
# 单个渠道心跳检测超时时间(秒)
timeout: 300
web:
# 前端页面路径
frontend_path: ./web/dist/
```
## 快速体验
### Demo
可以登录并修改通道和key数据,每30分钟重置(xx:00/xx:30).
地址:https://foa-demo.rockchin.top
密码:12345678
### 测试通道
仅可使用通道,不可登录:
api_base: https://foa.rockchin.top/v1
api_key: sk-foaDfZxzvfrwfqkBDJEMq7C0rdXkhOjXx4aM23pH42tv8SJ4
model: gpt-3.5-turbo
## 负载均衡性能
启用4个通道,客户端16个线程的请求时间甘特图,请求提问“write a quick sort in Java”:
(通道标记为 `Channel ID <id> <request count>`, X 轴为时间秒数, 每个色块为一次请求)

<img width="750" alt="image" src="assets/load_balance.png">
- GitHub Page: https://rockchinq.github.io/free-one-api
- 自部署文档:https://free-one-api.rockchin.top
163 changes: 4 additions & 159 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,164 +46,9 @@ Access all reverse engineered LLM libs by standard OpenAI API format.

</details>

### Supported LLM libs
## Documentation

|Adapter|Multi Round|Stream|Function Call|Status|Comment|
|---|---|---|---|---|---|
|[acheong08/ChatGPT](https://github.com/acheong08/ChatGPT)|||||ChatGPT Web Version|
|[KoushikNavuluri/Claude-API](https://github.com/KoushikNavuluri/Claude-API)|||||Claude Web Version|
|[dsdanielpark/Bard-API](https://github.com/dsdanielpark/Bard-API)|||||Google Bard Web Version|
|[xtekky/gpt4free](https://github.com/xtekky/gpt4free)|||||gpt4free cracked multiple platforms|
|[Soulter/hugging-chat-api](https://github.com/Soulter/hugging-chat-api)|||||hubbingface chat model|
|[xw5xr6/revTongYi](https://github.com/xw5xr6/revTongYi)|||||Aliyun TongYi QianWen Web Version|
Please refer to the documentation for deployment and configuration:

### Supported API paths

- `/v1/chat/completions`

File a issue or pull request if you want to add more.

## Setup

### Docker (Recommended)

```bash
docker run -d -p 3000:3000 --restart always --name free-one-api -v ~/free-one-api/data:/app/data rockchin/free-one-api
```

This command will start free-one-api and specify `~/free-one-api/data` as the container's file storage mapping directory.
Then you can open the admin page at `http://localhost:3000/`.

### Manual

```bash
git clone https://github.com/RockChinQ/free-one-api.git
cd free-one-api

cd web && npm install && npm run build && cd ..

pip install -r requirements.txt
python main.py
```

then you can open the admin page at `http://localhost:3000/`.

## Usage

1. Create channel on the admin page, create a new key.

<img width="400" alt="image" src="assets/add_channel.png">

2. Set the url (e.g. http://localhost:3000/v1 ) as OpenAI endpoint, and set the generated key as OpenAI api key.
3. Then you can use the OpenAI API to access the reverse engineered LLM lib.

```curl
# curl example
curl http://localhost:3000/v1/chat/completions \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
"stream": true
}'
```

```python
# python example
import openai

openai.api_base = "http://localhost:3000/v1"
openai.api_key = "generated key"

response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "hello, how are you?"
}
],
stream=False,
)

print(response)
```

### Configurations

Configuration file is saved at `data/config.yaml`

```yaml
database:
# SQLite DB file path
path: ./data/free_one_api.db
type: sqlite
logging:
debug: false # Enable debug log
misc:
# Reverse proxy address for acheong08/ChatGPT adapter.
# Default public reverse proxy may be unstable, it is recommended to build your own:
# https://github.com/acheong08/ChatGPT-Proxy-V4
chatgpt_api_base: https://chatproxy.rockchin.top/api/
# Random advertisement, will be appended to the end of each response
random_ad:
# advertisement list
ad_list:
- ' (This response is sponsored by Free One API. Consider star the project on GitHub:
https://github.com/RockChinQ/free-one-api )'
# Enable random ad
enabled: false
# Random ad rate
rate: 0.05
router:
# Backend listen port
port: 3000
# Admin page login password
token: '12345678'
watchdog:
heartbeat:
# Max fail times
fail_limit: 3
# Heartbeat check interval (seconds)
interval: 1800
# Single channel heartbeat check timeout (seconds)
timeout: 300
web:
# Frontend page path
frontend_path: ./web/dist/
```
## Quick Test
### Demo
Allow to login and modify the channel/apikey settings.Reset every 30 minutes(xx:00/xx:30).
Address: https://foa-demo.rockchin.top
Password: 12345678
### Test channel
Can only use the channel, can't login:
api_base: https://foa.rockchin.top/v1
api_key: sk-foaDfZxzvfrwfqkBDJEMq7C0rdXkhOjXx4aM23pH42tv8SJ4
model: gpt-3.5-turbo
## Performance
Gantt chart of request time with 4 channel enabled and 16 threads in client side, querying question "write a quick sort in Java":
(Channel labelled with `Channel ID <id> <request count>`, X axis is time in seconds)

<img width="750" alt="image" src="assets/load_balance.png">
- GitHub Page: https://rockchinq.github.io/free-one-api
- Self-deployment documentation: https://free-one-api.rockchin.top
9 changes: 8 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Free One API

[中文](/zh-CN/README.md) | [English](/en/README.md)
Welcome to the Free One API project, which is a free and open source project that provides a unified API for all reverse engineered LLM libs.

欢迎访问 Free One API 项目,这是一个免费开源的项目,提供了一个统一的 API,用于访问所有逆向工程的 LLM 库。

# 语言 Language

* [中文](/zh-CN/README.md)
* [English](/en/README.md)
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* [中文文档](/zh-CN/)
* [English](/en/)
Loading

0 comments on commit 1582349

Please sign in to comment.