mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-10 11:50:44 +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:
@@ -1,3 +1,4 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { getToken } from "next-auth/jwt";
|
||||
import { oasstApiClient } from "src/lib/oasst_api_client";
|
||||
import prisma from "src/lib/prismadb";
|
||||
@@ -6,9 +7,11 @@ import prisma from "src/lib/prismadb";
|
||||
* Stores the task interaction with the Task Backend and then returns the next task generated.
|
||||
*
|
||||
* This implicity does a few things:
|
||||
* 1) Stores the answer with the Task Backend.
|
||||
* 2) Records the new task in our local database.
|
||||
* 3) Returns the newly created task to the client.
|
||||
* 1) Records the users answer in our local database.
|
||||
* 2) Accepts the task.
|
||||
* 3) Sends the users answer to the Task Backend.
|
||||
* 4) Records the new task in our local database.
|
||||
* 5) Returns the newly created task to the client.
|
||||
*/
|
||||
const handler = async (req, res) => {
|
||||
const token = await getToken({ req });
|
||||
@@ -20,7 +23,13 @@ const handler = async (req, res) => {
|
||||
}
|
||||
|
||||
// Parse out the local task ID and the interaction contents.
|
||||
const { id, content, update_type } = await JSON.parse(req.body);
|
||||
const { id: frontendId, content, update_type } = await JSON.parse(req.body);
|
||||
|
||||
// Accept the task so that we can complete it, this will probably go away soon.
|
||||
const registeredTask = await prisma.registeredTask.findUniqueOrThrow({ where: { id: frontendId } });
|
||||
const task = registeredTask.task as Prisma.JsonObject;
|
||||
const id = task.id as string;
|
||||
await oasstApiClient.ackTask(id, registeredTask.id);
|
||||
|
||||
// Log the interaction locally to create our user_post_id needed by the Task
|
||||
// Backend.
|
||||
@@ -29,7 +38,7 @@ const handler = async (req, res) => {
|
||||
content,
|
||||
task: {
|
||||
connect: {
|
||||
id,
|
||||
id: frontendId,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -37,7 +46,7 @@ const handler = async (req, res) => {
|
||||
|
||||
let newTask;
|
||||
try {
|
||||
newTask = await oasstApiClient.interactTask(update_type, id, interaction.id, content, token);
|
||||
newTask = await oasstApiClient.interactTask(update_type, frontendId, interaction.id, content, token);
|
||||
} catch (err) {
|
||||
return res.status(500).json(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user