| Copyright | (c) 2025 Tushar Adhatrao |
|---|---|
| License | MIT |
| Maintainer | Tushar Adhatrao <tusharadhatrao@gmail.com> |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Ollama.Load
Contents
Description
This module provides functions to load and unload generative models in the Ollama server.
It includes both IO-based functions (loadGenModel, unloadGenModel) and monadic versions
(loadGenModelM, unloadGenModelM) for use in MonadIO contexts. The operations are
performed via POST requests to the "api/generate" endpoint, leveraging the GenerateOps
configuration from the Generate module.
Loading a model keeps it in memory for faster subsequent requests, while unloading frees up memory by setting the keep-alive duration to zero.
Example:
>>>loadGenModel "gemma3"Right ()>>>unloadGenModel "gemma3"Right ()
Synopsis
- loadGenModel :: Text -> IO (Either OllamaError ())
- unloadGenModel :: Text -> IO (Either OllamaError ())
- loadGenModelM :: MonadIO m => Text -> m (Either OllamaError ())
- unloadGenModelM :: MonadIO m => Text -> m (Either OllamaError ())
Load and Unload Model APIs
Arguments
| :: Text | Model name (e.g., "gemma3") |
| -> IO (Either OllamaError ()) |
Loads a generative model into memory.
Sends a POST request to the "api/generate" endpoint to load the specified model into
memory, ensuring faster response times for subsequent requests. Returns 'Right ()' on
success or Left with an OllamaError on failure.
--
-- @since 0.2.0.0
Arguments
| :: Text | Model name (e.g., "gemma3") |
| -> IO (Either OllamaError ()) |
Unloads a generative model from memory.
Sends a POST request to the "api/generate" endpoint with a keep-alive duration of zero
to unload the specified model from memory, freeing up resources. Returns 'Right ()' on
success or Left with an OllamaError on failure.
--
-- @since 0.2.0.0
loadGenModelM :: MonadIO m => Text -> m (Either OllamaError ()) Source #
MonadIO version of loadGenModel for use in monadic contexts.
Lifts the loadGenModel function into a MonadIO context, allowing it to be used in
monadic computations.
Example:
>>>import Control.Monad.IO.Class>>>runReaderT (loadGenModelM "gemma3") someContextRight () -- -- @since 0.2.0.0
unloadGenModelM :: MonadIO m => Text -> m (Either OllamaError ()) Source #
MonadIO version of unloadGenModel for use in monadic contexts.
Lifts the unloadGenModel function into a MonadIO context, allowing it to be used in
monadic computations.
Example:
>>>import Control.Monad.IO.Class>>>runReaderT (unloadGenModelM "gemma3") someContextRight () -- -- @since 0.2.0.0