Packages

Protocol-based AI adapter foundation for Elixir. Provides unified abstractions for gemini_ex, claude_agent_sdk, and codex_sdk with automatic fallback support, runtime capability detection, and built-in telemetry.

Current section

Files

Jump to
altar_ai lib altar ai protocols classifier.ex
Raw

lib/altar/ai/protocols/classifier.ex

defprotocol Altar.AI.Classifier do
@moduledoc """
Protocol for text classification.
This protocol defines the interface for adapters that can classify
text into predefined labels/categories.
"""
@doc """
Classify text into one of the provided labels.
## Parameters
- adapter: The adapter struct implementing this protocol
- text: The text to classify
- labels: List of possible classification labels
- opts: Optional keyword list of options
## Returns
- `{:ok, classification}` - Success with classification result
- `{:error, error}` - Error with details
"""
@spec classify(t, String.t(), [String.t()], keyword()) ::
{:ok, Altar.AI.Classification.t()} | {:error, Altar.AI.Error.t()}
def classify(adapter, text, labels, opts \\ [])
end