system commit
This commit is contained in:
31
backend/README.md
Normal file
31
backend/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# 后端服务
|
||||
|
||||
Node.js + Express + TypeScript + Mongoose + OpenAI 示例。
|
||||
|
||||
## 环境变量
|
||||
复制 `.env.example` 为 `.env` 并填写:
|
||||
|
||||
```
|
||||
PORT=3000
|
||||
MONGODB_URI=mongodb://localhost:27017/multi_llm_chat
|
||||
OPENAI_API_KEY=sk-...
|
||||
# 可选 OpenAI base (代理): OPENAI_BASE_URL=https://api.openai.com
|
||||
DEEPSEEK_API_KEY=sk-deepseek...
|
||||
DEEPSEEK_BASE_URL=https://api.deepseek.com
|
||||
```
|
||||
|
||||
## 运行
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## 接口
|
||||
- POST /api/chat { modelId, messages } => { text }
|
||||
- POST /api/chat/stream (SSE) data: <chunk> 直到 data: [DONE]
|
||||
- POST /api/conversations 保存对话
|
||||
- GET /api/conversations/:id 读取对话
|
||||
- GET /api/health 健康检查
|
||||
|
||||
## 说明
|
||||
已接入 OpenAI 与 DeepSeek(DeepSeek 通过 model 名包含 "deepseek" 自动匹配,使用 OpenAI 协议 /v1/chat/completions)。可继续在 `llmService.ts` 中扩展更多 provider 逻辑。
|
Reference in New Issue
Block a user