streaming, markdown, model selecting, and lots more
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { httpClient } from '~~/server/lib/triplit';
|
||||
import { cancelPendingGeneration } from '~~/server/utils/generations';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await protectRoute(event);
|
||||
|
||||
const { generationId } = event.context.params!;
|
||||
|
||||
const success = cancelPendingGeneration(generationId!);
|
||||
|
||||
if (!success) {
|
||||
const generation = await httpClient.fetchOne(httpClient.query('generations').Where('id', '=', generationId!));
|
||||
if (generation !== null && generation.status === 'pending') {
|
||||
await httpClient.update('generations', generationId!, {
|
||||
status: 'cancelled',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: 'Generation not found or already completed',
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
Reference in New Issue
Block a user