Spaces:
Runtime error
Runtime error
Download src/lib/server/abortedGenerations.ts from BetterAPI/BetterChat: direct link, hf CLI and curl.
- Browser
- Download file 772 Bytes
-
https://huggingface.co/spaces/BetterAPI/BetterChat/resolve/0592f207c0819df96caa4eb96d1dd79bee3392ad/src/lib/server/abortedGenerations.ts
- Command line
-
hf download hf://spaces/BetterAPI/BetterChat@0592f207c0819df96caa4eb96d1dd79bee3392ad/src/lib/server/abortedGenerations.ts
-
curl -L -o abortedGenerations.ts https://huggingface.co/spaces/BetterAPI/BetterChat/resolve/0592f207c0819df96caa4eb96d1dd79bee3392ad/src/lib/server/abortedGenerations.ts
772 Bytes
| // Shouldn't be needed if we dove into sveltekit internals, see https://github.com/huggingface/chat-ui/pull/88#issuecomment-1523173850 | |
| import { setTimeout } from "node:timers/promises"; | |
| import { collections } from "./database"; | |
| let closed = false; | |
| process.on("SIGINT", () => { | |
| closed = true; | |
| }); | |
| export let abortedGenerations: Map<string, Date> = new Map(); | |
| async function maintainAbortedGenerations() { | |
| while (!closed) { | |
| await setTimeout(1000); | |
| try { | |
| const aborts = await collections.abortedGenerations.find({}).sort({ createdAt: 1 }).toArray(); | |
| abortedGenerations = new Map( | |
| aborts.map(({ conversationId, createdAt }) => [conversationId.toString(), createdAt]) | |
| ); | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| } | |
| } | |
| maintainAbortedGenerations(); | |