Skip to content

erllama 0.10.0

Choose a tag to compare

@benoitc benoitc released this 23 Aug 12:52
· 15 commits to main since this release
ee6195d

Changed

  • Vendored llama.cpp bumped from b10068 to b10593 (vendor/ is now kept
    whole: upstream builds it as CMake targets). model_opts gains
    load_mode (upstream's llama_load_mode); use_mmap / use_mlock
    are mapped onto it.

Removed (BREAKING)

  • unload_model/1 (use unload/1), models/0 (use
    list_models/0), list_cached_prefixes/2 (renamed
    cached_prefix_len/2).
  • infer/4: use stream/3 (text or tokens; the receiving
    process is the to option, default the caller). continue/3 takes
    to instead of caller_pid; a missing session_id is
    {error, {missing_option, session_id}}.
  • Stream messages {erllama_token, Ref, _}, {erllama_token_id, Ref, _}, {erllama_thinking_end, Ref, _}, {erllama_done, Ref, _},
    {erllama_error, Ref, _}: every event is now {erllama, Ref, Event} with Event :: {token, Bin} | {token_id, Id} | {thinking, Bin} | {thinking_end, Sig} | {done, Stats} | {error, Reason}
    (erllama:stream_event()).
  • apply_chat_template/2 renamed render_chat_template/2.
  • chat_apply/2 is chat_apply/3 (model, messages, opts) and
    returns {ok, #{prompt, params}}; messages and tools are Erlang
    maps, JSON encoding happens at the NIF boundary.
  • verify/4 returns {ok, #{accepted, next}}.
  • set_observer/1 and clear_observer/0: use a
    middleware (erllama_middleware, guides/middleware.md).
  • Application environment: chat_params_cache_size renamed
    chat_cache_size; quota_mb dropped from the tiers entries.

Changed (BREAKING)

  • Every per-model call returns {ok, Result} or {error, not_loaded}
    for an unknown or stopped model instead of exiting with noproc:
    model_info/1, status/1, phase/1, pending_len/1,
    queue_depth/1, last_cache_hit/1, list_adapters/1 now wrap
    their result in {ok, _}; unload/1, evict/1, shutdown/1,
    end_session/2 return {error, not_loaded}.
  • load_model/1,2 validates the config (erllama_opts): backend
    defaults to erllama_model_llama; a missing model_path is
    {error, {missing_config, model_path}}, a missing file is
    {error, {invalid_config, model_path, Path}}, an unknown key is
    {error, {unknown_option, Key}}. model_id in the config map is
    honoured by load_model/1.
  • complete/3, prefill_only/3 and infer/4 validate their option
    maps: unknown keys are {error, {unknown_option, Key}}, wrong types
    {error, {invalid_option, Key, Value}}.
  • response_tokens defaults to 64 on every path (complete/3 used 4).
  • evict/1 and shutdown/1 honour the evict_save_timeout_ms
    application environment key (default 30 s); it was documented but
    unread.
  • list_adapters/1 entries use the key adapter (was handle).

Added

  • erllama:stream/3 and erllama:collect/2: streaming inference
    with a typed event envelope and a collector that folds the events
    into a stream_result().
  • erllama:chat/3: one chat turn (render, generate, parse) with
    Erlang-term messages and tools; returns the parsed assistant
    message with content, reasoning and tool calls.
  • erllama:embed/2 accepts text; erllama:embed_batch/2 embeds a
    list of inputs in one round-trip to the model process.
  • erllama:whereis/1 returns the model pid for monitoring.
  • Supervised cache tiers: erllama_cache:add_tier/1, remove_tier/1,
    list_tiers/0, info/0, and the tiers application environment
    key ([#{name, backend => disk | ram_file, root}]) started with
    the application. load_model checks that tier_srv is running and
    matches tier.
  • erllama_middleware: hackney-style middleware chain around every
    API call (global via the middleware environment key, or per call
    with the middleware option).
  • erllama:pressure/0, pressure_sources/0, requests/0,
    request_info/1.
  • Application environment keys fingerprint_mode (now the default
    for models that do not set it), writer_max_concurrent,
    chat_cache_size, thinking_signing_key, middleware and tiers
    are declared in the app file and documented; os_mon is a
    declared dependency (the system pressure source needs memsup).
  • erllama_scheduler:validate_config/1 checks that model_evictor
    names a loadable module exporting evict_one/0.
  • Documentation: public modules are erllama, erllama_cache,
    erllama_middleware, erllama_scheduler and the
    erllama_model_backend, erllama_model_evictor, erllama_pressure
    behaviours plus the erllama_model_stub test backend; every other
    module is hidden from hexdocs. Guides rewritten around the public
    API (the tool-calls guide now documents chat/3; the
    tool_call_markers option it described never existed). Public
    types are defined in erllama.
  • Tests: shared erllama_test_helpers; no catch Expr left, so the
    suite compiles on OTP 29 without nowarn_deprecated_catch.
  • erllama exports the types its specs use (token_id/0,
    cache_key/0, completion_result/0, stats/0, request_opts/0,
    load_config/0, error_reason/0, ...) and documents every error
    reason in error_reason/0.