增加openai

This commit is contained in:
dekun
2026-05-22 22:31:09 +08:00
parent ac762b540c
commit 5ff9cc4587
5 changed files with 202 additions and 42 deletions
@@ -0,0 +1,44 @@
# Gemma 漏斗 · Ollama / OpenAI 兼容网关
## 本机 Ollama(默认)
```yaml
gemma:
enabled: true
ollama_base_url: "http://127.0.0.1:11434"
api_style: "ollama"
api_key: ""
model: "gemma2:2b"
```
请求地址:`{base}/api/chat`Ollama 原生格式)。
## OpenAI 兼容网关(如 op.bz121.com
网关说明要点:
- 外网访问:`POST /v1/chat/completions`
- 请求头:`Authorization: Bearer sk-...`
- JSON 中 `model` 须与网关中登记的模型 ID **完全一致**
`config.yaml` 示例:
```yaml
gemma:
enabled: true
ollama_base_url: "https://op.bz121.com/v1"
api_style: "openai"
api_key: "sk-你的密钥"
model: "gemma4:e4b" # 改成网关里实际启用的模型名
timeout_seconds: 180
json_mode: true
send_chart_image: true # 需网关/模型支持多模态
```
程序请求:`https://op.bz121.com/v1/chat/completions`
## 注意
- Gemma 请求 **不走** `proxy`(与 Gate 行情代理分开),直连 `ollama_base_url`
- 若仅填 `api_key` 未写 `api_style`,会自动使用 `openai` 模式。
- 网关节点未启用时,会返回 HTTP 错误,日志关键字 `gemma_http_error`