46 Commits

Author SHA1 Message Date
bfe4d9f94d Use clap for command-line arguments in pull example
Some checks failed
CI / Check (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Format (push) Has been cancelled
2026-04-06 16:50:38 +01:00
1b37c8dafe Implement Clone for Stop
Some checks failed
CI / Check (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Format (push) Has been cancelled
2026-04-03 15:40:08 +01:00
19fd7ad712 Options implements Debug 2026-04-03 15:38:55 +01:00
8fc1268e81 Merge pull request #4 from andreban/feat/api-show
feat: implement api/show endpoint
2026-02-02 12:24:23 +00:00
de2efc51d5 Runs cargo fmt 2026-02-02 12:21:08 +00:00
5bad832353 feat: implement api/show endpoint 2026-02-02 10:19:42 +00:00
6f14e5e908 Merge pull request #3 from andreban/add-embed-endpoint
Add embed endpoint (POST /api/embed)
2026-02-01 21:27:47 +00:00
0f796f1a2f Add embed endpoint (POST /api/embed)
Implement the Ollama POST /api/embed endpoint for generating vector
embeddings from text input.

- Add EmbedInput, EmbedRequest, EmbedResponse types in src/types/embed.rs
- Add OllamaClient::embed() async method in src/lib.rs
- Register embed module in src/types/mod.rs
- Add usage example in examples/embed.rs
- Update README with embed endpoint documentation
2026-02-01 21:26:44 +00:00
b885ca3c1c Merge pull request #2 from andreban/update-readme-delete-endpoint
Update README with delete endpoint documentation
2026-02-01 21:19:10 +00:00
fe74d78645 Update README with delete endpoint documentation 2026-02-01 21:18:15 +00:00
c5abf87d9d Merge pull request #1 from andreban/add-delete-endpoint
Add delete model endpoint (DELETE /api/delete)
2026-02-01 21:15:53 +00:00
63c08c484c Add delete model endpoint (DELETE /api/delete)
Implement the Ollama DELETE /api/delete endpoint for removing models
from the server.

- Add DeleteRequest type with model field in src/types/delete.rs
- Add OllamaClient::delete() async method in src/lib.rs
- Register delete module in src/types/mod.rs
- Add usage example in examples/delete.rs
2026-02-01 21:14:26 +00:00
f15a2c53d6 Add comprehensive RustDocs for all public API items
- Add crate-level docs with usage examples for lib.rs
- Document OllamaClient, OllamaClientBuilder, and all public methods
- Document error module with OllamaError variants and OllamaResult
- Document types module with endpoint mapping table
- Document all types in common, chat, generate, ps, pull, tags, version
- Add doc examples for builders, constructors, and key types
- All 26 doc-tests pass
2026-01-30 20:16:15 +00:00
c6450b774a Add GitHub Actions CI workflow
Four parallel jobs on push/PR to main:
- check: cargo check + examples
- test: cargo test
- clippy: cargo clippy with warnings as errors
- fmt: cargo fmt --check

Uses dtolnay/rust-toolchain for Rust setup and Swatinem/rust-cache
for dependency caching.
2026-01-30 20:00:17 +00:00
ad07dcd644 Add configurable connection timeout to OllamaClient
OllamaClient now applies a 30-second connection timeout by default,
so a down server fails fast instead of blocking indefinitely. No
request timeout is set since LLM responses can legitimately run for
minutes during model loading or long generations.

Added OllamaClient::builder() for custom configuration:

    OllamaClient::builder("http://localhost:11434")
        .connection_timeout(Duration::from_secs(60))
        .build();

Also updated README.md to document the builder API, default()
constructor, tool_response return type change, and think support
in ChatRequest.
2026-01-30 19:56:56 +00:00
385ff9b3a2 Add unit tests for all types and error handling
54 tests covering serialization/deserialization round-trips, builder
patterns, skip_serializing_if behavior, untagged enums, field renames,
and error type conversions.

Test modules added to:
- types/common.rs: Think, Stop, Options, OptionsBuilder, ModelDetails
- types/generate.rs: GenerateRequest, GenerateResponse, builder
- types/chat.rs: Role, Message, ChatRequest, Tool, ChatResponse
- types/pull.rs: PullRequest, PullResponse, builder
- types/version.rs: VersionResponse
- types/tags.rs: TagsResponse
- types/ps.rs: PsResponse
- error.rs: Display formatting, From conversions, Error trait
2026-01-30 19:50:59 +00:00
35a7fd13f6 Add think field to ChatRequest
The Ollama API supports the think parameter for both generate and
chat endpoints. ChatRequest was missing it while GenerateRequest
already had it. Added the field, builder method, and doc comment
to bring chat to parity with generate.
2026-01-30 19:41:41 +00:00
be4bacf362 Add Default impl for OllamaClient
Connects to http://localhost:11434, the standard local Ollama address.
Users can now use OllamaClient::default() for the common case instead
of always providing the server address explicitly.
2026-01-30 19:40:26 +00:00
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