GenAI.Model.EncoderBehaviour behaviour
(GenAI Core v0.3.0)
Copy Markdown
Summary
Callbacks
Format message for provider/model type.
Format tool for provider/model type.
Prepare endpoint and method to make inference call to
Prepare request headers
Obtain list of hyper params supported by given model including mapping and conditional rules/alterations
Prepare request body to be passed to inference call.
Set setting with dynamic model based logic.
Set setting as_setting with dynamic model based logic.
Types
@type completion() :: any()
@type context() :: any()
@type headers() :: list()
@type json() :: any()
@type message() :: any()
@type messages() :: list()
@type method() :: :get | :post | :put | :delete | :option | :patch
@type model() :: any()
@type options() :: any()
@type request_body() :: any()
@type session() :: any()
@type settings() :: map()
@type tool() :: any()
@type tools() :: list() | nil
@type uri() :: url()
@type url() :: String.t()
Callbacks
@callback encode_message(message(), model(), session(), context(), options()) :: {:ok, {message(), session()}} | {:error, term()}
Format message for provider/model type.
@callback encode_tool(tool(), model(), session(), context(), options()) :: {:ok, {tool(), session()}} | {:error, term()}
Format tool for provider/model type.
@callback endpoint(model(), settings(), session(), context(), options()) :: {:ok, {method(), uri()}} | {:ok, {{method(), uri()}, session()}} | {:error, term()}
Prepare endpoint and method to make inference call to
@callback headers(model(), settings(), session(), context(), options()) :: {:ok, headers()} | {:ok, {headers(), session()}} | {:error, term()}
Prepare request headers
@callback hyper_params(model(), settings(), session(), context(), options()) :: {:ok, {settings(), session()}} | {:error, term()}
Obtain list of hyper params supported by given model including mapping and conditional rules/alterations
@callback request_body( model(), messages(), tools(), settings(), session(), context(), options() ) :: {:ok, headers()} | {:ok, {headers(), session()}} | {:error, term()}
Prepare request body to be passed to inference call.
@callback with_dynamic_setting( body :: term(), setting :: term(), model :: term(), settings :: term() ) :: term()
Set setting with dynamic model based logic.
@callback with_dynamic_setting_as( body :: term(), as_setting :: term(), setting :: term(), model :: term(), settings :: term() ) :: term()
Set setting as_setting with dynamic model based logic.