Skip to content

Commit

Permalink
docs: update en docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Oct 16, 2023
1 parent 4480f79 commit 0f8cb73
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 160 deletions.
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
115 changes: 115 additions & 0 deletions docs/en/Adapters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Adapters

Free One API currently supports multiple LLM reverse engineering libraries, each channel supports a corresponding adapter, the adapter is responsible for converting the client's request into a reverse engineering library request, and converting the reverse engineering library's response into the client's response.

## acheong08/ChatGPT

ChatGPT official website reverse engineering library

### Configuration

1. Select `acheong08/ChatGPT` as `Adapter`

![select adapter](assets/select_adapter.png)

2. Go to `chat.openai.com` and log in to your account

3. Access `https://chat.openai.com/api/auth/session` directly in the browser, copy the `access_token` obtained

![Alt text](assets/get_actoken.png)

4. Enter in the `Config` column

```json
{
"access_token": "your access token"
}
```

5. Save to test

### Reverse proxy

ChatGPT needs to use a reverse proxy to bypass Cloudflare's restrictions. The Free One API project defaults to the proxy address provided by the developer `https://chatproxy.rockchin.top/api/`, but the pressure is very high. It is strongly recommended to build a reverse proxy by yourself.

* Please configure according to this project document: <https://github.com/acheong08/ChatGPT-Proxy-V4>

Edit `misc.chatgpt_api_base` to your reverse proxy address in `data/config.yaml`.
You can also enter directly in the `Config` column when creating the `acheong08/ChatGPT` adapter

```json
{
"reverse_proxy": "your reverse proxy address"
}
```

If not set, the `misc.chatgpt_api_base` field in the configuration file will be used as the reverse proxy address.

## KoushikNavuluri/Claude-API

Anthropic Claude official website reverse engineering library

### Configuration

1. Select `KoushikNavuluri/Claude-API` as `Adapter`

2. Log in to `claude.ai`, open `F12`, select the `Network` column, find any request, and copy the `Cookie` string in the request header

![claude_get_cookie](assets/claude_cookie.png)

3. Enter in the `Config` column

```json
{
"cookie": "your cookie"
}
```

## xtekky/gpt4free

xtekky/gpt4free integrates multiple LLM reverse engineering libraries of multiple platforms

### Configuration

1. Select `xtekky/gpt4free` as `Adapter`

2. No authentication required, just save

## Soulter/hugging-chat-api

huggingface.co/chat official website reverse engineering library

### Configuration

1. Register `HuggingFace` account

2. Select `Soulter/hugging-chat-api` as `Adapter`

3. Enter in the `Config` column

```json
{
"email": "HuggingFace Email",
"passwd": "HuggingFace Password"
}
```

## xw5xr6/revTongYi

Aliyun TongYi QianWen official website reverse engineering library

### Configuration

1. Select `xw5xr6/revTongYi` as `Adapter`

2. Go to <https://qianwen.aliyun.com/> and log in to your account

3. Refer to the configuration method of Claude above to obtain the `Cookie` string

4. Enter in the `Config` column

```json
{
"cookie": "通义千问cookie"
}
```
43 changes: 43 additions & 0 deletions docs/en/Config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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/
```
17 changes: 17 additions & 0 deletions docs/en/Demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# 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
24 changes: 23 additions & 1 deletion docs/en/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# Free One API Documentation

WIP
## Supported LLM libs

|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|

## Supported API paths

- `/v1/chat/completions`

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

## 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)

![Load Balance](assets/load_balance.png)
Loading

0 comments on commit 0f8cb73

Please sign in to comment.