feat: 新增语音转文字(ASR)功能

- 后端:新增 /api/audio/transcribe 接口,调用 Ollama whisper 进行语音识别
- 前端:新增 AudioTranscribePage.vue 页面,支持 MP3/WAV/M4A/OGG/FLAC 等格式
- 注册路由、工具卡片、智能助手欢迎语更新

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
eaiadmin
2026-09-14 00:53:36 +08:00
co-authored by Claude Code
parent 752c7837ef
commit 0455f064ac
299 changed files with 1588 additions and 432 deletions
+23 -23
View File
@@ -1,4 +1,4 @@
# eaisalestrain_app — 部署文档
# eai_agentplatform_app — 部署文档
> **版本:V1.2 | 部署模式:纯本地离线 · Go 单二进制 · MySQL 8.0 + FAISS · systemd · Clonezilla 整盘克隆**
> **最后更新:2026-08-16**
@@ -25,7 +25,7 @@
│ │
┌─────▼──────────────┐ ┌──────▼───────┐
│ Go 单二进制 │ │ Vue 静态打包 │
│ eaisalestrain- │ │ /usr/share/ │
│ eai_agentplatform- │ │ /usr/share/ │
│ server :8080 │ │ nginx/html │
│ (Gin + GORM) │ └──────────────┘
└──┬─────┬─────┬─────┘
@@ -55,7 +55,7 @@
| 服务 | 端口 | 说明 |
|------|------|------|
| Nginx | 80/443 | HTTP 反代 + 前端静态资源托管 |
| eaisalestrain-server | 8080 | Go 单二进制后端(Gin + GORM) |
| eai_agentplatform-server | 8080 | Go 单二进制后端(Gin + GORM) |
| MySQL | 3306 | MySQL 8.0 关系数据(systemd 托管 mysqld) |
| FAISS | 内嵌 | 向量索引,由 Go 后端 cgo 内嵌,索引文件 `data/faiss/` |
| LibreOffice + pdftotext | 进程内调用 | 裸进程,非容器,文档转文本 |
@@ -68,8 +68,8 @@
## 目录布局
```
/opt/eaisalestrain/
├── eaisalestrain-server # 单二进制(CGO 关闭,静态链接,约 38MB)
/opt/eai_agentplatform/
├── eai_agentplatform-server # 单二进制(CGO 关闭,静态链接,约 38MB)
├── .env # JWT 密钥、LLM 配置等
├── data/
│ ├── faiss/ # FAISS 向量索引(embedding 向量)
@@ -93,9 +93,9 @@ apt update && apt install -y nginx mysql-server libreoffice poppler-utils
> MySQL 初始化库与账号(FAISS 向量索引内嵌于后端,无需独立服务):
>
> ```sql
> CREATE DATABASE eaisalestrain DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
> CREATE USER 'eaisalestrain'@'127.0.0.1' IDENTIFIED BY '<随机密码>';
> GRANT ALL PRIVILEGES ON eaisalestrain.* TO 'eaisalestrain'@'127.0.0.1';
> CREATE DATABASE eai_agentplatform DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
> CREATE USER 'eai_agentplatform'@'127.0.0.1' IDENTIFIED BY '<随机密码>';
> GRANT ALL PRIVILEGES ON eai_agentplatform.* TO 'eai_agentplatform'@'127.0.0.1';
> FLUSH PRIVILEGES;
> ```
@@ -103,37 +103,37 @@ apt update && apt install -y nginx mysql-server libreoffice poppler-utils
```bash
# 2.1 拷贝二进制 + 建服务账号
sudo install -m 0755 eaisalestrain-server /opt/eaisalestrain/eaisalestrain-server
sudo useradd -r -s /usr/sbin/nologin eaisalestrain
sudo mkdir -p /opt/eaisalestrain/data/kb_data /opt/eaisalestrain/docs/knowledge_source
sudo chown -R eaisalestrain:eaisalestrain /opt/eaisalestrain
sudo install -m 0755 eai_agentplatform-server /opt/eai_agentplatform/eai_agentplatform-server
sudo useradd -r -s /usr/sbin/nologin eai_agentplatform
sudo mkdir -p /opt/eai_agentplatform/data/kb_data /opt/eai_agentplatform/docs/knowledge_source
sudo chown -R eai_agentplatform:eai_agentplatform /opt/eai_agentplatform
# 2.2 生成 .env(JWT 密钥随机)
sudo -u eaisalestrain cp deploy/eaisalestrain.env /opt/eaisalestrain/.env
sudo -u eai_agentplatform cp deploy/eai_agentplatform.env /opt/eai_agentplatform/.env
NEW_SECRET=$(python3 -c "import secrets; print(secrets.token_urlsafe(48))")
sudo sed -i "s|^JWT_SECRET=.*|JWT_SECRET=$NEW_SECRET|" /opt/eaisalestrain/.env
sudo sed -i "s|^JWT_SECRET=.*|JWT_SECRET=$NEW_SECRET|" /opt/eai_agentplatform/.env
# 2.3 安装 systemd 单元并启动
sudo install -m 0644 deploy/eaisalestrain.service /etc/systemd/system/eaisalestrain.service
sudo install -m 0644 deploy/eai_agentplatform.service /etc/systemd/system/eai_agentplatform.service
sudo systemctl daemon-reload
sudo systemctl enable --now eaisalestrain
sudo systemctl enable --now eai_agentplatform
# 2.4 验证
curl http://127.0.0.1:8080/api/health # {"status":"ok","service":"eaisalestrain-app",...}
curl http://127.0.0.1:8080/api/health # {"status":"ok","service":"eai_agentplatform-app",...}
```
`.env` 关键项:
```bash
PORT=8080
DB_DSN=eaisalestrain:<随机密码>@tcp(127.0.0.1:3306)/eaisalestrain?charset=utf8mb4&parseTime=True&loc=Local
DB_DSN=eai_agentplatform:<随机密码>@tcp(127.0.0.1:3306)/eai_agentplatform?charset=utf8mb4&parseTime=True&loc=Local
JWT_SECRET=<48 字符随机串,交付前生成>
LLM_BASE_URL=http://127.0.0.1:11434/v1
LLM_MODEL=qwen2.5:7b
EMBED_MODEL=bge-m3
FAISS_INDEX_DIR=data/faiss
KB_DATA_DIR=data/kb_data
KNOWLEDGE_SOURCE_DIR=/opt/eaisalestrain/docs/knowledge_source
KNOWLEDGE_SOURCE_DIR=/opt/eai_agentplatform/docs/knowledge_source
LIBREOFFICE_BIN=/usr/bin/libreoffice
PDFTOTEXT_BIN=/usr/bin/pdftotext
```
@@ -205,10 +205,10 @@ python -m vllm.entrypoints.openai.api_server \
## 启动/停止
```bash
sudo systemctl restart eaisalestrain # 重启
sudo systemctl stop eaisalestrain # 停止
sudo systemctl status eaisalestrain # 状态 / 日志
journalctl -u eaisalestrain -f # 实时日志
sudo systemctl restart eai_agentplatform # 重启
sudo systemctl stop eai_agentplatform # 停止
sudo systemctl status eai_agentplatform # 状态 / 日志
journalctl -u eai_agentplatform -f # 实时日志
```
---