MyNixOS website logo
Description

Haskell client for ollama.

Ollama client for Haskell

🦙 Ollama Haskell

ollama-haskell is an unofficial Haskell client for Ollama, inspired by ollama-python. It enables interaction with locally running LLMs through the Ollama HTTP API — directly from Haskell.


✨ Features

  • 💬 Chat with models
  • ✍️ Text generation (with streaming)
  • ✅ Chat with structured messages and tools
  • 🧠 Embeddings
  • 🧰 Model management (list, pull, push, show, delete)
  • 🗃️ In-memory conversation history
  • ⚙️ Configurable timeouts, retries, streaming handlers

⚡ Quick Example

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.Ollama.Generate
import qualified Data.Text.IO as T

main :: IO ()
main = do
  let ops =
        defaultGenerateOps
          { modelName = "gemma3"
          , prompt = "What is the meaning of life?"
          }
  eRes <- generate ops Nothing
  case eRes of
    Left err -> putStrLn $ "Something went wrong: " ++ show err
    Right r -> do
      putStr "LLM response: "
      T.putStrLn (genResponse r)

📦 Installation

Add to your .cabal file:

build-depends:
  base >=4.7 && <5,
  ollama-haskell

Or use with stack/nix-shell.


📚 More Examples

See examples/OllamaExamples.hs for:

  • Chat with conversation memory
  • Structured JSON output
  • Embeddings
  • Tool/function calling
  • Multimodal input
  • Streaming and non-streaming variants

🛠 Prerequisite

Make sure you have Ollama installed and running locally. Run ollama pull llama3 to download a model.


🧪 Dev & Nix Support

Use Nix:

nix-shell

This will install stack and Ollama.


👨‍💻 Author

Created and maintained by @tusharad. PRs and feedback are welcome!


🤝 Contributing

Have ideas or improvements? Feel free to open an issue or submit a PR!

Metadata

Version

0.2.0.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows