diff --git a/website/src/components/Dashboard/TaskOption.tsx b/website/src/components/Dashboard/TaskOption.tsx index 1c070e17..43bcabea 100644 --- a/website/src/components/Dashboard/TaskOption.tsx +++ b/website/src/components/Dashboard/TaskOption.tsx @@ -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 ( diff --git a/website/src/components/Tasks/LabelTask.tsx b/website/src/components/Tasks/LabelTask.tsx index 9c08932c..04a9c1d3 100644 --- a/website/src/components/Tasks/LabelTask.tsx +++ b/website/src/components/Tasks/LabelTask.tsx @@ -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); }; diff --git a/website/src/components/Tasks/TaskTypes.tsx b/website/src/components/Tasks/TaskTypes.tsx index f2e00df5..fd37536e 100644 --- a/website/src/components/Tasks/TaskTypes.tsx +++ b/website/src/components/Tasks/TaskTypes.tsx @@ -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", diff --git a/website/src/pages/dashboard.tsx b/website/src/pages/dashboard.tsx index ece95212..d296592d 100644 --- a/website/src/pages/dashboard.tsx +++ b/website/src/pages/dashboard.tsx @@ -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 = () => { Dashboard - Open Assistant - + ); diff --git a/website/src/pages/tasks/all.tsx b/website/src/pages/tasks/all.tsx index 6e4e926b..ed0659c8 100644 --- a/website/src/pages/tasks/all.tsx +++ b/website/src/pages/tasks/all.tsx @@ -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 = () => { All Tasks - Open Assistant - + ); }; diff --git a/website/src/pages/tasks/random.tsx b/website/src/pages/tasks/random.tsx new file mode 100644 index 00000000..e61fe325 --- /dev/null +++ b/website/src/pages/tasks/random.tsx @@ -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 ; + } + + if (tasks.length == 0) { + return No tasks found...; + } + + return ( + <> + + Random Task + + + + + ); +}; + +export default RandomTask;