update ai insight migration for all page
This commit is contained in:
1 parent
07d36081ce
commit
18790ab8f6
69 files changed
+9457
-399
No files matched your search
@@ -9,6 +9,9 @@ import type {
|
||||
Flock,
|
||||
FlockWrite,
|
||||
InitialBalanceResult,
|
||||
InsightApiResponse,
|
||||
InsightCachedParams,
|
||||
InsightGenerateParams,
|
||||
Karung,
|
||||
KarungRequestResult,
|
||||
Kandang,
|
||||
@@ -253,5 +256,29 @@ export const api = {
|
||||
insights: {
|
||||
list: async (query?: CycleFilter) =>
|
||||
unwrapList(await get<Paginated<AIInsight> | AIInsight[]>('/ai-insights/', query)),
|
||||
/**
|
||||
* Generate (or refresh) an insight for one kandang.
|
||||
* Backend may take several minutes (qwen2.5:3b) — callers should
|
||||
* show long-timeout UX. `kandang_id` is required.
|
||||
*/
|
||||
generate: (body: InsightGenerateParams) => {
|
||||
if (body.kandang_id == null) {
|
||||
return Promise.reject(new Error('kandang_id wajib — insight tidak boleh untuk semua kandang'));
|
||||
}
|
||||
return post<InsightApiResponse>('/ai-insights/generate/', body);
|
||||
},
|
||||
/** Fetch cached insight 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 get<InsightApiResponse>('/ai-insights/cached/', {
|
||||
cycle_id: params.cycle_id,
|
||||
kandang_id: params.kandang_id,
|
||||
topic: params.topic,
|
||||
report_type: params.report_type,
|
||||
report_period: params.report_period ?? undefined,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user