AI prompts
base on free chat gpt api # [free-gpt3.5-2api](https://github.com/aurorax-neo/free-gpt3.5-2api)
## 一、支持
#### 1.支持免登录chat2api
#### 2.支持账号chat2api(Authorization Bearer eyJhbGciOiJSUz***)
#### 3.支持账号ACCESS_TOKEN(Authorization Bearer ac-***)
## 二、配置
#### 环境变量
```
LOG_LEVEL=info # debug, info, warn, error
LOG_PATH= # 日志文件路径,默认为空(不生成日志文件)
BIND=0.0.0.0 # 127.0.0.1
PORT=3040
TOKENS_FILE= # 账号token文件,默认 tokens.yml
PROXY= # http://127.0.0.1:7890,http://127.0.0.1:7890 已支持多个代理(英文 "," 分隔)
AUTHORIZATIONS= # abc,bac (英文 "," 分隔) 注:必须
BASE_URL= # 默认:https://chatgpt.com
```
###### 也可使用与程序同目录下 `.env` 文件配置上述字段
- ##### 若要使用TOKENS_FILE内的账号,AUTHORIZATIONS字段内必须配置`ac-`开头的AUTHORIZATION并使用ac-***调用本程序,若ACCESS_TOKENS无可用账号则返回401错误,`tokens.yml`详见`tokens.template.yml`
- ##### `AUTHORIZATIONS `功能(access_token):防止使用求头access_token的API接口被刷,使用方式 `access_token#{abc}` ,{abc}替换为 `AUTHORIZATIONS` 内的任意一项
## 三、部署
### 1.docker部署
##### 1 .创建文件夹
```
mkdir -p $PWD/free-gpt3.5-2api
```
##### 2.拉取镜像启动
```
docker run -itd --name=free-gpt3.5-2api -e AUTHORIZATIONS=abc,bac -p 9846:3040 ghcr.io/aurorax-neo/free-gpt3.5-2api
```
###### 注意:-e AUTHORIZATIONS=abc,bac 请自行修改,避免接口被刷
##### 3.更新容器
```
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -cR free-gpt3.5-2api --debug
```
### 2.docker-compose部署
##### 1.快速启动
###### 把本仓库根目录的compose.yaml文件下载到你的电脑(最好为它建立一个free-gpt3.5-2api文件夹,放在文件夹里,这样防止多个compose文件冲突),在compose.yaml目录下运行如下命令
```
docker compose up -d
```
##### 2.更新容器
```
docker compose pull
docker compose up -d
```
##### 3.配置文件说明
```
services:
free-gpt3.5-2api:
container_name: free-gpt3.5-2api #这里写你想起的容器名称
image: ghcr.io/aurorax-neo/free-gpt3.5-2api
ports:
- 7846:3040 #docker默认不经过ufw和firewall,如果想要不暴露端口到外网,在端口前加127.0.0.1,像这样 127.0.0.1:7846:3040
#7846:3040 前面是主机端口,可以自定义,后面是容器端口不要修改
restart: unless-stopped #容器停止和启动须经过手动操作,不会随docker自启
environment:
- AUTHORIZATIONS=abc,bac #注意:“=”后的内容请自行修改,避免接口被刷
```
######
### 3.Vercel部署
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/aurorax-neo/free-gpt3.5-2api&project-name=free-gpt3.5-2api&repository-name=free-gpt3.5-2api)
### 4.Koyeb部署
###### 注意:`Regions`请选择支持`openai`免登的区域!!!现原生ip已不支持免登,请配置代理使用!!!
[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=docker&name=free-gpt3-5-2api®ion=par&ports=3040;http;/&image=ghcr.io/aurorax-neo/free-gpt3.5-2api)
## 四、接口
#### 1./v1/accTokens
`Authorization`使用 `AUTHORIZATIONS`其中任意一个
```
curl --location --request GET 'http://127.0.0.1:9846/v1/accTokens' \
--header 'Authorization: Bearer abc'
```
返回示例说明:`count`为ACCESS_TOKEN池中可用授权数
```
{
"count": 1,
"canUseCount": 1
}
```
#### 2./v1/chat/completions
###### 支持返回stream和json
```
http://<ip>:<port>/v1/chat/completions
```
##### 示例
```
curl http://127.0.0.1:9846
```
```
curl --location --request POST 'http://127.0.0.1:9846/v1/chat/completions' \
--header 'Authorization: Bearer abc' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "西红柿炒钢丝球怎么做?"
}
],
"stream": false
}'
```
## 五、模型映射
```
"gpt-3.5-turbo": "text-davinci-002-render-sha",
"gpt-3.5-turbo-16k": "text-davinci-002-render-sha",
"gpt-3.5-turbo-16k-0613": "text-davinci-002-render-sha",
"gpt-3.5-turbo-0301": "text-davinci-002-render-sha",
"gpt-3.5-turbo-0613": "text-davinci-002-render-sha",
"gpt-3.5-turbo-1106": "text-davinci-002-render-sha",
"gpt-4o": "gpt-4o",
"auto": "auto",
"gpt-4o-av": "gpt-4o-av",
```
## 参考项目
- https://github.com/aurora-develop/aurora
- https://github.com/xqdoo00o/ChatGPT-to-API
", Assign "at most 3 tags" to the expected json: {"id":"9537","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"