@hook decorator, while other hooks run synchronously.
1
Create a Python file
background_hooks_decorator.py
2
Set up your virtual environment
3
Install dependencies
4
Export your OpenAI API key
5
Run the server
6
Test the endpoint
log_analytics completes. Check the server logs to see log_request and send_notification executing in the background.What Happens
- The agent processes the request
log_analyticsruns synchronously (blocks the response)- The response is sent to the user
log_requestandsend_notificationrun in the background- The user only waits for
log_analyticsto complete