Skip to content

About

帕拉斯 Bot AI 功能 API 服务端

Resources

Stars

8 stars

Watchers

1 watching

Forks

Latest commit

 

History

164 Commits

Folders and files

Repository files navigation

LOGO

Pallas-Bot-AI


Pallas-Bot 的可选媒体后端(与本体解耦):唱歌、TTS 等。聊天由 Bot 内核直连 Provider。

简介

使用 FastAPI + Celery(Redis) 为 Pallas-Bot 提供媒体能力(唱歌 / TTS 等)。任务异步执行,完成后通过 /callback 回推 Bot。

Bot 侧请安装官方扩展 pallas-plugin-ai-media(牛牛唱歌 / 牛牛说),并配置 AI_SERVER_HOST / AI_SERVER_PORT(或控制台媒体服务地址)。

默认启动 media worker + API(uv run pallas-ai start 或 ./scripts/ai_bootstrap.sh)。

快速开始(媒体服务)

方式 A:一键脚本(推荐,本机开发)

cp .env.example .env
# 编辑 CALLBACK_HOST / CALLBACK_PORT 指向已运行的 Bot(默认 localhost:8088)
# 网易云搜索和详情始终要求配置该 token;未配置时返回 HTTP 503。
# 在 Bot WebUI「AI 配置 → 媒体 → 媒体服务 → 连接 → Bearer Token」设置,并与此值保持一致。
# 建议设置 PALLAS_AI_API_TOKEN,与 Bot / 插件 Bearer 一致
./scripts/ai_bootstrap.sh

默认依次完成:安装 媒体栈(uv sync --all-groups --extra cpu,含 torch)→ 初始化子模块(git submodule update --init --recursive,含 DDSP-SVC / GPT-SoVITS / RVC)→ 启动 media worker + API。

Windows:bootstrap 会用 docker compose 拉 Redis。请先安装并启动 Docker Desktop(托盘就绪),或本机/WSL 自备 Redis 后在 .env 设置 REDIS_URL。普通聊天不需要本 Runtime。

唱歌 / TTS 的音频处理需要 ffmpeg 在 PATH 中,bootstrap 会检测并提示(Windows 可 winget install --id Gyan.FFmpeg -e,装完新开终端)。

场景 命令
仅体检 ./scripts/ai_bootstrap.sh --check-only
只装不启动 ./scripts/ai_bootstrap.sh --no-start
媒体 + NVIDIA GPU torch PALLAS_GPU=1 ./scripts/ai_bootstrap.sh

依赖矩阵目前仍是未验收候选,不能用于部署:完整解析超时、锁未更新,候选依赖和模型栈未安装/验证。目标是默认 GPU cu130 以保留 Blackwell(sm_120)支持、CPU 使用 torch 2.13.0 + torchaudio 2.11.0;仅本次 RTX 3060 验证候选使用 gpu-cu126,它不是通用 CUDA 12.6 或 Blackwell 选项。cpu、gpu 与 gpu-cu126 互斥;驱动需支持所选 CUDA 运行时。

方式 B:Docker

# 完整栈(Redis + AI + Bot 等),定义见 docker-compose.yml
docker compose up -d
curl -s http://127.0.0.1:9099/health | python3 -m json.tool

只在本机跑 AI、想用容器 Redis 时,先 docker compose up -d redis,再按下方「手动启动」运行。

全功能 GPU 镜像:docker build -t pallasbot/pallas-bot-ai:latest .

Bot 也在 Docker、且与本栈不同网络时:让 Bot 挂入固定网络,AI_SERVER_HOST=pallasbot-ai,本侧 CALLBACK_HOST 用 Bot 容器名。示例:deploy/docker-compose.bot-join-ai.example.yml。

手动启动

需要 Redis(Celery broker);没有可先 docker compose up -d redis,或在 .env 设置 REDIS_URL。音频处理另需 ffmpeg 在 PATH。

cp .env.example .env
uv sync --all-groups --extra cpu     # 或 --extra gpu
git submodule update --init --recursive   # DDSP-SVC / GPT-SoVITS / RVC
uv run pallas-ai start
uv run pallas-ai status
uv run pallas-ai stop
uv run pallas-ai restart media
uv run pallas-ai restart fast

日志在 logs/:api.log、celery-media.log、celery-fast.log。pallas-ai 是 API 与 media/fast worker 的统一入口,默认目标 all,也可只操作 api / media / fast(如 uv run pallas-ai restart media)。restart-clean 先清理遗留 Celery 任务状态再重启,purge-stale 仅清理任务状态。完整命令见 docs/Deployment.md。

自检与 API

curl -s http://127.0.0.1:9099/health | python3 -m json.tool

关注 media_tasks、tts 等字段(按已启用端点返回)。health 中会提示推荐前缀 /v1。

对外推荐 /v1(配置了 PALLAS_AI_API_TOKEN 时须带 Bearer);网易云搜索与歌曲详情始终要求配置该 token,未配置时返回 HTTP 503。/api 为兼容入口(deprecated)。

# 示例:提交 TTS(request_id 由调用方生成,完成后走 Bot /callback)
curl -s -X POST "http://127.0.0.1:9099/v1/tts/${REQUEST_ID}" \
  -H "Authorization: Bearer ${PALLAS_AI_API_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"text":"你好"}'

项目结构

  • app/http — FastAPI 路由(/api 兼容、/v1 推荐)
  • app/media — 媒体门面、运行时、SVC 注册表与本地服务
  • app/workers — Celery 媒体任务(sing / tts / 遗留酒后 chat RWKV)
  • docs — 部署与架构文档
  • tests — 单测

相关仓库

仓库 说明
Pallas-Bot Bot 本体(通过 AI_SERVER_* 连接本服务)
Plugin-Ai-Media 官方扩展:牛牛唱歌 / 牛牛说
Pallas-Bot-WebUI 控制台前端
Pallas-Bot-Docs 文档站
Pallas-Bot-Community-Stats 社区统计与语料中心

开发

uv run pytest
uv run ruff check app/ tests/

完整环境见 docs/Deployment.md。

About

帕拉斯 Bot AI 功能 API 服务端

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages