LemonAi. Provider behaviour
(lemon_ai v0.1.0)
View Source
Behaviour for LLM provider implementations.
Each provider (Anthropic, OpenAI, Google, etc.) implements this behaviour to provide a unified streaming interface.
Implementing a Provider
defmodule LemonAi.Providers.Anthropic do
@behaviour LemonAi.Provider
@impl true
def stream(model, context, opts) do
# Implementation...
end
end
Summary
Callbacks
API identifier atom.
Get the API key from environment variables for this provider.
Provider identifier atom.
Start streaming a response from the provider.
Callbacks
@callback api_id() :: atom()
API identifier atom.
@callback get_env_api_key() :: String.t() | nil
Get the API key from environment variables for this provider.
@callback provider_id() :: atom()
Provider identifier atom.
@callback stream( LemonAi.Types.Model.t(), LemonAi.Types.Context.t(), LemonAi.Types.StreamOptions.t() ) :: {:ok, LemonAi.EventStream.t()} | {:error, term()}
Start streaming a response from the provider.
Returns an EventStream that emits events as the response is generated.
The caller should consume events using EventStream.events/1 or
wait for the final result with EventStream.result/1.