import { Box, Flex, GridItem, Heading, IconButton, Link as ExternalLink, SimpleGrid, Spacer, Text, useColorModeValue, } from "@chakra-ui/react"; import { HelpCircle } from "lucide-react"; import Link from "next/link"; import { useTranslation } from "next-i18next"; import { useMemo } from "react"; import { normalizei18nKey } from "src/lib/i18n"; import { TaskType } from "src/types/Task"; import { TaskCategory, TaskCategoryLabels, TaskInfo, TaskInfos } from "../Tasks/TaskTypes"; export interface TasksOptionProps { 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) => { obj[taskType] = TaskInfos.filter((t) => t.type === taskType).pop(); return obj; }, {} as Record), [content] ); return ( {Object.entries(content).map(([category, taskTypes]) => (
{t(TaskCategoryLabels[category])} } /> {taskTypes .map((taskType) => taskInfoMap[taskType]) .map((item) => ( {t(normalizei18nKey(`tasks:${item.id}.label`))} {t(normalizei18nKey(`tasks:${item.id}.desc`))} {t("go")} -> ))}
))}
); }; 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.Label]: [TaskType.label_initial_prompt, TaskType.label_prompter_reply, TaskType.label_assistant_reply], };