Documentation
¶
Overview ¶
Package ollama 实现 Ollama 本地模型服务的 ModelProvider.
Ollama 在本地运行开源 LLM(Llama,DeepSeek,Qwen,Gemma 等), 提供 OpenAI 兼容的 Chat Completions API.
特点:
- 无需 API Key(本地服务无鉴权)
- 通过 /api/tags 端点实时获取已安装的本地模型列表
- 不支持 Thinking(本地模型通常不支持结构化推理输出)
- 不支持 Prompt Caching 和 Batch API
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// BaseURL 是 Ollama 服务地址(默认 http://localhost:11434).
// 远程 Ollama 实例时填写对应地址,如 "http://192.168.1.100:11434".
BaseURL string
// HTTPClient 注入自定义 HTTP 客户端(超时配置等).
// 本地模型推理可能较慢,建议设置较长的超时时间.
// nil = 使用默认 http.Client (带 Timeout 字段配置的 ResponseHeaderTimeout).
// 非 nil 时 consumer 完全接管超时责任, 下面的 Timeout 字段被忽略.
HTTPClient *http.Client
// Timeout 限制"从请求发出到收到响应首字节"的时间.
//
// 通过 http.Transport.ResponseHeaderTimeout 实现, **不影响** SSE 流式 body 读取.
// 精妙之处(CLEVER): 不要误用 http.Client.Timeout - 会砍死 SSE 流.
//
// 0 = 使用 defaultTimeout (300s, 适合本地推理冷启动).
// Ollama 默认比云端长 5 倍: 本地模型 (尤其是第一次调用某个模型) 需要从磁盘加载
// 权重 + warm-up, 可能耗时 30-60s 才开始响应.云端 60s 默认值在 Ollama 会频繁超时.
Timeout time.Duration
}
Config 是 Ollama provider 的配置.
Click to show internal directories.
Click to hide internal directories.