Spaces:
Paused
Paused
Commit
·
1e28d04
1
Parent(s):
5ee61de
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,9 +1,25 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
from
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
-
@app.
|
| 8 |
-
def
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from fastapi import FastAPI, WebSocket
|
| 3 |
|
| 4 |
+
from answerer import Answerer
|
| 5 |
|
| 6 |
+
print(f"HELLO_WORLD: {os.environ['HELLO_WORLD']}")
|
| 7 |
+
|
| 8 |
+
answerer = Answerer(
|
| 9 |
+
repo="BlinkDL/rwkv-5-world",
|
| 10 |
+
filename="RWKV-5-World-3B-v2-20231118-ctx16k",
|
| 11 |
+
vocab="rwkv_vocab_v20230424",
|
| 12 |
+
strategy="cpu bf16",
|
| 13 |
+
ctx_limit=16*1024,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
app = FastAPI()
|
| 17 |
|
| 18 |
+
@app.websocket("/answer")
|
| 19 |
+
async def answer(ws: WebSocket):
|
| 20 |
+
await ws.accept()
|
| 21 |
+
|
| 22 |
+
input = await ws.receive_text()
|
| 23 |
+
stream = answerer(input, 256)
|
| 24 |
+
for el in stream:
|
| 25 |
+
await ws.send_text(el)
|