hecate_plugin_llm (hecate_sdk v0.6.2)

View Source

LLM access for plugins via the daemon's serve_llm domain.

Provides capability-based model selection so plugins never hardcode model names. Delegates all LLM operations to the daemon's chat_to_llm and manage_providers modules.

Capabilities

Models are classified into three tiers:

- fast — Smallest, fastest models. Good for classification, extraction, simple Q&A. (e.g. Haiku, GPT-4o-mini, small local)

- balanced — Mid-tier models. Good for most tasks: summarization, code generation, analysis. (e.g. Sonnet, GPT-4o, medium local)

- smart — Largest, most capable models. Good for complex reasoning, planning, architecture. (e.g. Opus, o1/o3, large local)

Usage

   {ok, Model} = hecate_plugin_llm:select_model(#{capability => balanced}),
   {ok, Reply} = hecate_plugin_llm:chat(Model, [
       #{role => <<"user">>, content => <<"Summarize this document">>}
   ]).

Summary

Functions

Send a chat completion request.

Send a chat completion request with options.

Start a streaming chat completion.

List all models available through the daemon's providers.

Select a model by capability tier.

Types

capability/0

-type capability() :: fast | balanced | smart.

Functions

chat(Model, Messages)

-spec chat(binary(), list()) -> {ok, map()} | {error, term()}.

Send a chat completion request.

chat(Model, Messages, Opts)

-spec chat(binary(), list(), map()) -> {ok, map()} | {error, term()}.

Send a chat completion request with options.

Opts may include telemetry fields: venture_id, division_id, agent_id, task_id.

chat_stream(Model, Messages, Opts)

-spec chat_stream(binary(), list(), map()) -> {ok, reference()} | {error, term()}.

Start a streaming chat completion.

Returns {ok, Ref}. The calling process receives messages: {llm_chunk, Ref, ChunkMap} {llm_done, Ref, FinalMap} {llm_error, Ref, Reason}

list_models()

-spec list_models() -> {ok, [map()]} | {error, term()}.

List all models available through the daemon's providers.

select_model(Opts)

-spec select_model(#{capability := capability(), _ => _}) -> {ok, binary()} | {error, term()}.

Select a model by capability tier.

Queries the daemon's available models, classifies each by capability, and returns the best match.

Options: capability — fast | balanced | smart (required) provider — binary(), restrict to a specific provider (optional)

Returns the model name (binary) suitable for chat/2,3.