Skip to contents

R port of morie.llm.ask. Tries each provider in priority order; on HTTP/timeout failure falls through to the next, and finally to a static local help string.

Usage

morie_llm_ask(
  prompt,
  context = NULL,
  model = NULL,
  provider = NULL,
  system_prompt = NULL,
  timeout = 120
)

Arguments

prompt

User question or instruction.

context

Optional named list injected as text into the system prompt.

model

Optional model override.

provider

Optional provider override (ollama/gemini/api/openai/local). NULL = auto-detect.

system_prompt

Optional full system-prompt override.

timeout

HTTP timeout in seconds. Default 120.

Value

Character scalar response text, or local-fallback text when all providers fail.

Examples

# \donttest{
old <- options(morie.llm.ollama_cached = FALSE)
out <- try(morie_llm_ask("In one word, what is 2 + 2?"))
print(out)
#> [1] "MORIE is running in local-only mode (no LLM provider detected).\n\nAvailable capabilities without an LLM:\n  - morie list-modules        List analysis modules\n  - morie run-module <name>   Run a specific module\n  - morie pipeline --all -y   Run the full analysis pipeline\n\nEnable an LLM by setting one of GEMINI_API_KEY, LLM_API_BASE_URL + LLM_API_KEY, or OPENAI_API_KEY, or by running a local Ollama instance."
options(old)
# }