11import { Button , CircularProgress , DialogActions , DialogContent , Typography } from "@mui/material" ;
22import { useNavigate , useParams } from "react-router-dom" ;
33import LLMHooks from "../../../../api/LLMHooks.ts" ;
4+ import { ApproachType } from "../../../../api/openapi/models/ApproachType.ts" ;
45import { SentenceAnnotationLLMJobResult } from "../../../../api/openapi/models/SentenceAnnotationLLMJobResult.ts" ;
56import { QueryKey } from "../../../../api/QueryKey.ts" ;
67import queryClient from "../../../../plugins/ReactQueryClient.ts" ;
78import { 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" ;
914import { AnnoActions } from "../../../../views/annotation/annoSlice.ts" ;
1015import { CRUDDialogActions } from "../../../dialogSlice.ts" ;
1116import 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+
1324function 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 (
0 commit comments