ollama-haskell-0.2.0.0: Haskell client for ollama.
Copyright(c) 2025 Tushar Adhatrao
LicenseMIT
MaintainerTushar Adhatrao <[email protected]>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Ollama.Pull

Description

This module provides functions to pull (download) models from the Ollama server. It includes both high-level (pull, pullM) and low-level (pullOps, pullOpsM) APIs for pulling models, with support for streaming progress updates and insecure connections. The PullOps type configures the pull request, and PullResp represents the response containing the status and progress details.

The pull operation is performed via a POST request to the "api/pull" endpoint. Streaming mode, when enabled, provides real-time progress updates by printing the remaining bytes to the console.

Example:

>>> pull "gemma3"
Remaining bytes: 123456789
...
Completed
Right (PullResp {status = "success", ...})
Synopsis

Pull Model API

pull Source #

Arguments

:: Text

Model name

-> IO (Either OllamaError PullResp) 

Simplified API for pulling a model.

A higher-level function that pulls a model using default settings for insecure connections, streaming, and Ollama configuration. Suitable for basic use cases.

pullOps Source #

Arguments

:: Text

Model name

-> Maybe Bool

Optional insecure connection flag

-> Maybe Bool

Optional streaming flag

-> Maybe OllamaConfig

Optional OllamaConfig (defaults to defaultOllamaConfig if Nothing)

-> IO (Either OllamaError PullResp) 

Pulls a model with full configuration.

Sends a POST request to the "api/pull" endpoint to download the specified model. Supports streaming progress updates (if stream is 'Just True') and insecure connections (if insecure is 'Just True'). Prints remaining bytes during streaming and Completed when finished. Returns Right with a PullResp on success or Left with an OllamaError on failure.

pullM :: MonadIO m => Text -> m (Either OllamaError PullResp) Source #

MonadIO version of pull for use in monadic contexts.

Lifts the pull function into a MonadIO context, allowing it to be used in monadic computations.

Example:

>>> import Control.Monad.IO.Class
>>> runReaderT (pullM "gemma3") someContext
Right (PullResp {status = "success", ...})

pullOpsM :: MonadIO m => Text -> Maybe Bool -> Maybe Bool -> Maybe OllamaConfig -> m (Either OllamaError PullResp) Source #

MonadIO version of pullOps for use in monadic contexts.

Lifts the pullOps function into a MonadIO context, allowing it to be used in monadic computations with full configuration options.

Example:

>>> import Control.Monad.IO.Class
>>> runReaderT (pullOpsM "gemma3" Nothing (Just True) Nothing) someContext
Remaining bytes: 123456789
...
Completed
Right (PullResp {status = "success", ...})