Custom Actions
Connect your web agent to the wider web
Some times, you'll need to do thing that are tough to achieve using just the built-in actions. For such cases, you can make your own custom action. Custom actions have full access to both the LLM, the browser page, and all other functionality possible within NodeJS.
Components of a custom action
A custom action requires 3 components:
type
: This is used to distinguish a specific action from others available to the LLM. Make it unique and relevant to the task this action is supposed to perform.actionParams
: This describes the parameters that the custom action should accept. It expects a zod object.run
: A function that processes the instructions/parameteres produced by the LLM, and previous actions.
Response
The run of each custom action is required to output a dictionary containing the success
value,and a message describing what happened. This could be the description of the error, or the success response.
Here's a simple example which introduces a custom action to navigate to a random wikipedia page.
An example custom action
How to use
Each instance of HyperAgent accepts an array of customActions
. These actions are used in addition to other built-in actions.
Last updated