LazyDoc.Provider behaviour (LazyDoc v0.6.2)
View SourceThe module LazyDoc.Provider provides a standardized interface for making requests to various documentation providers through a defined set of operations.
Description
It defines a set of callbacks that allow for interaction with a documentation provider, enabling the request of prompts, extraction of documentation from responses, and validation of parameters. This facilitates the seamless integration of different providers by allowing the specific implementation details to be abstracted away. The module also includes functions that utilize these callbacks, ensuring that any provider can be utilized in a uniform manner.
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.