Spaces:
Build error
Build error
File size: 772 Bytes
2772555 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
// 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();
|