TaskWeaver icon indicating copy to clipboard operation
TaskWeaver copied to clipboard

Set session variables inside a plugin

Open shivakharbanda opened this issue 1 year ago • 2 comments
trafficstars

I would like to set session variables inside plugin so i can use those variables inside other plugin. Is there a way to do it?

shivakharbanda avatar Apr 24 '24 13:04 shivakharbanda

I haven't tried this, but I think it is doable as all the executions in the same session share the same context. But I think you need to modify the code in context.py. You can find the following code there

    def get_session_var(
        self,
        variable_name: str,
        default: Optional[str] = None,
    ) -> Optional[str]:
        if variable_name in self.executor.session_var:
            return self.executor.session_var[variable_name]
        return default

What you need is to implement another function set_session_var accordingly.

liqul avatar Apr 25 '24 02:04 liqul

Okay thank you. I’ll try to implement this

shivakharbanda avatar Apr 25 '24 05:04 shivakharbanda