ai insight rework #1
This commit is contained in:
1 parent
0d960c8153
commit
9d76f54d33
13 files changed
+730
-299
No files matched your search
+22
-8
@@ -11,7 +11,9 @@ import type {
|
||||
InitialBalanceResult,
|
||||
InsightApiResponse,
|
||||
InsightCachedParams,
|
||||
InsightGenerateJob,
|
||||
InsightGenerateParams,
|
||||
InsightJobStatus,
|
||||
Karung,
|
||||
KarungRequestResult,
|
||||
Kandang,
|
||||
@@ -194,14 +196,11 @@ export const api = {
|
||||
remove: (id: number) => del(`/cycles/${id}/`),
|
||||
initialBalance: (id: number, body: { date: string; feed_in_manual: number }) =>
|
||||
post<InitialBalanceResult>(`/cycles/${id}/initial-balance/`, body),
|
||||
initialBalanceCompare: (
|
||||
id: number,
|
||||
query: { date: string; manual?: number }
|
||||
) => get<InitialBalanceResult>(`/cycles/${id}/initial-balance-compare/`, query),
|
||||
initialBalanceCompare: (id: number, query: { date: string; manual?: number }) =>
|
||||
get<InitialBalanceResult>(`/cycles/${id}/initial-balance-compare/`, query),
|
||||
requestClose: (id: number, body: { proposed_end_date: string }) =>
|
||||
post<Cycle>(`/cycles/${id}/request-close/`, body),
|
||||
cancelCloseRequest: (id: number) =>
|
||||
post<Cycle>(`/cycles/${id}/cancel-close-request/`, {}),
|
||||
cancelCloseRequest: (id: number) => post<Cycle>(`/cycles/${id}/cancel-close-request/`, {}),
|
||||
},
|
||||
pusat: {
|
||||
register: (body: { code: string; site_id: string }) =>
|
||||
@@ -263,14 +262,29 @@ export const api = {
|
||||
*/
|
||||
generate: (body: InsightGenerateParams) => {
|
||||
if (body.kandang_id == null) {
|
||||
return Promise.reject(new Error('kandang_id wajib — insight tidak boleh untuk semua kandang'));
|
||||
return Promise.reject(
|
||||
new Error('kandang_id wajib — insight tidak boleh untuk semua kandang')
|
||||
);
|
||||
}
|
||||
return post<InsightApiResponse>('/ai-insights/generate/', body);
|
||||
},
|
||||
/** Async generate (Phase 4): 202 + job_id; poll with jobStatus(). */
|
||||
generateAsync: (body: InsightGenerateParams) => {
|
||||
if (body.kandang_id == null) {
|
||||
return Promise.reject(
|
||||
new Error('kandang_id wajib — insight tidak boleh untuk semua kandang')
|
||||
);
|
||||
}
|
||||
return post<InsightGenerateJob>('/ai-insights/generate/', { ...body, async: true });
|
||||
},
|
||||
/** Poll async generate job (status + pipeline stage). */
|
||||
jobStatus: (jobId: string) => get<InsightJobStatus>(`/ai-insights/jobs/${jobId}/`),
|
||||
/** Load insight from DB for the same scope key (no LLM call). */
|
||||
cached: (params: InsightCachedParams) => {
|
||||
if (params.kandang_id == null) {
|
||||
return Promise.reject(new Error('kandang_id wajib — insight tidak boleh untuk semua kandang'));
|
||||
return Promise.reject(
|
||||
new Error('kandang_id wajib — insight tidak boleh untuk semua kandang')
|
||||
);
|
||||
}
|
||||
return get<InsightApiResponse>('/ai-insights/cached/', {
|
||||
cycle_id: params.cycle_id,
|
||||
|
||||
Reference in new issue
Block a user