Firstly, you should use a template, the how-to is described here: Running a Bokeh server — Bokeh 2.3.2 Documentation
Inside the template you can declare any (local) resources that you want to have loaded into your application. Now you can simply evoke a custom function using a JSCallback, e.g.:
CustomJS(code=“myfunc();”). If you pass a reference of the bokeh-object that you want to manipulate to your own code you can ofcoure manipulate it there, as well. (I did something similar recently)
If you want to do this from a Notebook, it’d be slightly harder to embed your custom code I believe.
Something handy I came across is:
You can execude abritrary JS from the bokeh server by creating a
PreText-Widget. And abusing it a bit, like so: https://stackoverflow.com/a/42692856 .
That way you can access your custom modules a bit more easily and customizably.
If you want to just share data from non-connected callbacks you could temporarily save data in the browser by putting it in e.g., window.callback2_data and access it from the other callback