-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #884 from LAION-AI/available
Present available task types on dashboard
- Loading branch information
Showing
6 changed files
with
75 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,75 @@ | ||
import { Box, Flex, GridItem, Heading, SimpleGrid, Text, useColorModeValue } from "@chakra-ui/react"; | ||
import Link from "next/link"; | ||
import { useMemo } from "react"; | ||
import { TaskType } from "src/types/Task"; | ||
|
||
import { TaskCategory, TaskCategoryLabels, TaskTypes } from "../Tasks/TaskTypes"; | ||
import { TaskCategory, TaskCategoryLabels, TaskInfo, TaskInfos } from "../Tasks/TaskTypes"; | ||
|
||
export const TaskOption = ({ displayTaskCategories }: { displayTaskCategories: TaskCategory[] }) => { | ||
export interface TasksOptionProps { | ||
content: Partial<Record<TaskCategory, TaskType[]>>; | ||
} | ||
|
||
export const TaskOption = ({ content }: TasksOptionProps) => { | ||
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<TaskType, TaskInfo>), | ||
[content] | ||
); | ||
|
||
return ( | ||
<Box className="flex flex-col gap-14"> | ||
{displayTaskCategories.map((category) => ( | ||
{Object.entries(content).map(([category, taskTypes]) => ( | ||
<div key={category}> | ||
<Text className="text-2xl font-bold pb-4">{TaskCategoryLabels[category]}</Text> | ||
<Heading size="lg" className="pb-4"> | ||
{TaskCategoryLabels[category]} | ||
</Heading> | ||
<SimpleGrid columns={[1, 1, 2, 2, 3, 4]} gap={4}> | ||
{TaskTypes.filter((task) => task.category === category).map((item) => ( | ||
<Link key={category + item.label} href={item.pathname}> | ||
<GridItem | ||
bg={backgroundColor} | ||
borderRadius="xl" | ||
boxShadow="base" | ||
className="flex flex-col justify-between h-full" | ||
> | ||
<Box className="p-6 pb-10"> | ||
<Flex flexDir="column" gap="3"> | ||
<Heading size="md" fontFamily="inter"> | ||
{item.label} | ||
</Heading> | ||
<Text size="sm" opacity="80%"> | ||
{item.desc} | ||
</Text> | ||
</Flex> | ||
</Box> | ||
<Box | ||
bg="blue.500" | ||
borderBottomRadius="xl" | ||
className="px-6 py-2 transition-colors duration-300" | ||
_hover={{ backgroundColor: "blue.600" }} | ||
{taskTypes | ||
.map((taskType) => taskInfoMap[taskType]) | ||
.map((item) => ( | ||
<Link key={category + item.label} href={item.pathname}> | ||
<GridItem | ||
bg={backgroundColor} | ||
borderRadius="xl" | ||
boxShadow="base" | ||
className="flex flex-col justify-between h-full" | ||
> | ||
<Text fontWeight="bold" color="white"> | ||
<Flex className="p-6 pb-10" flexDir="column" gap="3"> | ||
<Heading size="md">{item.label}</Heading> | ||
<Text size="sm">{item.desc}</Text> | ||
</Flex> | ||
<Text | ||
fontWeight="bold" | ||
color="white" | ||
borderBottomRadius="xl" | ||
className="px-6 py-2 transition-colors duration-300 bg-blue-500 hover:bg-blue-600" | ||
> | ||
Go -> | ||
</Text> | ||
</Box> | ||
</GridItem> | ||
</Link> | ||
))} | ||
</GridItem> | ||
</Link> | ||
))} | ||
</SimpleGrid> | ||
</div> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
|
||
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], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters