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

Functions

Rank all candidate models for a given analysis and preference.

Analyze a request and return ranked models for the given preference.

Like select/3 but returns all ranked models (not just the best), so the caller can walk the full list on failure.

Get the top N ranked models.

Types

ranked_model()

@type ranked_model() :: {Agentic.LLM.Model.t(), float()}

Functions

rank(analysis, preference, opts \\ [])

Rank all candidate models for a given analysis and preference.

Returns a list of {model, score} tuples sorted by score ascending.

select(request, preference, opts \\ [])

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.

select_all(request, preference, opts \\ [])

Like select/3 but returns all ranked models (not just the best), so the caller can walk the full list on failure.

top(analysis, preference, n \\ 3, opts \\ [])

Get the top N ranked models.