update applying current ai insight from dashboard-cpsp
This commit is contained in:
1 parent
31272035e9
commit
b87f20e3b3
27 files changed
+5300
-343
No files matched your search
+143
-4
@@ -272,17 +272,156 @@ export type PanelIoT = {
|
||||
export type AIInsight = {
|
||||
id: number;
|
||||
cycle: number;
|
||||
kandang: number;
|
||||
flock_id: number;
|
||||
kandang: number | null;
|
||||
flock_id?: number;
|
||||
date: string;
|
||||
insight_text: string;
|
||||
/** Condition from graded facts: healthy | warning | critical | unknown */
|
||||
alert: string;
|
||||
section: string;
|
||||
session: string;
|
||||
topic: string;
|
||||
report_type: string;
|
||||
report_period: string;
|
||||
summary?: string;
|
||||
citations?: InsightCitation[];
|
||||
section?: string;
|
||||
session?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
};
|
||||
|
||||
export type InsightReportType = 'page' | 'daily' | 'weekly' | 'end_cycle';
|
||||
|
||||
export type InsightTopic =
|
||||
| 'hitung_ayam'
|
||||
| 'berat_ayam'
|
||||
| 'fcr'
|
||||
| 'eef'
|
||||
| 'iot_panel'
|
||||
| 'hitung_karung'
|
||||
| 'dashboard';
|
||||
|
||||
export type InsightCitation = {
|
||||
id?: string;
|
||||
title?: string;
|
||||
chapter?: string;
|
||||
excerpt?: string;
|
||||
source?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Curated page context sent to the insight service.
|
||||
* `kandangId` is required — never generate for "all kandang".
|
||||
*/
|
||||
export type InsightContext = {
|
||||
kandangId: number;
|
||||
kandangName?: string;
|
||||
cycleId?: number;
|
||||
hari_ke?: number | null;
|
||||
totalDays?: number | null;
|
||||
periode?: string | null;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export type InsightGenerateParams = {
|
||||
cycle_id: number;
|
||||
kandang_id: number;
|
||||
topic: InsightTopic | string;
|
||||
report_type?: InsightReportType;
|
||||
report_period?: string | null;
|
||||
context: InsightContext;
|
||||
force_refresh?: boolean;
|
||||
};
|
||||
|
||||
export type InsightCachedParams = {
|
||||
cycle_id: number;
|
||||
kandang_id: number;
|
||||
topic: InsightTopic | string;
|
||||
report_type?: InsightReportType;
|
||||
report_period?: string | null;
|
||||
};
|
||||
|
||||
export type InsightJobStage =
|
||||
| 'queued'
|
||||
| 'starting'
|
||||
| 'grading'
|
||||
| 'retrieving'
|
||||
| 'synthesizing'
|
||||
| 'saving'
|
||||
| 'done'
|
||||
| 'error';
|
||||
|
||||
export type InsightGenerateJob = {
|
||||
job_id: string;
|
||||
status: 'queued' | 'running' | 'done' | 'error';
|
||||
};
|
||||
|
||||
export type InsightJobStatus = InsightGenerateJob & {
|
||||
stage: InsightJobStage;
|
||||
result: InsightApiResponse | null;
|
||||
error: string | null;
|
||||
};
|
||||
|
||||
export type InsightStatusLabel = 'ok' | 'warning' | 'critical' | 'unknown';
|
||||
|
||||
export type InsightStructuredSection = {
|
||||
status: InsightStatusLabel;
|
||||
bullets: string[];
|
||||
evidence: string[];
|
||||
actions: string[];
|
||||
};
|
||||
|
||||
export type InsightStructuredReport = {
|
||||
summary: {
|
||||
headline: string;
|
||||
bullets: string[];
|
||||
risks: string[];
|
||||
actions: string[];
|
||||
};
|
||||
detailed?: Partial<
|
||||
Record<
|
||||
'hitung_ayam' | 'berat_ayam' | 'fcr' | 'eef' | 'panel_iot' | 'data_quality',
|
||||
InsightStructuredSection
|
||||
>
|
||||
>;
|
||||
};
|
||||
|
||||
/** Structured end-cycle insight (Masalah / Akar penyebab / Perbaikan). */
|
||||
export type EndCycleRootCause = {
|
||||
id?: string;
|
||||
hipotesis: string;
|
||||
bukti: string[];
|
||||
confidence?: 'high' | 'med' | 'low' | string;
|
||||
fase?: string;
|
||||
};
|
||||
|
||||
export type EndCycleAction = {
|
||||
id?: string;
|
||||
fase: string;
|
||||
aksi: string;
|
||||
metrik_pantau?: string;
|
||||
};
|
||||
|
||||
export type EndCycleStructuredInsight = {
|
||||
kesimpulan: string;
|
||||
masalah: string[];
|
||||
akar_penyebab: EndCycleRootCause[];
|
||||
perbaikan_siklus_berikutnya: EndCycleAction[];
|
||||
insight?: string;
|
||||
};
|
||||
|
||||
/** Response from generate / cached insight endpoints. */
|
||||
export type InsightApiResponse = {
|
||||
success?: boolean;
|
||||
insight_text: string;
|
||||
summary?: string;
|
||||
insight?: string;
|
||||
structured?: InsightStructuredReport | null;
|
||||
structured_end_cycle?: EndCycleStructuredInsight | null;
|
||||
citations?: InsightCitation[];
|
||||
message?: string;
|
||||
};
|
||||
|
||||
|
||||
export type KarungRequestResult = {
|
||||
karung: Karung;
|
||||
upstream: Record<string, unknown>;
|
||||
|
||||
Reference in new issue
Block a user