-
Notifications
You must be signed in to change notification settings - Fork 0
Evals UI: Filter text eval jobs for eval jobs page #52
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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; | ||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. STT filtering misses the This code only filters top-level arrays and Proposed fix- 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;
+ const filteredData = Array.isArray(data)
+ ? data.filter((dataset: any) => dataset.type === 'stt')
+ : Array.isArray(data?.datasets)
+ ? { ...data, datasets: data.datasets.filter((dataset: any) => dataset.type === 'stt') }
+ : Array.isArray(data?.data)
+ ? { ...data, data: data.data.filter((dataset: any) => dataset.type === 'stt') }
+ : data;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return NextResponse.json(filteredData, { status: response.status }); | ||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||
| return NextResponse.json( | ||||||||||||||||||||||||||||||
| { success: false, error: error, data: null }, | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard nested payload shape before calling
.filter().If
data.datais present but not an array, Line 44 throws at runtime. Add anArray.isArray(data.data)check before filtering.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents