Skip to content

Commit 05b83b6

Browse files
committed
compare with correct assistant user
1 parent 93aeca3 commit 05b83b6

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

frontend/src/components/LLMDialog/steps/SentenceAnnotationResultStep/SentenceAnnotationResultStep.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
import { Button, CircularProgress, DialogActions, DialogContent, Typography } from "@mui/material";
22
import { useNavigate, useParams } from "react-router-dom";
33
import LLMHooks from "../../../../api/LLMHooks.ts";
4+
import { ApproachType } from "../../../../api/openapi/models/ApproachType.ts";
45
import { SentenceAnnotationLLMJobResult } from "../../../../api/openapi/models/SentenceAnnotationLLMJobResult.ts";
56
import { QueryKey } from "../../../../api/QueryKey.ts";
67
import queryClient from "../../../../plugins/ReactQueryClient.ts";
78
import { useAppDispatch, useAppSelector } from "../../../../plugins/ReduxHooks.ts";
8-
import { SYSTEM_USER_ID } from "../../../../utils/GlobalConstants.ts";
9+
import {
10+
ASSISTANT_FEWSHOT_ID,
11+
ASSISTANT_TRAINED_ID,
12+
ASSISTANT_ZEROSHOT_ID,
13+
} from "../../../../utils/GlobalConstants.ts";
914
import { AnnoActions } from "../../../../views/annotation/annoSlice.ts";
1015
import { CRUDDialogActions } from "../../../dialogSlice.ts";
1116
import LLMUtterance from "../LLMUtterance.tsx";
1217

18+
const approach2AssistantID: Record<ApproachType, number> = {
19+
[ApproachType.LLM_ZERO_SHOT]: ASSISTANT_ZEROSHOT_ID,
20+
[ApproachType.LLM_FEW_SHOT]: ASSISTANT_FEWSHOT_ID,
21+
[ApproachType.MODEL_TRAINING]: ASSISTANT_TRAINED_ID,
22+
};
23+
1324
function SentenceAnnotationResultStep() {
1425
// get the job
1526
const llmJobId = useAppSelector((state) => state.dialog.llmJobId);
@@ -19,6 +30,7 @@ function SentenceAnnotationResultStep() {
1930
return (
2031
<SentenceAnnotationResultStepContent
2132
jobResult={llmJob.data.result.specific_task_result as SentenceAnnotationLLMJobResult}
33+
approachType={llmJob.data.parameters.llm_approach_type}
2234
/>
2335
);
2436
} else if (llmJob.isLoading) {
@@ -34,7 +46,13 @@ function SentenceAnnotationResultStep() {
3446
}
3547
}
3648

37-
function SentenceAnnotationResultStepContent({ jobResult }: { jobResult: SentenceAnnotationLLMJobResult }) {
49+
function SentenceAnnotationResultStepContent({
50+
jobResult,
51+
approachType,
52+
}: {
53+
jobResult: SentenceAnnotationLLMJobResult;
54+
approachType: ApproachType;
55+
}) {
3856
// actions
3957
const dispatch = useAppDispatch();
4058
const handleClose = () => {
@@ -47,11 +65,13 @@ function SentenceAnnotationResultStepContent({ jobResult }: { jobResult: Sentenc
4765
const firstSdocId = jobResult.results[0].sdoc_id;
4866

4967
dispatch(CRUDDialogActions.closeLLMDialog());
50-
dispatch(AnnoActions.compareWithUser(SYSTEM_USER_ID));
68+
dispatch(AnnoActions.compareWithUser(approach2AssistantID[approachType]));
5169
navigate(`/project/${projectId}/annotation/${firstSdocId}`);
5270

5371
// reload annotations
54-
queryClient.invalidateQueries({ queryKey: [QueryKey.SDOC_SENTENCE_ANNOTATOR, firstSdocId, SYSTEM_USER_ID] });
72+
queryClient.invalidateQueries({
73+
queryKey: [QueryKey.SDOC_SENTENCE_ANNOTATOR, firstSdocId, approach2AssistantID[approachType]],
74+
});
5575
};
5676

5777
return (

frontend/src/utils/GlobalConstants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { AttachedObjectType } from "../api/openapi/models/AttachedObjectType.ts";
22

33
export const SYSTEM_USER_ID = 1;
4+
export const ASSISTANT_ZEROSHOT_ID = 9990;
5+
export const ASSISTANT_FEWSHOT_ID = 9991;
6+
export const ASSISTANT_TRAINED_ID = 9992;
47
export const SUPPORT_EMAIL = "[email protected]";
58
export const EMAIL_REGEX = /^[A-Za-z0-9][A-Za-z0-9._%+-]*@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
69
export const HELP_MESSAGE_SUFFIX = "To learn more about this page, please click on the help icon.";

0 commit comments

Comments
 (0)