Ollama native adapter
internal/ai/llm/ollama implements llm.Provider over plain net/http:
POST {base}/api/chat with "stream": false, the request schema in
"format", and options.temperature / options.num_predict only when the
request sets them; GET {base}/api/tags for ListModels and Verify. No
Authorization header is sent and redirects are not followed.
Usage comes from prompt_eval_count/eval_count. A schema reply that is
not a JSON object is ErrBadOutput. HTTP 404 on /api/chat is an
ErrProvider naming the configured model, without quoting the body.
Refused connections and timeouts match ErrTimeout and say
"Ollama not reachable at {base}"; a cancelled context stays
context.Canceled. The base URL is required, absolute http or https
(LAN hosts allowed), and may not carry userinfo, a query or a fragment.
Contract tests replay sanitized fixtures adapted from Ollama's public
API docs against httptest servers: success, schema output, model
missing and unreachable host.
Maestro task: 51289131-5abf-48c3-b553-7e3809c09076
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"model": "llama3.2",
|
||||
"created_at": "2026-10-04T12:13:43.416799Z",
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "Try a crock pot chili: it is a Quick dinner."
|
||||
},
|
||||
"done": true,
|
||||
"done_reason": "stop",
|
||||
"total_duration": 5191566416,
|
||||
"load_duration": 2154458,
|
||||
"prompt_eval_count": 26,
|
||||
"prompt_eval_duration": 383809000,
|
||||
"eval_count": 298,
|
||||
"eval_duration": 4799921000
|
||||
}
|
||||
Reference in New Issue
Block a user