2023-12-04 06:41:36 +00:00
|
|
|
import { APIService } from "services/api.service";
|
2023-03-28 18:50:00 +00:00
|
|
|
// types
|
2023-12-04 06:41:36 +00:00
|
|
|
import { IGptResponse } from "types";
|
2023-09-13 14:51:02 +00:00
|
|
|
// helpers
|
|
|
|
import { API_BASE_URL } from "helpers/common.helper";
|
2023-03-26 06:06:10 +00:00
|
|
|
|
2023-12-04 06:41:36 +00:00
|
|
|
export class AIService extends APIService {
|
2023-03-26 06:06:10 +00:00
|
|
|
constructor() {
|
2023-09-13 14:51:02 +00:00
|
|
|
super(API_BASE_URL);
|
2023-03-26 06:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async createGptTask(
|
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
2023-12-04 06:41:36 +00:00
|
|
|
data: { prompt: string; task: string }
|
2023-03-28 18:50:00 +00:00
|
|
|
): Promise<IGptResponse> {
|
2023-03-26 06:06:10 +00:00
|
|
|
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/ai-assistant/`, data)
|
2023-12-04 06:41:36 +00:00
|
|
|
.then((response) => response?.data)
|
2023-03-26 06:06:10 +00:00
|
|
|
.catch((error) => {
|
2023-03-30 13:15:33 +00:00
|
|
|
throw error?.response;
|
2023-03-26 06:06:10 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|