DaniilAlpha commited on
Commit
a3ccca5
·
1 Parent(s): 1e28d04

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +33 -2
main.py CHANGED
@@ -3,8 +3,6 @@ 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",
@@ -15,6 +13,39 @@ answerer = Answerer(
15
 
16
  app = FastAPI()
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  @app.websocket("/answer")
19
  async def answer(ws: WebSocket):
20
  await ws.accept()
 
3
 
4
  from answerer import Answerer
5
 
 
 
6
  answerer = Answerer(
7
  repo="BlinkDL/rwkv-5-world",
8
  filename="RWKV-5-World-3B-v2-20231118-ctx16k",
 
13
 
14
  app = FastAPI()
15
 
16
+ HTML = """
17
+ <!DOCTYPE HTML>
18
+
19
+ <html>
20
+
21
+ <body>
22
+ <form action="" onsubmit="sendMessage(event)">
23
+ <input id="prompt" type="text" autocomplete="off"/>
24
+ <button>SEND</button>
25
+ </form>
26
+
27
+ <p id="output"></p>
28
+ <script>
29
+ const prompt = document.getElementById("prompt");
30
+ const output = document.getElementById("output");
31
+
32
+ const ws = new WebSocket("ws://huggingface.co/spaces/DaniilAlpha/answerer-api:8000/answer");
33
+ ws.onmessage = function (event) => output.innerText = event.data;
34
+
35
+ function ask(event) {
36
+ ws.send(prompt.value);
37
+ event.preventDefault();
38
+ }
39
+ </script>
40
+ </body>
41
+
42
+ </html>
43
+ """
44
+
45
+ @app.get("/")
46
+ async def index():
47
+ return HTMLResponse(HTML)
48
+
49
  @app.websocket("/answer")
50
  async def answer(ws: WebSocket):
51
  await ws.accept()