Agentic.ModelRouter.Selector
(agentic v0.2.2)
Copy Markdown
Scores and ranks catalog models based on an Analyzer.analysis() result
and a user Preference.
Returns an ordered list of {model, score} tuples (lowest score first).
Models with missing required capabilities receive heavy penalties so they
sink to the bottom but remain available as fallbacks.
Summary
Types
@type ranked_model() :: {Agentic.LLM.Model.t(), float()}
Functions
@spec rank( Agentic.ModelRouter.Analyzer.analysis(), Agentic.ModelRouter.Preference.preference(), keyword() ) :: [ranked_model()]
Rank all candidate models for a given analysis and preference.
Returns a list of {model, score} tuples sorted by score ascending.
@spec select(String.t(), Agentic.ModelRouter.Preference.preference(), keyword()) :: {:ok, {Agentic.LLM.Model.t(), Agentic.ModelRouter.Analyzer.analysis()}} | {:error, term()}
Analyze a request and return ranked models for the given preference.
This is the main entry point combining analysis + ranking.
When llm_chat is provided, uses LLM-based analysis; otherwise
falls back to heuristic analysis.
Like select/3 but returns all ranked models (not just the best),
so the caller can walk the full list on failure.
@spec top( Agentic.ModelRouter.Analyzer.analysis(), Agentic.ModelRouter.Preference.preference(), pos_integer(), keyword() ) :: [ranked_model()]
Get the top N ranked models.