Agentic.ModelRouter.Analyzer (agentic v0.2.2)

Copy Markdown

Analyzes a user request using a fast, ideally free model to determine complexity, required capabilities (vision, audio, reasoning, etc.), and context requirements.

The analysis result is then used by Agentic.ModelRouter.Selector to pick the best model based on user preferences.

Summary

Functions

Analyze a user request for complexity and capability requirements.

Pure heuristic analysis — no LLM call. Used as fallback when no lightweight model is available or when the caller wants zero-latency analysis.

Find the cheapest available model suitable for analysis.

Types

analysis()

@type analysis() :: %{
  complexity: complexity(),
  required_capabilities: [atom()],
  needs_vision: boolean(),
  needs_audio: boolean(),
  needs_reasoning: boolean(),
  needs_large_context: boolean(),
  estimated_input_tokens: non_neg_integer(),
  explanation: String.t()
}

complexity()

@type complexity() :: :simple | :moderate | :complex

Functions

analyze(request, opts \\ [])

@spec analyze(
  String.t(),
  keyword()
) :: {:ok, analysis()}

Analyze a user request for complexity and capability requirements.

Uses the cheapest available model (preferring free models) to classify the request. Falls back to heuristic analysis if no model is available.

analyze_heuristic(request)

@spec analyze_heuristic(String.t()) :: {:ok, analysis()}

Pure heuristic analysis — no LLM call. Used as fallback when no lightweight model is available or when the caller wants zero-latency analysis.

find_analysis_model()

Find the cheapest available model suitable for analysis.