Skip to content

2026-03-31 工作项目记录

时间: 2026-03-31 状态: 进行中 ⚠️


Content Center 项目(AI内容中心)

项目概览

全栈 AI 内容中心应用,支持文生文、文生图、图生图功能。

技术栈:

  • 后端:Node.js + Express + TypeScript + SSE 流式输出
  • 前端:React 18 + TypeScript + Vite + Tailwind CSS
  • 部署:Docker Compose

文件结构:

C:\project\content-center\
├── backend/
│   ├── src/
│   │   ├── modules/(意图分类、文本生成、图片生成、工作流)
│   │   ├── routes/(API路由)
│   │   └── server.ts
│   └── .env
├── frontend/
└── docker-compose.yml

今日问题排查

问题1:Git 代码同步确认

现象:飞哥在服务器上执行 git pull,显示 "Already up to date."

结论:✅ 代码已是最新状态


问题2:AI 文字生成失败 ⚠️

现象

  • 发送消息后 AI 返回 "抱歉,文字生成失败了,请稍后重试"
  • 接口状态是 200 OK,但用的是 text/event-stream (SSE)
  • 前端显示错误,但后端日志未截图

可能原因

  1. TONGYI_API_KEY 无效或过期 - 当前使用的 Key: sk-****...****(已脱敏)
  2. 网络问题 - 服务器无法访问阿里云 DashScope
  3. API 端点变更 - https://dashscope.aliyuncs.com/compatible-mode/v1 可能已变更

代码分析

backend/src/modules/text-generator.ts:

typescript
static async* generate(prompt: string): AsyncGenerator<string> {
  try {
    // 调用通义千问 API
    const response = await axios.post(
      `${textConfig.baseUrl}/chat/completions`,
      // ...
    );
    // 流式处理响应...
  } catch (error) {
    console.error('Text generation failed:', error);
    yield '抱歉,文字生成失败了,请稍后重试。';  // 错误被吞掉,只返回通用消息
  }
}

根本问题:catch 块只记录了错误到 console,但返回给用户的是通用错误消息,无法得知真正原因。

建议排查步骤

bash
# 1. SSH 到服务器
# 2. 查看容器日志
docker-compose logs -f backend

# 3. 检查 API Key 是否有效
# 4. 测试网络连通性
curl -v https://dashscope.aliyuncs.com/compatible-mode/v1/models

已完成事项

项目状态说明
Git 代码同步✅ 完成Already up to date
问题代码分析✅ 完成定位到 text-generator.ts 错误处理问题
AI 生成失败排查⚠️ 进行中需查看服务器日志确认具体错误

待处理

  • [ ] 查看 content-center 服务器后端日志,确认 TONGYI_API_KEY 是否有效
  • [ ] 测试服务器能否访问 https://dashscope.aliyuncs.com
  • [ ] 如果 API Key 无效,需要更新新的 Key