The Upstreet Agents SDK is now in public beta 🎉 Get started →
bg-pattern
📚 API ReferenceComponents

<Perception>

The <Perception /> Component allows the Agent to perceive and react to real-world events.

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.

Import

import { Perception } from 'react-agents';

Usage

Here's an example of how to use the <Perception /> component:

import { Perception } from 'react-agents';
 
function MyComponent() {
  return (
    <Perception
      type="visual"
      handler={(data) => {
        console.log('Handling visual perception:', data);
      }}
    >
      {/* Optional child components */}
    </Perception>
  );
}

Props

PropTypeDefault
type
string
N/A
handler
Function
N/A
children
ReactNode
N/A

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.

On this page

Facing an issue? Add a ticket.