Commit Graph

28 Commits

Author SHA1 Message Date
ac2137eedb Fix doc comments and attribute ordering in GenerateRequest
Moved serde attributes on prompt and suffix to the conventional
position after doc comments. Changed // to /// on images and format
fields so they appear in generated documentation.
2026-01-30 19:39:40 +00:00
0f0f227208 Return OllamaResult from Message::tool_response instead of panicking
Replaced unwrap() with ? operator so serialization errors propagate
as OllamaError::ResponseParseError instead of panicking. This is
safer for a library API where callers should decide how to handle
errors.
2026-01-30 19:38:28 +00:00
51771284a7 Always serialize messages field in ChatRequest
The Ollama API expects the messages field to be present in chat
requests. Removed skip_serializing_if on messages so it serializes
as an empty array rather than being omitted entirely.
2026-01-30 19:34:09 +00:00
c567f935f6 Add skip_serializing_if to PullRequest optional fields
PullRequest now omits insecure and stream from serialized JSON when
unset, consistent with all other request types in the codebase.
Previously these fields serialized as null.
2026-01-30 19:33:30 +00:00
fe796162c7 Use u64 instead of usize for durations, counts, and sizes
usize is platform-dependent (32-bit on 32-bit targets). Nanosecond
durations can exceed u32::MAX in ~4.3 seconds, and model sizes in
bytes can easily exceed 4 GiB. Using u64 ensures correctness across
all platforms.

Changed fields:
- GenerateResponse: total_duration, load_duration, prompt_eval_count,
  prompt_eval_duration, eval_count, eval_duration
- Model: size
- RunningModel: size, size_vram
2026-01-30 19:31:59 +00:00
2f23e6123a Fix typo: rename LinesCoderError variant to LinesCodecError
The variant name now matches the underlying tokio_util::codec::LinesCodecError
type it wraps.
2026-01-30 19:30:29 +00:00
d845103679 Fix Display impl for OllamaError: use write! instead of writeln!
The Display trait should not append trailing newlines, as callers
like println! and error chaining libraries (anyhow, eyre) add their
own. Also cleaned up the display strings to use readable names
instead of raw variant names.
2026-01-30 19:29:29 +00:00
b70cc1a62d Propagate parse errors in stream_response instead of silently dropping them
Previously, if serde_json::from_str failed on a streamed line, the
line was silently discarded and the caller had no indication that data
was lost. Now parse errors are yielded as OllamaError::ResponseParseError
so consumers can detect and handle unexpected API responses.

Empty lines from LinesCodec are skipped to avoid spurious parse errors
on blank input between chunks.
2026-01-30 19:28:02 +00:00
098dc4426f Reuse reqwest::Client across requests for connection pooling
Store a shared reqwest::Client on OllamaClient instead of creating
a new one per request. Previously, version(), tags(), and ps() each
used reqwest::get() which allocates a one-shot client, and
stream_response() called reqwest::Client::new() on every invocation.

Since reqwest::Client manages an internal connection pool, reusing it
enables TCP and TLS connection reuse across calls. Cloning the client
is cheap as it is Arc-backed internally.
2026-01-30 19:25:15 +00:00
c66312ce56 Update request to 0.13 2026-01-30 19:16:15 +00:00
0f49c5577c Adds README.md 2026-01-30 19:13:00 +00:00
cfd476a82d Uses previous version of reqwest for compatibility 2026-01-17 09:33:26 +00:00
c295565401 Uses major versions for library dependencies 2026-01-16 15:54:25 +00:00
f87a8497da More logging 2026-01-15 20:47:19 +00:00
a9ab4e6d60 Adds structured output to chat 2026-01-07 16:33:18 +00:00
69a9ce0de5 OllamaClient derives Clone 2026-01-07 14:24:08 +00:00
96bed8e85b Adds error_for_status() for ollama requests 2026-01-07 14:16:44 +00:00
53353eabe0 Adds function calling 2026-01-06 21:15:20 +00:00
ecedb1c054 Add Options to generate and chat 2025-12-28 20:52:01 +00:00
d7cb16a6d8 Refactor to tags and ps 2025-12-28 20:35:04 +00:00
7251ac07bd Adds think, format and images to generate 2025-12-28 14:56:40 +00:00
b2e7b7134e Adds version method 2025-12-28 13:23:14 +00:00
1c431715c6 Unifies streaming code 2025-12-28 12:50:47 +00:00
ac480881e4 Adds pull method and example 2025-12-28 12:18:35 +00:00
65ea1dcfec Adds chat and chat example 2025-12-24 16:55:34 +00:00
d06d69d132 Finishes the generate implementation 2025-12-24 15:58:23 +00:00
8a0c10c6fc Adds tags and ps methods 2025-12-23 22:04:38 +00:00
4b96a0b9dc Initial Commit 2025-12-23 17:49:52 +00:00