Merge pull request #621 from kostiak/website-random-task3

Added random task and moved other tasks to /tasks/all
This commit is contained in:
Keith Stevens
2023-01-11 18:41:53 +09:00
committed by GitHub
6 changed files with 56 additions and 7 deletions
@@ -1,11 +1,9 @@
import { Box, Flex, GridItem, Heading, SimpleGrid, Text, useColorModeValue } from "@chakra-ui/react";
import Link from "next/link";
import { TaskCategory, TaskTypes } from "../Tasks/TaskTypes";
import { TaskTypes } from "../Tasks/TaskTypes";
const displayTaskCategories = [TaskCategory.Create, TaskCategory.Evaluate, TaskCategory.Label];
export const TaskOption = () => {
export const TaskOption = ({ displayTaskCategories }) => {
const backgroundColor = useColorModeValue("white", "gray.700");
return (
+4 -1
View File
@@ -24,7 +24,10 @@ export const LabelTask = ({
const onSliderChange = (values: number[]) => {
console.assert(valid_labels.length === sliderValues.length);
const labels = Object.fromEntries(valid_labels.map((label, i) => [label, sliderValues[i]]));
onReplyChanged({ content: { labels, text: task.reply, message_id: task.message_id }, state: "VALID" });
onReplyChanged({
content: { labels, text: task.reply || task.prompt, message_id: task.message_id },
state: "VALID",
});
setSliderValues(values);
};
@@ -1,4 +1,5 @@
export enum TaskCategory {
Tasks = "Tasks",
Create = "Create",
Evaluate = "Evaluate",
Label = "Label",
@@ -18,6 +19,15 @@ export interface TaskInfo {
}
export const TaskTypes: TaskInfo[] = [
// general/random
{
label: "Grab a task",
desc: "Help us improve Open Assistant by grabbing a task ...",
category: TaskCategory.Tasks,
pathname: "/tasks/random",
type: "random",
update_type: "random",
},
// create
{
label: "Create Initial Prompts",
+2 -1
View File
@@ -1,6 +1,7 @@
import Head from "next/head";
import { LeaderboardTable, TaskOption } from "src/components/Dashboard";
import { getDashboardLayout } from "src/components/Layout";
import { TaskCategory } from "src/components/Tasks/TaskTypes";
const Dashboard = () => {
return (
@@ -9,7 +10,7 @@ const Dashboard = () => {
<title>Dashboard - Open Assistant</title>
<meta name="description" content="Chat with Open Assistant and provide feedback." />
</Head>
<TaskOption />
<TaskOption displayTaskCategories={[TaskCategory.Tasks]} />
<LeaderboardTable />
</>
);
+2 -1
View File
@@ -1,6 +1,7 @@
import Head from "next/head";
import { TaskOption } from "src/components/Dashboard";
import { getDashboardLayout } from "src/components/Layout";
import { TaskCategory } from "src/components/Tasks/TaskTypes";
const AllTasks = () => {
return (
@@ -9,7 +10,7 @@ const AllTasks = () => {
<title>All Tasks - Open Assistant</title>
<meta name="description" content="All tasks for Open Assistant." />
</Head>
<TaskOption />
<TaskOption displayTaskCategories={[TaskCategory.Create, TaskCategory.Evaluate, TaskCategory.Label]} />
</>
);
};
+36
View File
@@ -0,0 +1,36 @@
import { Container } from "@chakra-ui/react";
import Head from "next/head";
import { useEffect } from "react";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useGenericTaskAPI } from "src/hooks/tasks/useGenericTaskAPI";
const RandomTask = () => {
const { tasks, isLoading, trigger, reset } = useGenericTaskAPI("random");
useEffect(() => {
if (tasks.length == 0) {
reset();
}
}, [tasks]);
if (isLoading) {
return <LoadingScreen text="Loading..." />;
}
if (tasks.length == 0) {
return <Container className="p-6 text-center text-gray-800">No tasks found...</Container>;
}
return (
<>
<Head>
<title>Random Task</title>
<meta name="description" content="Random Task." />
</Head>
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
</>
);
};
export default RandomTask;