<Perception>
Define how your agent handles incoming events.
The <Perception />
allows the Agent to perceive and react to real-world events.
Importing the Perception Component
To use the Perception
component, import it as follows:
The <Perception />
component is used to define and register a perception within the agent's context. It allows the agent to handle specific types of perceptions with custom logic.
Example
Here's an example of how to use the <Perception />
component:
Props
The <Perception />
component accepts the following props:
- type: string The type of perception being registered. This is a required prop and is used to identify the perception. handler: Function A function that handles the perception logic. This function is executed when the perception is triggered.
- children: ReactNode (optional) Any child components or elements to be rendered within the Perception component.
Methods
The <Perception>
component does not expose any public methods. All interaction should be handled through props or by wrapping the component with additional logic.
Best Practices
- Event Handling: Ensure that your event handling logic is efficient and does not block the main thread. Consider using asynchronous functions or web workers for complex processing.
- Configuration: Use the
config
prop to fine-tune the perception logic to suit your specific use case. This can help optimize performance and accuracy.
Troubleshooting
- No Response: If the component does not seem to be responding to events, check that your event handlers are correctly implemented and that the component is properly mounted in the DOM.
- Performance Issues: If you experience performance issues, review your event handling logic and consider optimizing or offloading intensive tasks.