File size: 635 Bytes
f52d137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from backend.are import kill_are_process
from backend.session import UserSession


def cleanup(user_session: UserSession) -> None:
    """Logs the user interaction.
    Stops ARE, queries GraphQL to grab the traces, saves them locally, pushes everything to the hub,
    then kills the ARE processes.

    Args:
        request (gr.Request): Automatically accessed
        user_session (gr.State): Storage for user-specific session variables, contains a UserSession
    """

    # The user did not interact with are agent
    if user_session is None:
        return

    # Kill the user are processes
    kill_are_process(user_session)