From 877d41815db15130dcd05d071130a3f00b266a2c Mon Sep 17 00:00:00 2001 From: nishika26 Date: Wed, 4 Mar 2026 00:22:43 +0530 Subject: [PATCH 1/3] Evals UI: Filter text eval jobs for eval jobs page --- app/api/evaluations/route.ts | 34 ++++++++++++++++------------------ app/evaluations/page.tsx | 5 ++++- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/api/evaluations/route.ts b/app/api/evaluations/route.ts index 92ef43d..c5de175 100644 --- a/app/api/evaluations/route.ts +++ b/app/api/evaluations/route.ts @@ -22,27 +22,25 @@ export async function GET(request: NextRequest) { const data = await response.json(); - // Log the structure to help debug score visibility issues + // Log the structure to help debug score visibility issues - only for text type evaluations //TODO Fix it later + let items = []; if (data && Array.isArray(data)) { - console.log('[GET /api/evaluations] Sample evaluation structure:', { - firstItem: data[0] ? { - id: data[0].id, - hasScore: !!data[0].score, - hasScores: !!data[0].scores, - scoreKeys: data[0].score ? Object.keys(data[0].score) : [], - scoresKeys: data[0].scores ? Object.keys(data[0].scores) : [] - } : 'No items' - }); + items = data.filter((item: any) => item.type === 'text'); } else if (data && data.data && Array.isArray(data.data)) { - console.log('[GET /api/evaluations] Sample evaluation structure (nested):', { - firstItem: data.data[0] ? { - id: data.data[0].id, - hasScore: !!data.data[0].score, - hasScores: !!data.data[0].scores, - scoreKeys: data.data[0].score ? Object.keys(data.data[0].score) : [], - scoresKeys: data.data[0].scores ? Object.keys(data.data[0].scores) : [] - } : 'No items' + items = data.data.filter((item: any) => item.type === 'text'); + } + + if (items.length > 0) { + console.log('[GET /api/evaluations] Sample text evaluation structure:', { + firstItem: { + id: items[0].id, + type: items[0].type, + hasScore: !!items[0].score, + hasScores: !!items[0].scores, + scoreKeys: items[0].score ? Object.keys(items[0].score) : [], + scoresKeys: items[0].scores ? Object.keys(items[0].scores) : [] + } }); } diff --git a/app/evaluations/page.tsx b/app/evaluations/page.tsx index 1109e8d..29f8146 100644 --- a/app/evaluations/page.tsx +++ b/app/evaluations/page.tsx @@ -871,7 +871,10 @@ function ResultsTab({ apiKeys, selectedKeyId }: ResultsTabProps) { const data = await response.json(); // API may return an array or an object with data property - const jobs = Array.isArray(data) ? data : (data.data || []); + let jobs = Array.isArray(data) ? data : (data.data || []); + + // Filter to only show jobs with type: "text" + jobs = jobs.filter((job: any) => job.type === 'text'); // Debug logging for score visibility if (jobs.length > 0) { From c83e2ba70a57b676a5947a07b12f3fe259f11663 Mon Sep 17 00:00:00 2001 From: nishika26 Date: Thu, 5 Mar 2026 12:26:09 +0530 Subject: [PATCH 2/3] filtering dataset and changing pages name --- app/api/evaluations/datasets/route.ts | 12 +++++- app/api/evaluations/stt/datasets/route.ts | 24 +++++++++-- app/evaluations/page.tsx | 51 +++++++++++------------ 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/app/api/evaluations/datasets/route.ts b/app/api/evaluations/datasets/route.ts index 0952446..a5eec03 100644 --- a/app/api/evaluations/datasets/route.ts +++ b/app/api/evaluations/datasets/route.ts @@ -3,7 +3,8 @@ import { NextRequest, NextResponse } from 'next/server'; /** * GET /api/evaluations/datasets * - * Proxy endpoint to fetch all datasets from the backend. + * Proxy endpoint to fetch text datasets only from the backend. + * This endpoint filters and returns only datasets with type='text'. */ export async function GET(request: NextRequest) { try { @@ -36,7 +37,14 @@ export async function GET(request: NextRequest) { return NextResponse.json(data, { status: response.status }); } - return NextResponse.json(data, { status: 200 }); + // Filter to only return text datasets + const filteredData = Array.isArray(data) + ? data.filter((dataset: any) => dataset.type === 'text') + : data.data + ? { ...data, data: data.data.filter((dataset: any) => dataset.type === 'text') } + : data; + + return NextResponse.json(filteredData, { status: 200 }); } catch (error: any) { console.error('Proxy error:', error); return NextResponse.json( diff --git a/app/api/evaluations/stt/datasets/route.ts b/app/api/evaluations/stt/datasets/route.ts index a725ccd..c93efb5 100644 --- a/app/api/evaluations/stt/datasets/route.ts +++ b/app/api/evaluations/stt/datasets/route.ts @@ -1,8 +1,12 @@ import { NextResponse, NextRequest } from 'next/server'; - - -export async function GET(request: +/** + * GET /api/evaluations/stt/datasets + * + * Proxy endpoint to fetch STT datasets only from the backend. + * This endpoint filters and returns only datasets with type='stt'. + */ +export async function GET(request: Request) { const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; const apiKey = request.headers.get('X-API-KEY'); @@ -15,7 +19,19 @@ export async function GET(request: }); const data = await response.json(); - return NextResponse.json(data, { status: response.status }); + + if (!response.ok) { + return NextResponse.json(data, { status: response.status }); + } + + // Filter to only return STT datasets (additional safety check) + const filteredData = Array.isArray(data) + ? data.filter((dataset: any) => dataset.type === 'stt') + : data.data + ? { ...data, data: data.data.filter((dataset: any) => dataset.type === 'stt') } + : data; + + return NextResponse.json(filteredData, { status: response.status }); } catch (error) { return NextResponse.json( { success: false, error: error, data: null }, diff --git a/app/evaluations/page.tsx b/app/evaluations/page.tsx index 29f8146..83575df 100644 --- a/app/evaluations/page.tsx +++ b/app/evaluations/page.tsx @@ -2,8 +2,8 @@ * SimplifiedEval.tsx - Simplified One-Click Evaluation Flow * * Two-tab structure: - * 1. Upload Tab: Upload QnA dataset → Run evaluation - * 2. Results Tab: View evaluation results with metrics and detailed logs + * 1. Datasets Tab: Upload QnA dataset → Run evaluation + * 2. Evaluations Tab: View evaluation results with metrics and detailed logs */ "use client" @@ -24,17 +24,17 @@ import ConfigSelector from '../components/ConfigSelector'; import { useToast } from '../components/Toast'; import Loader, { LoaderBox } from '../components/Loader'; -type Tab = 'upload' | 'results'; +type Tab = 'datasets' | 'evaluations'; function SimplifiedEvalContent() { const router = useRouter(); const searchParams = useSearchParams(); const toast = useToast(); - // Initialize activeTab from URL query parameter, default to 'upload' + // Initialize activeTab from URL query parameter, default to 'datasets' const [activeTab, setActiveTab] = useState(() => { const tabParam = searchParams.get('tab'); - return (tabParam === 'results' || tabParam === 'upload') ? tabParam as Tab : 'upload'; + return (tabParam === 'evaluations' || tabParam === 'datasets') ? tabParam as Tab : 'datasets'; }); const [isEvaluating, setIsEvaluating] = useState(false); @@ -266,9 +266,9 @@ function SimplifiedEvalContent() { // Extract the evaluation ID from response (could be data.id or data.data.id or data.eval_id) const evalId = data.id || data.data?.id || data.eval_id || 'unknown'; - // Redirect to results tab to view evaluation status + // Redirect to evaluations tab to view evaluation status setIsEvaluating(false); - setActiveTab('results'); + setActiveTab('evaluations'); // Show success message toast.success(`Evaluation job created successfully! ${evalId !== 'unknown' ? `Job ID: ${evalId}` : ''}`); @@ -341,8 +341,8 @@ function SimplifiedEvalContent() { {/* Tab Navigation */} setActiveTab(tabId as Tab)} @@ -351,8 +351,8 @@ function SimplifiedEvalContent() { {/* Tab Content */}
- {activeTab === 'upload' ? ( - ) : ( - + )}
@@ -402,8 +402,8 @@ function SimplifiedEvalContent() { ); } -// ============ UPLOAD TAB COMPONENT ============ -interface UploadTabProps { +// ============ DATASETS TAB COMPONENT ============ +interface DatasetsTabProps { isEvaluating: boolean; apiKeys: APIKey[]; selectedKeyId: string; @@ -420,7 +420,7 @@ interface UploadTabProps { onConfigSelect: (configId: string, configVersion: number) => void; } -function UploadTab({ +function DatasetsTab({ isEvaluating, apiKeys, selectedKeyId, @@ -435,7 +435,7 @@ function UploadTab({ onExperimentNameChange, onRunEvaluation, onConfigSelect, -}: UploadTabProps) { +}: DatasetsTabProps) { const selectedKey = apiKeys.find(k => k.id === selectedKeyId); const selectedDataset = storedDatasets.find(d => d.dataset_id.toString() === selectedDatasetId); @@ -480,8 +480,8 @@ function UploadTab({
  • Select a stored dataset or upload a new CSV file (format: question,answer columns)
  • Configure evaluation settings (experiment name required, other fields optional)
  • Click
    Run Evaluation
    to start the evaluation process
  • -
  • Wait for processing to complete (automatic redirect to results)
  • -
  • View detailed results and metrics in the Results tab
  • +
  • Wait for processing to complete (automatic redirect to evaluations tab)
  • +
  • View detailed results and metrics in the Evaluations tab
  • )} @@ -827,13 +827,13 @@ function UploadTab({ // ============ TYPES ============ // Types are now imported from '../components/types' -// ============ RESULTS TAB COMPONENT ============ -interface ResultsTabProps { +// ============ EVALUATIONS TAB COMPONENT ============ +interface EvaluationsTabProps { apiKeys: APIKey[]; selectedKeyId: string; } -function ResultsTab({ apiKeys, selectedKeyId }: ResultsTabProps) { +function EvaluationsTab({ apiKeys, selectedKeyId }: EvaluationsTabProps) { const [evalJobs, setEvalJobs] = useState([]); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); @@ -871,14 +871,11 @@ function ResultsTab({ apiKeys, selectedKeyId }: ResultsTabProps) { const data = await response.json(); // API may return an array or an object with data property - let jobs = Array.isArray(data) ? data : (data.data || []); - - // Filter to only show jobs with type: "text" - jobs = jobs.filter((job: any) => job.type === 'text'); + const jobs = Array.isArray(data) ? data : (data.data || []); // Debug logging for score visibility if (jobs.length > 0) { - console.log('[ResultsTab] Sample job data:', { + console.log('[EvaluationsTab] Sample job data:', { id: jobs[0].id, run_name: jobs[0].run_name, hasScore: !!jobs[0].score, @@ -1017,7 +1014,7 @@ function ResultsTab({ apiKeys, selectedKeyId }: ResultsTabProps) { borderColor: '#e5e5e5', boxShadow: '0 1px 3px rgba(0, 0, 0, 0.04)' }}> -

    No evaluation jobs found. Create one from the Upload tab!

    +

    No evaluation jobs found. Create one from the Datasets tab!

    )} From 9bb39ac3788418fdd97115efa012940baa917584 Mon Sep 17 00:00:00 2001 From: nishika26 Date: Thu, 5 Mar 2026 14:26:06 +0530 Subject: [PATCH 3/3] returned respective dataset only --- app/api/evaluations/datasets/route.ts | 2 +- app/api/evaluations/route.ts | 32 +++++++++------------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/app/api/evaluations/datasets/route.ts b/app/api/evaluations/datasets/route.ts index a5eec03..36b3272 100644 --- a/app/api/evaluations/datasets/route.ts +++ b/app/api/evaluations/datasets/route.ts @@ -37,7 +37,7 @@ export async function GET(request: NextRequest) { return NextResponse.json(data, { status: response.status }); } - // Filter to only return text datasets + // Filter to only return text datasets const filteredData = Array.isArray(data) ? data.filter((dataset: any) => dataset.type === 'text') : data.data diff --git a/app/api/evaluations/route.ts b/app/api/evaluations/route.ts index c5de175..3a7077a 100644 --- a/app/api/evaluations/route.ts +++ b/app/api/evaluations/route.ts @@ -2,7 +2,9 @@ import { NextRequest, NextResponse } from 'next/server'; /** * GET /api/evaluations - * Fetches all evaluation jobs + * + * Proxy endpoint to fetch text evaluations only from the backend. + * This endpoint filters and returns only evaluations with type='text'. */ export async function GET(request: NextRequest) { try { @@ -22,29 +24,17 @@ export async function GET(request: NextRequest) { const data = await response.json(); - // Log the structure to help debug score visibility issues - only for text type evaluations - //TODO Fix it later - let items = []; - if (data && Array.isArray(data)) { - items = data.filter((item: any) => item.type === 'text'); - } else if (data && data.data && Array.isArray(data.data)) { - items = data.data.filter((item: any) => item.type === 'text'); + if (!response.ok) { + return NextResponse.json(data, { status: response.status }); } - if (items.length > 0) { - console.log('[GET /api/evaluations] Sample text evaluation structure:', { - firstItem: { - id: items[0].id, - type: items[0].type, - hasScore: !!items[0].score, - hasScores: !!items[0].scores, - scoreKeys: items[0].score ? Object.keys(items[0].score) : [], - scoresKeys: items[0].scores ? Object.keys(items[0].scores) : [] - } - }); - } + const filteredData = Array.isArray(data) + ? data.filter((item: any) => item.type === 'text') + : data.data + ? { ...data, data: data.data.filter((item: any) => item.type === 'text') } + : data; - return NextResponse.json(data, { status: response.status }); + return NextResponse.json(filteredData, { status: response.status }); } catch (error) { console.error('Proxy error:', error); return NextResponse.json(