Skip to contents

ellmer routes ollama via the OpenAI-compatible /v1/ endpoint, which ignores think=FALSE. This helper calls /api/chat directly where think is honoured.

Usage

.llm_ollama_native(
  text,
  system_prompt,
  model = NULL,
  think = FALSE,
  options = list(),
  base_url = rep_if(Sys.getenv("OLLAMA_BASE_URL"), "http://localhost:11434", replace =
    ""),
  timeout = llm_timeout()
)

Arguments

text

The text to send to the LLM (vector of strings, or data frame with the text in a column)

system_prompt

A system prompt to set the behavior of the assistant

model

the ollama model

think

whether to use thinking mode (very slow)

options

further options to pass to to the model

base_url

the local URL

timeout

request timeout in seconds; defaults to llm_timeout(). A stuck/overloaded local Ollama server otherwise blocks here with no log output for as long as curl is willing to wait – this turns that into a visible, retriable per-call failure instead.

Value

the model's answer (character), without leading or trailing white space