Skip to content

Commit 69aaff3

Browse files
committed
adapted frontend accordingly (using new Job & LLMAssistant DTOs)
1 parent cd316ce commit 69aaff3

File tree

23 files changed

+577
-381
lines changed

23 files changed

+577
-381
lines changed

frontend/src/api/LLMHooks.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ import { useMutation, useQuery } from "@tanstack/react-query";
22
import queryClient from "../plugins/ReactQueryClient.ts";
33
import { QueryKey } from "./QueryKey.ts";
44
import { ApproachType } from "./openapi/models/ApproachType.ts";
5-
import { BackgroundJobStatus } from "./openapi/models/BackgroundJobStatus.ts";
6-
import { LLMJobRead } from "./openapi/models/LLMJobRead.ts";
5+
import { JobStatus } from "./openapi/models/JobStatus.ts";
6+
import { LlmAssistantJobRead } from "./openapi/models/LlmAssistantJobRead.ts";
77
import { TaskType } from "./openapi/models/TaskType.ts";
88
import { LlmService } from "./openapi/services/LlmService.ts";
99

1010
const useStartLLMJob = () =>
1111
useMutation({
12-
mutationFn: LlmService.startLlmJob,
12+
mutationFn: LlmService.startLlmAssistantJob,
1313
onSuccess: (job) => {
1414
// force refetch of all llm jobs when adding a new one
15-
queryClient.invalidateQueries({ queryKey: [QueryKey.PROJECT_LLM_JOBS, job.parameters.project_id] });
15+
queryClient.invalidateQueries({ queryKey: [QueryKey.PROJECT_LLM_JOBS, job.project_id] });
1616
},
1717
meta: {
18-
successMessage: (data: LLMJobRead) => `Started LLM Job as a new background task (ID: ${data.id})`,
18+
successMessage: (data: LlmAssistantJobRead) => `Started LLM Job as a new background task (ID: ${data.job_id})`,
1919
},
2020
});
2121

22-
const usePollLLMJob = (llmJobId: string | undefined, initialData: LLMJobRead | undefined) => {
23-
return useQuery<LLMJobRead, Error>({
22+
const usePollLLMJob = (llmJobId: string | undefined, initialData: LlmAssistantJobRead | undefined) => {
23+
return useQuery<LlmAssistantJobRead, Error>({
2424
queryKey: [QueryKey.LLM_JOB, llmJobId],
2525
queryFn: () =>
26-
LlmService.getLlmJob({
27-
llmJobId: llmJobId!,
26+
LlmService.getLlmAssistantJobById({
27+
jobId: llmJobId!,
2828
}),
2929
enabled: !!llmJobId,
3030
refetchInterval: (query) => {
@@ -33,11 +33,15 @@ const usePollLLMJob = (llmJobId: string | undefined, initialData: LLMJobRead | u
3333
}
3434
if (query.state.data.status) {
3535
switch (query.state.data.status) {
36-
case BackgroundJobStatus.ERRORNEOUS:
37-
case BackgroundJobStatus.FINISHED:
36+
case JobStatus.CANCELED:
37+
case JobStatus.FAILED:
38+
case JobStatus.FINISHED:
39+
case JobStatus.STOPPED:
3840
return false;
39-
case BackgroundJobStatus.WAITING:
40-
case BackgroundJobStatus.RUNNING:
41+
case JobStatus.DEFERRED:
42+
case JobStatus.QUEUED:
43+
case JobStatus.SCHEDULED:
44+
case JobStatus.STARTED:
4145
return 1000;
4246
}
4347
}
@@ -48,10 +52,10 @@ const usePollLLMJob = (llmJobId: string | undefined, initialData: LLMJobRead | u
4852
};
4953

5054
const useGetAllLLMJobs = (projectId: number) => {
51-
return useQuery<LLMJobRead[], Error>({
55+
return useQuery<LlmAssistantJobRead[], Error>({
5256
queryKey: [QueryKey.PROJECT_LLM_JOBS, projectId],
5357
queryFn: () =>
54-
LlmService.getAllLlmJobs({
58+
LlmService.getLlmAssistantJobsByProject({
5559
projectId: projectId!,
5660
}),
5761
enabled: !!projectId,

frontend/src/api/openapi/models/DuplicateFinderJobRead.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ export type DuplicateFinderJobRead = {
2626
* Status message
2727
*/
2828
status_message?: string | null;
29+
/**
30+
* Current step in the job process
31+
*/
32+
current_step: number;
33+
/**
34+
* Total number of steps in the job process
35+
*/
36+
num_steps: number;
2937
/**
3038
* Input for the job
3139
*/

frontend/src/api/openapi/models/LLMJobParameters2_Input.ts renamed to frontend/src/api/openapi/models/LLMJobInput_Input.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import type { SentenceAnnotationParams } from "./SentenceAnnotationParams";
1111
import type { TaggingParams } from "./TaggingParams";
1212
import type { TaskType } from "./TaskType";
1313
import type { ZeroShotParams } from "./ZeroShotParams";
14-
export type LLMJobParameters2_Input = {
14+
export type LLMJobInput_Input = {
1515
/**
16-
* The type of the LLMJob (what to llm)
16+
* Project ID associated with the job
1717
*/
18-
llm_job_type: TaskType;
18+
project_id: number;
1919
/**
20-
* The ID of the Project to analyse
20+
* The type of the LLMJob (what to llm)
2121
*/
22-
project_id: number;
22+
llm_job_type: TaskType;
2323
/**
2424
* Specific parameters for the LLMJob w.r.t it's type
2525
*/

frontend/src/api/openapi/models/LLMJobParameters2_Output.ts renamed to frontend/src/api/openapi/models/LLMJobInput_Output.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import type { SentenceAnnotationParams } from "./SentenceAnnotationParams";
1111
import type { TaggingParams } from "./TaggingParams";
1212
import type { TaskType } from "./TaskType";
1313
import type { ZeroShotParams } from "./ZeroShotParams";
14-
export type LLMJobParameters2_Output = {
14+
export type LLMJobInput_Output = {
1515
/**
16-
* The type of the LLMJob (what to llm)
16+
* Project ID associated with the job
1717
*/
18-
llm_job_type: TaskType;
18+
project_id: number;
1919
/**
20-
* The ID of the Project to analyse
20+
* The type of the LLMJob (what to llm)
2121
*/
22-
project_id: number;
22+
llm_job_type: TaskType;
2323
/**
2424
* Specific parameters for the LLMJob w.r.t it's type
2525
*/

frontend/src/api/openapi/models/LLMJobResult.ts renamed to frontend/src/api/openapi/models/LLMJobOutput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { MetadataExtractionLLMJobResult } from "./MetadataExtractionLLMJobR
77
import type { SentenceAnnotationLLMJobResult } from "./SentenceAnnotationLLMJobResult";
88
import type { TaggingLLMJobResult } from "./TaggingLLMJobResult";
99
import type { TaskType } from "./TaskType";
10-
export type LLMJobResult = {
10+
export type LLMJobOutput = {
1111
/**
1212
* The type of the LLMJob (what to llm)
1313
*/

frontend/src/api/openapi/models/LLMJobParameters.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import type { TaggingParams } from "./TaggingParams";
99
import type { TaskType } from "./TaskType";
1010
export type LLMJobParameters = {
1111
/**
12-
* The type of the LLMJob (what to llm)
12+
* Project ID associated with the job
1313
*/
14-
llm_job_type: TaskType;
14+
project_id: number;
1515
/**
16-
* The ID of the Project to analyse
16+
* The type of the LLMJob (what to llm)
1717
*/
18-
project_id: number;
18+
llm_job_type: TaskType;
1919
/**
2020
* Specific parameters for the LLMJob w.r.t it's type
2121
*/

frontend/src/api/openapi/models/LLMJobRead.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* generated using openapi-typescript-codegen -- do not edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
import type { JobStatus } from "./JobStatus";
6+
import type { LLMJobInput_Output } from "./LLMJobInput_Output";
7+
import type { LLMJobOutput } from "./LLMJobOutput";
8+
export type LlmAssistantJobRead = {
9+
/**
10+
* RQ job ID
11+
*/
12+
job_id: string;
13+
/**
14+
* Type of the job
15+
*/
16+
job_type: string;
17+
/**
18+
* Project ID associated with the job
19+
*/
20+
project_id: number;
21+
/**
22+
* Current status of the job
23+
*/
24+
status: JobStatus;
25+
/**
26+
* Status message
27+
*/
28+
status_message?: string | null;
29+
/**
30+
* Current step in the job process
31+
*/
32+
current_step: number;
33+
/**
34+
* Total number of steps in the job process
35+
*/
36+
num_steps: number;
37+
/**
38+
* Input for the job
39+
*/
40+
input: LLMJobInput_Output;
41+
/**
42+
* Output for the job
43+
*/
44+
output?: LLMJobOutput | null;
45+
};

0 commit comments

Comments
 (0)