感谢论坛里的大佬提供的api地址,结合自己个人的一些使用习惯,写了以下脚本
#!/bin/bash
# 获取新的 access_token
new_access_token=$(curl -s -X POST "https://auth0.openai.com/oauth/token" \
-H "Content-Type: application/json" \
-d '{
"redirect_uri": "com.openai.chat://auth0.openai.com/ios/com.openai.chat/callback",
"grant_type": "refresh_token",
"client_id": "pdlLIX2Y72MIl2rhLhTE9VV9bN905kBh",
"refresh_token": "{你自己的refresh_token}"
}' | jq -r '.access_token')
# 替换 docker-compose.yml 中的 PANDORA_ACCESS_TOKEN
sed -i "s/PANDORA_ACCESS_TOKEN=.*/PANDORA_ACCESS_TOKEN=$new_access_token/" docker-compose.yml
# 重启容器
docker-compose down && docker-compose up -d
docker-compose文件内容
version: '3.3'
services:
pandora:
image: pengzhile/pandora
container_name: pandoraGPT
network_mode: bridge
ports:
- 8070:8070
environment:
- PANDORA_SERVER=0.0.0.0:8070
- PANDORA_CLOUD=true
- CHATGPT_API_PREFIX=https://api.u4vr.com
- PANDORA_ACCESS_TOKEN={获取的access_token}
restart: unless-stopped
再自己写一个crontab,就可以实现自用定时更新