mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-29 16:30:24 +08:00
website: request message specific labels for on demand labelling
This commit is contained in:
@@ -28,7 +28,7 @@ interface ValidLabelsResponse {
|
||||
|
||||
export const LabelMessagePopup = ({ messageId, show, onClose }: LabelMessagePopupProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { data: response } = useSWRImmutable<ValidLabelsResponse>("/api/valid_labels", get);
|
||||
const { data: response } = useSWRImmutable<ValidLabelsResponse>(`/api/valid_labels?message_id=${messageId}`, get);
|
||||
const valid_labels = response?.valid_labels ?? [];
|
||||
const [values, setValues] = useState<number[]>(new Array(valid_labels.length).fill(null));
|
||||
|
||||
|
||||
@@ -160,8 +160,8 @@ export class OasstApiClient {
|
||||
/**
|
||||
* Returns the valid labels for messages.
|
||||
*/
|
||||
async fetch_valid_text(): Promise<any> {
|
||||
return this.get(`/api/v1/text_labels/valid_labels`);
|
||||
async fetch_valid_text(messageId?: string): Promise<any> {
|
||||
return this.get("/api/v1/text_labels/valid_labels", { message_id: messageId });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,9 @@ import { createApiClient } from "src/lib/oasst_client_factory";
|
||||
* Returns the set of valid labels that can be applied to messages.
|
||||
*/
|
||||
const handler = withoutRole("banned", async (req, res, token) => {
|
||||
const { message_id } = req.query;
|
||||
const client = await createApiClient(token);
|
||||
const valid_labels = await client.fetch_valid_text();
|
||||
const valid_labels = await client.fetch_valid_text(message_id as string);
|
||||
res.status(200).json(valid_labels);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user