-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor tasks into components #470
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
pathname: "/evaluate/rank_initial_prompts", | ||
type: "rank_initial_prompts", | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would make more sense to split this array into 2.
One for create and one for evaluate.
category
could be an enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming we will have more than 2 categories, this makes it future proof. Plus, this is array is used to determine which category of component to render for random
.
Regarding enum
good idea, will do.
<div className={`p-12 ${mainBgClasses}`}> | ||
<TwoColumnsWithCards> | ||
<> | ||
<h5 className="text-lg font-semibold">Reply as the assistant</h5> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming this still needs to be updated right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. On it.
Edit: added those to the TaskType and loading them from there now.
export const Task = ({ tasks, trigger, mutate, mainBgClasses }) => { | ||
const task = tasks[0].task; | ||
|
||
function taskTypeComponent(type) { | ||
const category = TaskTypes.find((taskType) => taskType.type === type).category; | ||
|
||
switch (category) { | ||
case "create": | ||
return <CreateTask tasks={tasks} trigger={trigger} mutate={mutate} mainBgClasses={mainBgClasses} />; | ||
case "evaluate": | ||
return <EvaluateTask tasks={tasks} trigger={trigger} mutate={mutate} mainBgClasses={mainBgClasses} />; | ||
} | ||
} | ||
|
||
return taskTypeComponent(task.type); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
This component adds an extra level of indirection that is not necessary.
I would argue that you can directly use CreateTask
or EvaluateTask
in the corresponding task page.
That being said, I understand its value for the random
task type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I make a unified component and also combined everything into one array is because I'm assuming we will have more tasks in future, so we will need to know how to handle any type, given the response from the backend.
This looks pretty good. I'll approve and merge after you've marked it ready for review and comment on or address @AbdBarho's comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
Another draft for refactoring the tasks into components. Related to #433