DaniilAlpha commited on
Commit
233feb1
·
1 Parent(s): 71f5570

Create accelerator.py

Browse files
Files changed (1) hide show
  1. accelerator.py +16 -0
accelerator.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union
2
+ from fastapi import WebSocket
3
+
4
+ class Accelerator:
5
+ _connected = False
6
+ def connected(self): return self._connected
7
+
8
+ ws: Union[WebSocket, None]
9
+
10
+ async def connect(self, ws: WebSocket):
11
+ await ws.accept()
12
+ self.ws = ws
13
+
14
+ async def accelerate(self, input):
15
+ await self.ws.send_text(input)
16
+ return await self.ws.receive_text()