CliSubprocessCore.Ollama (CliSubprocessCore v0.2.0)

Copy Markdown View Source

Ollama HTTP integration used by model validation and backend resolution.

This module wraps the small set of Ollama endpoints the core runtime uses to verify availability, inspect installed models, and validate model ids.

Summary

Types

http_stub()

@type http_stub() :: (atom(), String.t(), map() | nil, keyword() ->
                  {:ok, pos_integer(), map()} | {:error, term()})

model_info()

@type model_info() :: map()

Functions

codex_base_url(value)

@spec codex_base_url(String.t() | nil) :: String.t() | nil

Normalizes an Ollama base URL for Codex's OpenAI-compatible OSS route.

Raw Ollama roots such as http://localhost:11434 are promoted to /v1 because current Codex CLI OSS requests target OpenAI-style endpoints below that prefix. Explicit non-root paths are preserved.

default_base_url()

@spec default_base_url() :: String.t()

fetch_version(opts \\ [])

@spec fetch_version(keyword()) :: {:ok, String.t() | nil} | {:error, term()}

list_model_names(opts \\ [])

@spec list_model_names(keyword()) :: {:ok, [String.t()]} | {:error, term()}

list_models(opts \\ [])

@spec list_models(keyword()) :: {:ok, [model_info()]} | {:error, term()}

running_models(opts \\ [])

@spec running_models(keyword()) :: {:ok, [model_info()]} | {:error, term()}

show_model(model, opts \\ [])

@spec show_model(
  String.t(),
  keyword()
) :: {:ok, model_info()} | {:error, term()}

validate_model(model, provider, opts \\ [])

@spec validate_model(String.t(), atom(), keyword()) ::
  {:ok, model_info()}
  | {:error, {:unknown_model, String.t(), [String.t()], atom()}}
  | {:error, {:model_unavailable, atom(), {:ollama_unavailable, term()}}}