GenAI.InferenceProviderBehaviour behaviour
(GenAI Core v0.3.0)
Copy Markdown
Summary
Callbacks
Return config_key inference provide application config stored under :genai entry
Obtain map of effective settings: settings, model_settings, provider_settings, config_settings, etc.
Prepare endpoint and method to make inference call to
Prepare request headers
Prepare request body to be passed to inference call.
Build and run inference thread
Build and run inference thread in streaming mode
Types
@type completion() :: any()
@type context() :: any()
@type headers() :: list()
@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 tools() :: list() | nil
@type uri() :: url()
@type url() :: String.t()
Callbacks
@callback config_key() :: atom()
Return config_key inference provide application config stored under :genai entry
@callback effective_settings(model(), session(), context(), options()) :: {:ok, {settings(), session()}} | {:error, term()}
Obtain map of effective settings: settings, model_settings, provider_settings, config_settings, etc.
@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 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 run(session(), context(), options()) :: {:ok, {completion(), session()}} | {:error, term()}
Build and run inference thread
@callback stream(session(), context(), options()) :: {:ok, {completion(), session()}} | {:error, term()} | :nyi
Build and run inference thread in streaming mode