-
Notifications
You must be signed in to change notification settings - Fork 440
feat: add data quality issue detector kit. #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
donallsiby
wants to merge
3
commits into
Lamatic:main
Choose a base branch
from
donallsiby:data-quality-detector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+8,324
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Lamatic API configuration | ||
| LAMATIC_API_KEY=your_lamatic_api_key_here | ||
| LAMATIC_PROJECT_ID=your_lamatic_project_id_here | ||
| LAMATIC_ENDPOINT=https://your-project-endpoint.lamatic.dev | ||
|
|
||
| # Deployed Flow IDs | ||
| DATA_QUALITY_AGENT=your_data_quality_agent_flow_id_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .lamatic/ | ||
| node_modules/ | ||
| .env | ||
| .env.local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Data Quality Issue Detector Kit | ||
|
|
||
| ## 1. The Problem | ||
| Before analyzing data or training machine learning models, cleaning raw data is always the first and most critical step. Identifying null/missing values, duplicates, out-of-range numerical fields, formatting syntax problems (e.g. invalid emails or dates), and status casing inconsistencies is usually done manually with custom Python/Pandas scripts. This can be time-consuming, repetitive, and inaccessible to non-technical users who just want a quick audit of their files. | ||
|
|
||
| ## 2. The Approach | ||
| We built an AI-powered data quality audit agent using Next.js and the Lamatic API. | ||
| - **Workflow:** The user loads or pastes a dataset (CSV) and provides optional instructions (e.g. "Focus on validating emails and ignore columns without names"). | ||
| - **Agent Action:** The LLM-backed agent scans the dataset row-by-row, identifying anomalies, missing information, schema mismatches, and duplicated records. | ||
| - **Interactive UI:** The Next.js frontend previews the CSV as an interactive table, triggers the Server Action to invoke the Lamatic flow, and renders the detailed audit report side-by-side using markdown. | ||
|
|
||
| ## 3. The Result | ||
| An instantly usable web tool to run automated health checks on dataset CSVs. Teams receive a clear, prioritized checklist of data clean-up items, complete with column-specific summaries, issues categorized by severity (High, Medium, Low), and actionable cleaning steps to feed into their ETL scripts. | ||
|
|
||
| --- | ||
|
|
||
| ## AgentKit Collection (1 flow) | ||
|
|
||
| This AgentKit contains 1 flow: | ||
| - **Data Quality Agent** (`flows/data-quality-agent.ts`) | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
| * **Node.js** (v18 or higher recommended) | ||
| * **npm** or **pnpm** package manager | ||
| * A valid **Lamatic API Key**, **Project ID**, and **API URL/Endpoint** | ||
|
|
||
| --- | ||
|
|
||
| ## Setup Instructions | ||
|
|
||
| 1. **Initialize the App Directory** | ||
| ```bash | ||
| cd apps | ||
| npm install | ||
| ``` | ||
|
|
||
| 2. **Configure Environment Variables** | ||
| Create a local env file: | ||
| ```bash | ||
| cp .env.example .env.local | ||
| ``` | ||
| Open `.env.local` and add your Lamatic credentials: | ||
| ```env | ||
| LAMATIC_API_KEY=your_api_key_here | ||
| LAMATIC_PROJECT_ID=your_project_id_here | ||
| LAMATIC_ENDPOINT=https://your-endpoint.lamatic.dev | ||
| DATA_QUALITY_AGENT=your_deployed_flow_id_here | ||
| ``` | ||
|
|
||
| 3. **Start the Development Server** | ||
| ```bash | ||
| npm run dev | ||
| ``` | ||
| The application will be available at `http://localhost:3000`. | ||
|
|
||
| --- | ||
|
|
||
| ## Programmatic Usage Example | ||
|
|
||
| The Next.js frontend calls the Lamatic flow via Next.js Server Actions: | ||
|
|
||
| ```typescript | ||
| import { analyzeDatasetQuality } from "@/actions/orchestrate"; | ||
|
|
||
| const checkData = async () => { | ||
| const csvContent = `id,name,email,age | ||
| 1,John Doe,john@example.com,28 | ||
| 2,Jane Smith,,thirty-four | ||
| 1,John Doe,john@example.com,28`; | ||
|
|
||
| const result = await analyzeDatasetQuality(csvContent, "Check for schema issues and duplicates."); | ||
|
|
||
| if (result.success) { | ||
| console.log("Analysis Report:", result.data); | ||
| } | ||
| }; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Data Quality Issue Detector | ||
|
|
||
| You are a data quality assistant. | ||
|
|
||
| Your job is to analyze uploaded tabular data and identify: | ||
| - missing values | ||
| - duplicate rows | ||
| - invalid formats | ||
| - outliers | ||
| - inconsistent categories | ||
| - suspicious values | ||
| - data type mismatches | ||
|
|
||
| Return: | ||
| 1. Dataset summary | ||
| 2. Issues found | ||
| 3. Severity | ||
| 4. Suggested fixes | ||
| 5. Quality score out of 100 | ||
| 6. Final recommendation | ||
|
|
||
| Be concise, practical, and easy to understand. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Lamatic API configuration | ||
| LAMATIC_API_KEY=your_lamatic_api_key_here | ||
| LAMATIC_PROJECT_ID=your_lamatic_project_id_here | ||
| LAMATIC_ENDPOINT=https://your-project-endpoint.lamatic.dev | ||
|
|
||
| # Deployed Flow IDs | ||
| DATA_QUALITY_AGENT=your_data_quality_agent_flow_id_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .env | ||
| .env.local | ||
| node_modules | ||
| .next | ||
| out | ||
| dist | ||
| tsconfig.tsbuildinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| "use server"; | ||
|
|
||
| import { lamaticClient } from "../lib/lamatic-client" | ||
| import lamaticConfig from "../../lamatic.config" | ||
|
|
||
| export async function orchestrateAnalysis(formData: FormData) { | ||
| try { | ||
| const file = formData.get("file") as File | null; | ||
| if (!file) throw new Error("File is required"); | ||
|
|
||
| const fileContent = await file.text(); | ||
|
|
||
| const step = lamaticConfig.steps.find((s) => s.id === "data-quality-agent") as any; | ||
| let workflowId = step?.workflowId || (step?.envKey ? process.env[step.envKey] : undefined); | ||
| if (!workflowId) { | ||
| workflowId = process.env.DATA_QUALITY_AGENT; | ||
| } | ||
| if (!workflowId) { | ||
| throw new Error("Data Quality Agent workflow ID is not configured. Please define it in lamatic.config.ts or the DATA_QUALITY_AGENT env variable."); | ||
| } | ||
|
|
||
| const query = ` | ||
| query ExecuteWorkflow($workflowId: String!, $file: JSON) { | ||
| executeWorkflow( | ||
| workflowId: $workflowId | ||
| payload: { file: $file } | ||
| ) { | ||
| status | ||
| result | ||
| } | ||
| }`; | ||
|
|
||
| const variables = { | ||
| workflowId, | ||
| file: { | ||
| name: file.name, | ||
| content: fileContent | ||
| } | ||
| }; | ||
|
|
||
| const response = await lamaticClient.executeGraphQL(query, variables); | ||
|
|
||
| let report = response.result; | ||
| if (typeof report === "object" && report !== null) { | ||
| report = report.report || JSON.stringify(report, null, 2); | ||
| } | ||
|
|
||
| return { success: true, data: report }; | ||
|
|
||
| } catch (error: unknown) { | ||
| console.error("Data Quality Analysis Error:", error); | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return { success: false, error: message }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| @import "tailwindcss"; | ||
|
|
||
| :root { | ||
| color-scheme: light; | ||
| --background: #f8fafc; | ||
| --foreground: #0f172a; | ||
| --surface: #ffffff; | ||
| --surface-muted: #f1f5f9; | ||
| --border: #e2e8f0; | ||
| --border-strong: #cbd5e1; | ||
| --muted: #64748b; | ||
| --muted-strong: #334155; | ||
| --heading: #0f172a; | ||
| --primary: #4f46e5; | ||
| --primary-hover: #4338ca; | ||
| --primary-foreground: #ffffff; | ||
| --primary-soft: #e0e7ff; | ||
| --primary-soft-foreground: #4338ca; | ||
| --danger: #dc2626; | ||
| --danger-soft: #fef2f2; | ||
| --danger-border: #fecaca; | ||
| --success: #16a34a; | ||
| --success-soft: #f0fdf4; | ||
| --success-border: #bbf7d0; | ||
| } | ||
|
|
||
| * { | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| body { | ||
| margin: 0; | ||
| background: var(--background); | ||
| color: var(--foreground); | ||
| font-family: | ||
| Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", | ||
| sans-serif; | ||
| } | ||
|
|
||
| button, | ||
| input, | ||
| textarea { | ||
| font: inherit; | ||
| } | ||
|
|
||
| textarea { | ||
| resize: vertical; | ||
| } | ||
|
|
||
| /* Custom markdown rendering styling */ | ||
| .prose h1, .prose h2, .prose h3 { | ||
| font-weight: 700; | ||
| color: var(--heading); | ||
| margin-top: 1.5em; | ||
| margin-bottom: 0.5em; | ||
| } | ||
| .prose h1 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.3em; } | ||
| .prose h2 { font-size: 1.25rem; } | ||
| .prose h3 { font-size: 1.1rem; } | ||
| .prose p { margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.6; } | ||
| .prose ul, .prose ol { padding-left: 1.5rem; margin-top: 0.5em; margin-bottom: 0.5em; } | ||
| .prose li { margin-top: 0.25em; margin-bottom: 0.25em; } | ||
| .prose strong { color: var(--heading); font-weight: 600; } | ||
| .prose code { background-color: var(--surface-muted); padding: 0.15rem 0.3rem; rounded: 0.25rem; font-family: monospace; font-size: 0.9em; } | ||
|
donallsiby marked this conversation as resolved.
|
||
| .prose blockquote { border-left: 4px solid var(--border-strong); padding-left: 1rem; color: var(--muted); font-style: italic; } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { Metadata } from "next"; | ||
| import "./globals.css"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "Data Quality Issue Detector", | ||
| description: "Scans datasets for anomalies, missing values, duplicates, and formatting issues with Lamatic.", | ||
| }; | ||
|
|
||
| export default function RootLayout({ | ||
| children, | ||
| }: Readonly<{ | ||
| children: React.ReactNode; | ||
| }>) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body>{children}</body> | ||
| </html> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.