Skip to content

fix: 配置 Docker 环境使用本地 llama.cpp#111

Merged
TelivANT merged 1 commit intomainfrom
fix/qdrant-port-config
Feb 28, 2026
Merged

fix: 配置 Docker 环境使用本地 llama.cpp#111
TelivANT merged 1 commit intomainfrom
fix/qdrant-port-config

Conversation

@TelivANT
Copy link
Copy Markdown
Owner

变更类型

  • Bug 修复 (fix)
  • 新功能 (feat)
  • 文档更新 (docs)
  • 代码重构 (refactor)
  • 性能优化 (perf)

变更描述

修复 Docker 环境配置,使 Gateway 能够连接主机上的 llama.cpp 服务,并解决 IP 防御功能导致的启动错误。

主要修改

  1. LLM 配置

    • 修改 base_urlhttp://host.docker.internal:11434/v1
    • 更新默认模型为 qwen2.5:latest
    • 支持 Docker 容器访问主机 llama.cpp 服务
  2. IP 防御配置

    • 添加 [ip_defense] 配置段
    • 设置 enabled = false
    • 避免因缺少 ip_blacklist collection 导致的启动失败

问题背景

在 Docker 环境中启动 Gateway 时遇到以下问题:

  • Gateway 无法连接 OpenAI API(需要本地 LLM)
  • IP 防御系统尝试访问不存在的 ip_blacklist collection 导致所有请求被阻塞

解决方案

通过配置文件调整,使 Gateway 能够:

  • 使用主机上的 llama.cpp 作为 LLM 后端
  • 禁用 IP 防御功能(或在生产环境中正确初始化 Qdrant collections)

测试

  • 本地测试通过
  • Docker 环境测试通过
  • Gateway 成功连接 llama.cpp
  • API 请求正常响应

测试命令

# 启动 llama.cpp
llama-server --model qwen2.5-3b-instruct-q4_k_m.gguf --port 11434

# 启动 Gateway
docker-compose up -d gateway

# 测试 API
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen2.5","messages":[{"role":"user","content":"你好"}]}'

文档

  • 已更新相关文档(配置文件本身即为文档)
  • 不需要更新 CHANGELOG(配置调整)

检查清单

  • 配置文件格式正确
  • 提交信息符合规范
  • 本地测试通过
  • Docker 环境验证通过

相关 Issue

解决 Docker 环境下 Gateway 无法启动和连接 LLM 的问题。

备注

此配置适用于开发/测试环境。生产环境建议:

  1. 使用真实的 OpenAI API 或其他 LLM 服务
  2. 正确初始化 IP 防御所需的 Qdrant collections
  3. 启用认证和安全防护功能

- 修改 LLM 配置指向 host.docker.internal:11434 (llama.cpp)
- 更新默认模型为 qwen2.5:latest
- 禁用 IP 防御功能以避免 ip_blacklist collection 缺失错误
- 支持 Docker 容器内访问主机 llama.cpp 服务
@TelivANT
Copy link
Copy Markdown
Owner Author

Self-Review Checklist ✅

作为提交者,我已完成以下自查:

代码质量

  • ✅ 配置文件格式正确(TOML 语法)
  • ✅ 修改最小化,只涉及必要的配置项
  • ✅ 没有引入新的依赖或破坏性变更

功能验证

  • ✅ 本地测试通过(llama.cpp + Gateway)
  • ✅ Docker 环境测试通过
  • ✅ API 请求正常响应
  • ✅ 记忆功能可用(通过 MCP Server 测试)

文档完整性

  • ✅ PR 描述详细,包含问题背景
  • ✅ 提供了完整的测试步骤
  • ✅ 标注了生产环境注意事项

规范遵守

  • ✅ 提交信息符合 Conventional Commits
  • ✅ 分支命名符合 fix/ 规范
  • ✅ 遵循 CONTRIBUTING.md 指南

测试环境

  • OS: macOS (Apple Silicon)
  • Docker: Colima 0.8.0
  • llama.cpp: 8180 (Homebrew)
  • 模型: Qwen2.5-3B-Instruct Q4_K_M

已知限制

  1. 此配置仅适用于开发/测试环境
  2. 生产环境需要额外配置(认证、IP 防御等)
  3. host.docker.internal 在某些 Linux 环境可能需要额外配置

后续工作

  • 添加 IP 防御 collection 初始化脚本
  • 创建生产环境配置模板
  • 补充配置文档

Ready for review! 🔍

@TelivANT TelivANT merged commit 23d8724 into main Feb 28, 2026
3 checks passed
@TelivANT TelivANT deleted the fix/qdrant-port-config branch February 28, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant