LazyDoc.Provider behaviour (LazyDoc v0.5.3)
View SourceMain 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
Returns whether the parameters are valid according to the given callback module.
Returns the documents extracted from the response using the specified callback module.
Returns the result of invoking the model method on the specified callback module with the given model.
Returns the result of the request prompt operation initiated with the provided parameters.
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
Returns whether the parameters are valid according to the given callback module.
Parameters
- callback_module - the module that contains the check_parameters? method to validate the parameters.
- params - the parameters to be validated against the callback module's method.
Description
Invokes the check_parameters? method on the specified callback module to verify the validity of the provided parameters.
@spec get_docs_from_response( callback_module :: module(), response :: Req.Response.t() ) :: binary()
Returns the documents extracted from the response using the specified callback module.
Parameters
- callback_module - the module responsible for handling the response and extracting the documents.
- response - the data response from which documents need to be extracted.
Description
Calls the method get_docs_from_response in the provided callback module to process the response.
Returns the result of invoking the model method on the specified callback module with the given model.
Parameters
- callback_module - the module that contains the model method.
- model - the data structure or object to be processed by the model method.
Description
Invokes the model method from the provided callback module with the specified model argument.
@spec request_prompt( callback_module :: module(), prompt :: binary(), model :: binary(), token :: binary(), params :: keyword() ) :: {:ok, Req.Response.t()} | {:error, Exception.t()}
Returns the result of the request prompt operation initiated with the provided parameters.
Parameters
- callback_module - The module used to handle the request.
- prompt - The prompt that will be processed by the model.
- model - The model that will be utilized for generating the response.
- token - An authorization token for the request.
- params - Optional additional parameters for the request.
Description
Executes a request through the specified callback module using the given prompt and model.