docs(wiki): 添加 Ollama 配置文档和 AI 分析故障排除
- infrastructure.md: 新增 Ollama 服务连接、环境变量、GPU 注意事项 - index.md: 症状导航新增 qwen3 thinking、Ollama 内存/安全、模板渲染等问题
This commit is contained in:
@@ -36,6 +36,7 @@ tags: [infrastructure, dev-environment, windows, postgresql]
|
||||
| 后端 API | `http://localhost:3000/api/v1` | Axum 服务 |
|
||||
| 前端 SPA | `http://localhost:5174` | Vite 开发服务器 |
|
||||
| 微信小程序 | 微信开发者工具 | 患者端小程序(`apps/miniprogram/dist/`) |
|
||||
| Ollama | `http://127.0.0.1:11434` | 本地 AI 推理(qwen3:4b) |
|
||||
|
||||
### 登录凭据
|
||||
|
||||
@@ -63,6 +64,24 @@ psql: `D:\postgreSQL\bin\psql.exe -U postgres -h localhost -d erp`
|
||||
|
||||
> 开发环境 AES/HMAC 密钥生成: `python -c "import secrets; print(secrets.token_hex(32))"`
|
||||
|
||||
### Ollama 本地 AI 配置
|
||||
|
||||
启动脚本:`tmp/start-ollama.ps1`(必须用 `ollama serve` 而非 `ollama app`,否则环境变量不生效)
|
||||
|
||||
| 环境变量 | 值 | 说明 |
|
||||
|----------|-----|------|
|
||||
| `OLLAMA_HOST` | `http://127.0.0.1:11434` | 只监听本地(默认 `0.0.0.0` 暴露局域网) |
|
||||
| `OLLAMA_CONTEXT_LENGTH` | `4096` | 4b 模型足够,默认 262144 会导致 35GB+ KV cache |
|
||||
| `OLLAMA_MAX_LOADED_MODELS` | `1` | 开发环境只加载一个模型 |
|
||||
| `OLLAMA_FLASH_ATTENTION` | `true` | RTX 3070 (Ampere) 支持,降低显存占用 |
|
||||
| `OLLAMA_KEEP_ALIVE` | `10m` | 模型保留 10 分钟避免频繁重载 |
|
||||
| `OLLAMA_ORIGINS` | `http://localhost:3000,http://localhost:5174` | CORS 限制 |
|
||||
| `OLLAMA_NO_CLOUD` | `true` | 禁用云功能 |
|
||||
|
||||
> **GPU 注意事项:** 默认 `OLLAMA_CONTEXT_LENGTH=262144` 会使 KV cache 需要 35GB+ CPU 内存 + 1.8GB GPU 显存,RTX 3070 8GB 无法加载。设为 4096 后模型可完全加载到 GPU(~3GB 显存),推理速度正常。
|
||||
|
||||
> **qwen3 thinking 模式:** qwen3:4b 默认开启 thinking,流式 API 中 `message.content` 为空(全部 token 消耗在 thinking 上)。`erp-ai` Ollama provider 对 qwen3 自动改用非流式 API + `strip_think_block` 剥离 `<think...` 块。
|
||||
|
||||
### 微信小程序配置
|
||||
|
||||
| 配置 | 位置 | 说明 |
|
||||
|
||||
Reference in New Issue
Block a user