mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-07 11:17:38 +08:00
Prompt for reason for skipping.
Note: skipping is only half implemented for labelling and summarisation tasks as those probably need to be changed to use the new Task component.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { getToken } from "next-auth/jwt";
|
||||
import { oasstApiClient } from "src/lib/oasst_api_client";
|
||||
|
||||
const handler = async (req, res) => {
|
||||
const token = await getToken({ req });
|
||||
|
||||
// Return nothing if the user isn't registered.
|
||||
if (!token) {
|
||||
res.status(401).end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse out the local task ID and the interaction contents.
|
||||
const { id: frontendId, reason } = await JSON.parse(req.body);
|
||||
|
||||
const registeredTask = await prisma.registeredTask.findUniqueOrThrow({ where: { id: frontendId } });
|
||||
|
||||
const task = registeredTask.task as Prisma.JsonObject;
|
||||
const id = task.id as string;
|
||||
|
||||
// Update the backend with the rejection
|
||||
await oasstApiClient.nackTask(id, reason);
|
||||
|
||||
// Send the results to the client.
|
||||
res.status(200).json({});
|
||||
};
|
||||
|
||||
export default handler;
|
||||
Reference in New Issue
Block a user