adk_llm behaviour (erlang_adk v0.7.0)

View Source

Summary

Functions

Return normalized adapter capabilities. Unknown custom providers remain usable and conservatively report only the two required behavior callbacks.

Dispatch the call to the specified provider.

Dispatch the streaming call to the specified provider.

Dispatch the optional canonical content-delta stream. Providers which implement text streaming only fail explicitly instead of coercing maps to text or silently dropping parts.

Validate the provider reference and invoke its optional validator.

Types

config/0

-type config() :: map().

memory/0

-type memory() :: [map()].

provider_outcome/0

-type provider_outcome() ::
          {ok, binary() | string() | adk_content:content()} | {tool_calls, list()} | streamed.

provider_result/0

-type provider_result() ::
          {provider_result,
           #{version := 1,
             provider := binary(),
             type := binary(),
             outcome := provider_outcome(),
             metadata := map()}}.

tools/0

-type tools() :: [module() | map()].

Callbacks

capabilities/0

(optional)
-callback capabilities() -> map().

generate/3

-callback generate(Config :: config(), Memory :: memory(), Tools :: tools()) ->
                      {ok, binary() | string() | adk_content:content()} |
                      {tool_calls, list()} |
                      provider_result() |
                      {error, term()}.

stream/4

-callback stream(Config :: config(),
                 Memory :: memory(),
                 Tools :: tools(),
                 Callback :: fun((binary()) -> ok)) ->
                    ok | {tool_calls, list()} | provider_result() | {error, term()}.

stream_content/4

(optional)
-callback stream_content(Config :: config(),
                         Memory :: memory(),
                         Tools :: tools(),
                         Callback :: fun((adk_content:content()) -> ok)) ->
                            ok | {tool_calls, list()} | provider_result() | {error, term()}.

validate_config/1

(optional)
-callback validate_config(Config :: config()) -> ok | {error, term()}.

Functions

capabilities(Provider)

-spec capabilities(config() | module()) -> {ok, map()} | {error, term()}.

Return normalized adapter capabilities. Unknown custom providers remain usable and conservatively report only the two required behavior callbacks.

generate(Config, Memory, Tools)

Dispatch the call to the specified provider.

stream(Config, Memory, Tools, Callback)

Dispatch the streaming call to the specified provider.

stream_content(Config, Memory, Tools, Callback)

Dispatch the optional canonical content-delta stream. Providers which implement text streaming only fail explicitly instead of coercing maps to text or silently dropping parts.

validate_config(Config)

-spec validate_config(config()) -> ok | {error, term()}.

Validate the provider reference and invoke its optional validator.