Real-Time Function Update

I’m trying to add some sort of callback that would allow me to update my function call input data to change a currently running Bokeh plot accordingly in rtt.py:

from bokeh.io import output_file,show
from bokeh.driving import count
from bokeh.server.server import Server
from bokeh.models import ColumnDataSource, HoverTool, Button, Label
from bokeh.plotting import curdoc, figure
from bokeh.client import push_session
import math
import time

def parameters(a,b,c,d):
    def sinusoid(doc):
            t_initial=time.time()
            source = ColumnDataSource({"x": [], "y": []})
            sinPlot = figure(x_range=(1,10),plot_width=700)
            sinPlot.line("x", "y", source=source) 
    
            @count()
            def update(t):
                t =(time.time()-t_initial)*3
                test={'x':[t], 'y':[a*math.sin(b*t+c)+d]}
                source.stream(test)
                sinPlot.x_range.start=t-20
                sinPlot.x_range.end=t
                
            doc.add_root(sinPlot)
            doc.add_periodic_callback(update,20)
            
            

            print("Function runs")
            print(a,b,c,d)
            
        
    server = Server({'/': sinusoid}, num_procs=1)
    server.start()
    server.io_loop.add_callback(server.show, "/")
    server.io_loop.start()

The plan is to call rtt.parameters(1,1,0,1) , have it plot accordingly, then add a callback or call rtt.parameters(1,2,3,4) again with different inputs (such as updating a,b,c,d). Hopefully this would update the plot that is currently graphing.
Is this possible with Bokeh imported as a library?

Hi @Stoze please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

Apologies for wrong formatting. Should be fixed now!