Candil.Model (Candil v1.0.0)

Copy Markdown View Source

LLM model definition for Candil.

A model is either local (a .gguf file on disk served by a local engine) or remote (a model name offered by a remote provider such as OpenAI or Anthropic).

Local model fields

  • :alias — unique atom identifier
  • :type:local
  • :model_dir — directory where the model file is stored
  • :filename — file name of the .gguf model (e.g. "llama-3-8b.gguf")
  • :download_url — URL to download the model from (HuggingFace, etc.)
  • :context_size — context window in tokens (default: 4096)
  • :engine — atom alias of the Candil.Engine to use
  • :usage — list of intended usages (see below)
  • :model_args — extra CLI args passed to the engine at model load time

Remote model fields

  • :alias — unique atom identifier
  • :type:remote
  • :name — provider model ID (e.g. "gpt-4o", "claude-opus-4-5")
  • :context_size — context window in tokens
  • :provider — atom alias of the Candil.Provider to use
  • :usage — list of intended usages

Usage types

:chat, :completion, :embeddings, :reasoning, :vision, :code, :translation, :summarisation

Summary

Functions

Returns true if the model file exists on disk.

Returns the full path to the model file on disk.

Returns all valid usage type atoms.

Validates a model struct. Returns :ok or {:error, [reasons]}.

Types

model_type()

@type model_type() :: :local | :remote

t()

@type t() :: %Candil.Model{
  alias: atom(),
  context_size: pos_integer(),
  download_url: binary() | nil,
  engine: atom() | nil,
  filename: binary() | nil,
  model_args: [binary()],
  model_dir: binary() | nil,
  name: binary() | nil,
  provider: atom() | nil,
  type: model_type(),
  usage: [usage()]
}

usage()

@type usage() ::
  :chat
  | :completion
  | :embeddings
  | :reasoning
  | :vision
  | :code
  | :translation
  | :summarisation

Functions

downloaded?(model)

@spec downloaded?(t()) :: boolean()

Returns true if the model file exists on disk.

Always returns false for remote models.

file_path(arg1)

@spec file_path(t()) :: binary() | nil

Returns the full path to the model file on disk.

Returns nil for remote models.

usage_types()

@spec usage_types() :: [usage()]

Returns all valid usage type atoms.

validate(model)

@spec validate(t()) :: :ok | {:error, [binary()]}

Validates a model struct. Returns :ok or {:error, [reasons]}.