42 lines
636 B
Python
42 lines
636 B
Python
|
|
import time
|
||
|
|
|
||
|
|
from baseController import BaseController
|
||
|
|
|
||
|
|
class Controller(BaseController):
|
||
|
|
|
||
|
|
model = None
|
||
|
|
|
||
|
|
tokenizer = None
|
||
|
|
|
||
|
|
counter = 0
|
||
|
|
|
||
|
|
def getModelPath(self, params):
|
||
|
|
|
||
|
|
return {"Model": self.model}
|
||
|
|
|
||
|
|
def getTokenizer(self, params):
|
||
|
|
|
||
|
|
return {"Tokenizer": self.tokenizer}
|
||
|
|
|
||
|
|
def increment(self, params):
|
||
|
|
|
||
|
|
self.counter += params.get("by", 1)
|
||
|
|
|
||
|
|
return {"counter": self.counter}
|
||
|
|
|
||
|
|
def reset(self, params):
|
||
|
|
|
||
|
|
self.counter = 0
|
||
|
|
|
||
|
|
return {"counter": self.counter}
|
||
|
|
|
||
|
|
def testStream(self, params):
|
||
|
|
|
||
|
|
for i in range(5):
|
||
|
|
|
||
|
|
time.sleep(0.5)
|
||
|
|
|
||
|
|
self.send({"partial": f"step {i+1} complete"})
|
||
|
|
|
||
|
|
return {"counter": self.counter}
|