Spaces:
Sleeping
Sleeping
Download test.js from afnhf/dynamo-backend: direct link, hf CLI and curl.
- Browser
- Download file 675 Bytes
-
https://huggingface.co/spaces/afnhf/dynamo-backend/resolve/main/test.js
- Command line
-
hf download hf://spaces/afnhf/dynamo-backend/test.js
-
curl -L -o test.js https://huggingface.co/spaces/afnhf/dynamo-backend/resolve/main/test.js
675 Bytes
| async function stream() { | |
| const response = await fetch(`http://127.0.0.1:8000/dynamo/?prompt=tell+me+a+joke`); | |
| const reader = response.body.getReader(); | |
| const decoder = new TextDecoder(); | |
| while (true) { | |
| const { done, value } = await reader.read(); | |
| if (done) break; | |
| const text = decoder.decode(value); | |
| const lines = text.split("\n\n").filter(line => line.startsWith("data: ")); | |
| for (const line of lines) { | |
| const data = line.replace("data: ", "").trim(); | |
| if (data === "[DONE]") return; | |
| const { token } = JSON.parse(data); | |
| console.log(token); | |
| } | |
| } | |
| } | |
| stream(); |