-
Notifications
You must be signed in to change notification settings - Fork 0
UI: STT Evals #44
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
nishika26
wants to merge
5
commits into
main
Choose a base branch
from
feature/stt_eval
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.
Open
UI: STT Evals #44
Changes from all commits
Commits
Show all changes
5 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
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
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
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,26 @@ | ||
| import { NextResponse, NextRequest } from 'next/server'; | ||
|
|
||
| export async function GET( | ||
| request: Request, | ||
| { params }: { params: Promise<{ dataset_id: string }> } | ||
| ) { | ||
| const { dataset_id } = await params; | ||
| const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
| const apiKey = request.headers.get('X-API-KEY'); | ||
|
|
||
| try { | ||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/datasets/${dataset_id}`, { | ||
| headers: { | ||
| 'X-API-KEY': apiKey || '', | ||
| }, | ||
| }); | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { success: false, error: 'Failed to fetch dataset', data: null }, | ||
| { status: 500 } | ||
| ); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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 { NextResponse, NextRequest } from 'next/server'; | ||
|
|
||
|
|
||
|
|
||
| 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'); | ||
|
|
||
| try { | ||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/datasets`, { | ||
| headers: { | ||
| 'X-API-KEY': apiKey || '', | ||
| }, | ||
| }); | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { success: false, error: error, data: null }, | ||
| { status: 500 } | ||
| ); | ||
nishika26 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const apiKey = request.headers.get('X-API-KEY'); | ||
| if (!apiKey) { | ||
| return NextResponse.json({ | ||
| error: 'Missing X-API-KEY. Either generate an API Key. Contact Kaapi team for more details' | ||
| }, | ||
| { | ||
| status: 401 | ||
| } | ||
|
|
||
| ) | ||
| } | ||
| const body=await request.json(); | ||
| const backendUrl=process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
|
|
||
| const response=await fetch(`${backendUrl}/api/v1/evaluations/stt/datasets`, { | ||
| method:'POST', | ||
| body:JSON.stringify(body), | ||
| headers:{ | ||
| 'X-API-KEY':apiKey, | ||
| 'Content-Type':'application/json' | ||
| }, | ||
| }); | ||
| const data=await response.json(); | ||
| return NextResponse.json(data, {status:response.status}) | ||
|
|
||
|
|
||
|
|
||
| } catch (error) { | ||
| console.error('Proxy error:', error); | ||
| return NextResponse.json( | ||
| {error: 'Failed to forward request to backend', details: error instanceof Error ? error.message : String(error)}, | ||
| {status:500} | ||
| ); | ||
nishika26 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| } | ||
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,49 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
|
|
||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| // Get the API key from request headers | ||
| const apiKey = request.headers.get('X-API-KEY'); | ||
|
|
||
| if (!apiKey) { | ||
| return NextResponse.json( | ||
| { error: 'Missing X-API-KEY header' }, | ||
| { status: 401 } | ||
| ); | ||
| } | ||
|
|
||
| // Get the form data from the request | ||
| const formData = await request.formData(); | ||
|
|
||
| // Get backend URL from environment variable | ||
| const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
|
|
||
| // Forward the request to the actual backend | ||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/files`, { | ||
| method: 'POST', | ||
| body: formData, | ||
| headers: { | ||
| 'X-API-KEY': apiKey, | ||
|
|
||
| }, | ||
| }); | ||
|
|
||
| // Handle empty responses (204 No Content, etc.) | ||
| const text = await response.text(); | ||
| const data = text ? JSON.parse(text) : { success: true }; | ||
|
|
||
| // Return the response with the same status code | ||
| if (!response.ok) { | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } | ||
|
|
||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error: any) { | ||
| console.error('Proxy error:', error); | ||
| return NextResponse.json( | ||
| { error: 'Failed to forward request to backend', details: error instanceof Error ? error.message : String(error) }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } |
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,64 @@ | ||
| import { NextResponse, NextRequest } from 'next/server'; | ||
|
|
||
| export async function GET( | ||
| request: Request, | ||
| { params }: { params: Promise<{ result_id: string }> } | ||
| ) { | ||
| const { result_id } = await params; | ||
| const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
nishika26 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const apiKey = request.headers.get('X-API-KEY'); | ||
|
|
||
| try { | ||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/results/${result_id}`, { | ||
| headers: { | ||
| 'X-API-KEY': apiKey || '', | ||
| }, | ||
| }); | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { success: false, error: 'Failed to fetch results', data: null }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| export async function PATCH( | ||
| request: Request, | ||
| { params }: { params: Promise<{ result_id: string }> } | ||
| ) { | ||
| const { result_id } = await params; | ||
| const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
| const apiKey = request.headers.get('X-API-KEY'); | ||
|
|
||
| if (!apiKey) { | ||
| return NextResponse.json( | ||
| { error: 'Missing X-API-KEY header' }, | ||
| { status: 401 } | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| const body = await request.json(); | ||
|
|
||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/results/${result_id}`, { | ||
| method: 'PATCH', | ||
| headers: { | ||
| 'X-API-KEY': apiKey || '', | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(body), | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { success: false, error: 'Failed to update result feedback', data: null }, | ||
| { status: 500 } | ||
| ); | ||
nishika26 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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,26 @@ | ||
| import { NextResponse, NextRequest } from 'next/server'; | ||
|
|
||
| export async function GET( | ||
| request: Request, | ||
| { params }: { params: Promise<{ run_id: string }> } | ||
| ) { | ||
| const { run_id } = await params; | ||
| const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
| const apiKey = request.headers.get('X-API-KEY'); | ||
|
|
||
| try { | ||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/runs/${run_id}`, { | ||
| headers: { | ||
| 'X-API-KEY': apiKey || '', | ||
| }, | ||
| }); | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { success: false, error: 'Failed to fetch the run', data: null }, | ||
| { status: 500 } | ||
| ); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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,64 @@ | ||
| import { NextResponse, NextRequest } from 'next/server'; | ||
|
|
||
|
|
||
|
|
||
| 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'); | ||
|
|
||
| try { | ||
| const response = await fetch(`${backendUrl}/api/v1/evaluations/stt/runs`, { | ||
| headers: { | ||
| 'X-API-KEY': apiKey || '', | ||
| }, | ||
| }); | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { success: false, error: error, data: null }, | ||
| { status: 500 } | ||
| ); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const apiKey = request.headers.get('X-API-KEY'); | ||
| if (!apiKey) { | ||
| return NextResponse.json({ | ||
| error: 'Missing X-API-KEY. Either generate an API Key. Contact Kaapi team for more details' | ||
| }, | ||
| { | ||
| status: 401 | ||
| } | ||
|
|
||
| ) | ||
| } | ||
| const body=await request.json(); | ||
| const backendUrl=process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'; | ||
|
|
||
| const response=await fetch(`${backendUrl}/api/v1/evaluations/stt/runs`, { | ||
| method:'POST', | ||
| body:JSON.stringify(body), | ||
| headers:{ | ||
| 'X-API-KEY':apiKey, | ||
| 'Content-Type':'application/json' | ||
| }, | ||
| }); | ||
| const data=await response.json(); | ||
| return NextResponse.json(data, {status:response.status}) | ||
|
|
||
|
|
||
|
|
||
| } catch (error) { | ||
| console.error('Proxy error:', error); | ||
| return NextResponse.json( | ||
| {error: 'Failed to forward request to backend', details: error instanceof Error ? error.message : String(error)}, | ||
| {status:500} | ||
| ); | ||
nishika26 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| } | ||
This file was deleted.
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.