LazyDoc.Provider behaviour (LazyDoc v0.5.0)
## Main functionality
The module LazyDoc.Provider provides a standard interface for making requests to an external service and processing the responses.
## Description
It defines a set of callbacks and functions that allow a user to request a prompt, retrieve documents from a response, and interact with models, enabling flexible integration with various providers that conform to this interface.
Summary
Functions
Parameters
- callback_module - a module that implements a
check_parameters?
function. - params - the parameters to be checked for validity.
Description
Validates the given parameters using the specified callback module.
Parameters
- callback_module - a module that contains the method to retrieve documents from a response.
- response - the data response from which to extract documents.
Description
Calls the get_docs_from_response method from the specified callback module with the provided response.
Parameters
- callback_module - The module that contains the callback functions.
- model - The specific model to be processed by the callback module.
Description
Executes the model function of the provided callback module.
Parameters
- callback_module - module responsible for handling the request.
- prompt - the text input or query that needs to be processed.
- model - the specific model to be used for generating a response.
- token - authentication token required for the request.
- params - optional parameters that can be passed to customize the request.
Description
Handles a request for generating a response based on the given prompt using the specified model.
Callbacks
@callback get_docs_from_response(response :: Req.Response.t()) :: binary()
@callback request_prompt( prompt :: binary(), model :: binary(), token :: binary(), params :: keyword() ) :: {:ok, Req.Response.t()} | {:error, Exception.t()}
Functions
Parameters
- callback_module - a module that implements a
check_parameters?
function. - params - the parameters to be checked for validity.
Description
Validates the given parameters using the specified callback module.
Returns
a boolean indicating whether the parameters are valid or not.
@spec get_docs_from_response( callback_module :: module(), response :: Req.Response.t() ) :: binary()
Parameters
- callback_module - a module that contains the method to retrieve documents from a response.
- response - the data response from which to extract documents.
Description
Calls the get_docs_from_response method from the specified callback module with the provided response.
Returns
The documents extracted from the response by the callback module.
Parameters
- callback_module - The module that contains the callback functions.
- model - The specific model to be processed by the callback module.
Description
Executes the model function of the provided callback module.
Returns
The result from invoking the model function in the callback module with the specified model.
@spec request_prompt( callback_module :: module(), prompt :: binary(), model :: binary(), token :: binary(), params :: keyword() ) :: {:ok, Req.Response.t()} | {:error, Exception.t()}
Parameters
- callback_module - module responsible for handling the request.
- prompt - the text input or query that needs to be processed.
- model - the specific model to be used for generating a response.
- token - authentication token required for the request.
- params - optional parameters that can be passed to customize the request.
Description
Handles a request for generating a response based on the given prompt using the specified model.
Returns
the result of the request processed by the callback_module.