forked from yk/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
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 LAION-AI#575 from LAION-AI/website-types
Centralize task types
- Loading branch information
Showing
29 changed files
with
162 additions
and
192 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
website/src/hooks/tasks/labeling/useLabelAssistantReply.ts
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
website/src/hooks/tasks/labeling/useLabelInitialPrompt.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { TaskType } from "src/types/Task"; | ||
import { CreateAssistantReplyTask, CreateInitialPromptTask, CreatePrompterReplyTask } from "src/types/Tasks"; | ||
|
||
import { useGenericTaskAPI } from "./useGenericTaskAPI"; | ||
|
||
export const useCreateAssistantReply = () => useGenericTaskAPI<CreateAssistantReplyTask>(TaskType.assistant_reply); | ||
export const useCreatePrompterReply = () => useGenericTaskAPI<CreatePrompterReplyTask>(TaskType.prompter_reply); | ||
export const useCreateInitialPrompt = () => useGenericTaskAPI<CreateInitialPromptTask>(TaskType.initial_prompt); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { BaseTask, TaskResponse, TaskType } from "src/types/Task"; | ||
import { LabelAssistantReplyTask, LabelInitialPromptTask, LabelPrompterReplyTask } from "src/types/Tasks"; | ||
|
||
import { useGenericTaskAPI } from "./useGenericTaskAPI"; | ||
|
||
const useLabelingTask = <Task extends BaseTask>( | ||
endpoint: TaskType.label_assistant_reply | TaskType.label_prompter_reply | TaskType.label_initial_prompt | ||
) => { | ||
const { tasks, isLoading, trigger, reset, error } = useGenericTaskAPI<Task>(endpoint); | ||
|
||
const submit = (id: string, message_id: string, text: string, validLabels: string[], labelWeights: number[]) => { | ||
console.assert(validLabels.length === labelWeights.length); | ||
const labels = Object.fromEntries(validLabels.map((label, i) => [label, labelWeights[i]])); | ||
|
||
return trigger({ id, update_type: "text_labels", content: { labels, text, message_id } }); | ||
}; | ||
|
||
return { tasks, isLoading, submit, reset, error }; | ||
}; | ||
|
||
export type LabelAssistantReplyTaskResponse = TaskResponse<LabelAssistantReplyTask>; | ||
|
||
export const useLabelAssistantReplyTask = () => | ||
useLabelingTask<LabelAssistantReplyTask>(TaskType.label_assistant_reply); | ||
|
||
export type LabelInitialPromptTaskResponse = TaskResponse<LabelInitialPromptTask>; | ||
|
||
export const useLabelInitialPromptTask = () => useLabelingTask<LabelInitialPromptTask>(TaskType.label_initial_prompt); | ||
|
||
export type LabelPrompterReplyTaskResponse = TaskResponse<LabelPrompterReplyTask>; | ||
|
||
export const useLabelPrompterReplyTask = () => useLabelingTask<LabelPrompterReplyTask>(TaskType.label_prompter_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TaskType } from "src/types/Task"; | ||
import { RankAssistantRepliesTask, RankInitialPromptsTask, RankPrompterRepliesTask } from "src/types/Tasks"; | ||
|
||
import { useGenericTaskAPI } from "./useGenericTaskAPI"; | ||
|
||
export const useRankAssistantRepliesTask = () => | ||
useGenericTaskAPI<RankAssistantRepliesTask>(TaskType.rank_assistant_replies); | ||
|
||
export const useRankPrompterRepliesTask = () => | ||
useGenericTaskAPI<RankPrompterRepliesTask>(TaskType.rank_prompter_replies); | ||
|
||
export const useRankInitialPromptsTask = () => useGenericTaskAPI<RankInitialPromptsTask>(TaskType.rank_initial_prompts); |
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
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
Oops, something went wrong.