-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
133 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 配置文件 | ||
|
||
配置文件位于`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/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# Free One API 中文文档 | ||
# Free One API 中文文档 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 安装 | ||
|
||
## 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/` 打开管理页面。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 用法 | ||
|
||
1. 创建一个 channel,填写名称。 | ||
|
||
![add_channel](assets/add_channel.png) | ||
|
||
2. 选择此渠道使用的逆向工程库适配器,填写配置。 | ||
|
||
> 请参考[适配器](/zh-CN/Adapters.md)文档。 | ||
3. 在 API Key 栏中创建一个新的 key。 | ||
|
||
4. 将 url (e.g. http://localhost:3000/v1 ) 设置为 OpenAI 的 api_base ,将生成的 key 设置为 OpenAI api key。 | ||
5. 现在你可以使用 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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
* [首页](/zh-CN/) | ||
* [适配器](/zh-CN/Adapters) | ||
* [部署](/zh-CN/Setup) | ||
* [使用](/zh-CN/Usage) | ||
* [适配器](/zh-CN/Adapters) | ||
* [配置文件](/zh-CN/Config) |
File renamed without changes