diff --git a/website/public/locales/en/tasks.json b/website/public/locales/en/tasks.json index 53cfa088..7fa7c452 100644 --- a/website/public/locales/en/tasks.json +++ b/website/public/locales/en/tasks.json @@ -77,5 +77,6 @@ "label": "Classify Assistant Reply", "desc": "Provide labels for a prompt.", "overview": "Read the following conversation and then answer the question about the last reply in the discussion." - } + }, + "available_task_count": "{{count}} tasks available" } diff --git a/website/src/components/Dashboard/TaskOption.tsx b/website/src/components/Dashboard/TaskOption.tsx index 0401fd97..87910695 100644 --- a/website/src/components/Dashboard/TaskOption.tsx +++ b/website/src/components/Dashboard/TaskOption.tsx @@ -1,5 +1,7 @@ import { + Badge, Box, + Card, Flex, GridItem, Heading, @@ -8,7 +10,6 @@ import { SimpleGrid, Spacer, Text, - useColorModeValue, } from "@chakra-ui/react"; import { HelpCircle } from "lucide-react"; import Link from "next/link"; @@ -20,18 +21,17 @@ import { TaskCategory, TaskInfo, TaskType } from "src/types/Task"; import { TaskCategoryLabels, TaskInfos } from "../Tasks/TaskTypes"; export interface TasksOptionProps { - content: Partial>; + content: Partial>>; } export const TaskOption = ({ content }: TasksOptionProps) => { const { t } = useTranslation(["dashboard", "tasks"]); - const backgroundColor = useColorModeValue("white", "gray.700"); const taskInfoMap = useMemo( () => Object.values(content) .flat() - .reduce((obj, taskType) => { + .reduce((obj, { taskType }) => { obj[taskType] = TaskInfos.filter((t) => t.type === taskType).pop(); return obj; }, {} as Record), @@ -53,23 +53,35 @@ export const TaskOption = ({ content }: TasksOptionProps) => { {taskTypes - .map((taskType) => taskInfoMap[taskType]) + .map(({ taskType, count }) => ({ ...taskInfoMap[taskType], count })) .map((item) => ( - - - {t(getTypeSafei18nKey(`tasks:${item.id}.label`))} - {t(getTypeSafei18nKey(`tasks:${item.id}.desc`))} + + + + {t(getTypeSafei18nKey(`tasks:${item.id}.label`))} + {t(getTypeSafei18nKey(`tasks:${item.id}.desc`))} + + + + {t("tasks:available_task_count", { count: item.count })} + + {t("go")} -> @@ -85,12 +97,20 @@ export const TaskOption = ({ content }: TasksOptionProps) => { }; export const allTaskOptions: TasksOptionProps["content"] = { - [TaskCategory.Random]: [TaskType.random], - [TaskCategory.Create]: [TaskType.initial_prompt, TaskType.prompter_reply, TaskType.assistant_reply], - [TaskCategory.Evaluate]: [ - TaskType.rank_initial_prompts, - TaskType.rank_prompter_replies, - TaskType.rank_assistant_replies, + [TaskCategory.Random]: [{ taskType: TaskType.random, count: 0 }], + [TaskCategory.Create]: [ + { taskType: TaskType.initial_prompt, count: 0 }, + { taskType: TaskType.prompter_reply, count: 0 }, + { taskType: TaskType.assistant_reply, count: 0 }, + ], + [TaskCategory.Evaluate]: [ + { taskType: TaskType.rank_initial_prompts, count: 0 }, + { taskType: TaskType.rank_prompter_replies, count: 0 }, + { taskType: TaskType.rank_assistant_replies, count: 0 }, + ], + [TaskCategory.Label]: [ + { taskType: TaskType.label_initial_prompt, count: 0 }, + { taskType: TaskType.label_prompter_reply, count: 0 }, + { taskType: TaskType.label_assistant_reply, count: 0 }, ], - [TaskCategory.Label]: [TaskType.label_initial_prompt, TaskType.label_prompter_reply, TaskType.label_assistant_reply], }; diff --git a/website/src/pages/dashboard.tsx b/website/src/pages/dashboard.tsx index 23fcec06..94c25e57 100644 --- a/website/src/pages/dashboard.tsx +++ b/website/src/pages/dashboard.tsx @@ -59,4 +59,4 @@ const filterAvailableTasks = (availableTasks: Partial) => Object.entries(availableTasks) .filter(([, count]) => count > 0) .sort((a, b) => b[1] - a[1]) - .map(([taskType]) => taskType) as TaskType[]; + .map(([taskType, count]) => ({ taskType, count })) as Array<{ taskType: TaskType; count: number }>;