clever-needle-28108
08/11/2025, 5:37 PMtall-airline-16756
08/11/2025, 5:37 PMtall-airline-16756
08/11/2025, 5:38 PMclass CustomLLMEvent:
def __init__(self, item_id: str, transcript: str, is_final: bool):
self.item_id = item_id
self.transcript = transcript
self.is_final = is_final
1. Emit the Custom Event: Next, use the emit()
method from EventEmitter
to send out your custom event. Here’s an example:
self.emit("custom_event_name", CustomLLMEvent(...))
Then, in your LLM service, you can listen for that custom event like this:
@agent.on("custom_event_name")
def handle_custom_event(event: CustomLLMEvent):
# Process the event
pass
Just make sure your EventEmitter
is properly set up and shared between the parts of your system. This way, your worker and LLM service can chat smoothly, even if they’re running separately.
Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Agents Core Architecture | livekit/livekit_composite | DeepWikiclever-needle-28108
08/11/2025, 5:38 PMtall-airline-16756
08/11/2025, 5:39 PMEventEmitter
between your components, here’s a simple way to do it:
1. Extend the EventEmitter: Start by creating a custom class that extends the EventEmitter
so you can define your own event types:
const EventEmitter = require('events');
class CustomEmitter extends EventEmitter {
constructor() {
super();
}
}
1. Initialize and Share: Then, create just one instance of your CustomEmitter
and share it across the components:
const sharedEmitter = new CustomEmitter();
// Component A
sharedEmitter.on('custom_event', (data) => {
console.log('Event received in Component A:', data);
});
// Component B
sharedEmitter.emit('custom_event', { message: 'Hello from Component B!' });
This way, all components using the same sharedEmitter
can easily talk to each other. If you want me to walk you through it more or need another example, just let me know—I’m here to help!clever-needle-28108
08/11/2025, 5:40 PMtall-airline-16756
08/11/2025, 5:41 PM