oA sfc to manage and UI to visualize (made with tailwindcss script setup typescript) for these endpoints:
import pyspark
from fastapi import APIRouter, HTTPException, Request
from .schema import (FineTuningCheckpointList, FineTuningEventList,
FineTuningJobCreate, FineTuningJobList,
FineTuningJobResponse, FineTuningJobUpdate)
from .schema.trait import SparkFineTuningService
from .shared.db import db
app = APIRouter(tags=["Fine-tuning"])
service = SparkFineTuningService(
pyspark.SparkContext(appName="SparkFineTuningService").getOrCreate() # type: ignore
)
@app.post("/fine_tuning/jobs", response_model=FineTuningJobResponse)
async def create_job(req: Request, job: FineTuningJobCreate):
try:
org_id = req.headers.get("X-Org-Id", None)
if not org_id:
raise HTTPException(status_code=400, detail="X-Org-Id header is required")
return await service.create_fine_tuning_job(db, org_id=org_id, job=job)
except Exception as e:
raise HTTPException(status_code=400, detail=str(e))
@app.get("/fine_tuning/jobs/{job_id}", response_model=FineTuningJobResponse)
async def get_job(job_id: str):
job = await service.get_fine_tuning_job(db, job_id=job_id)
if not job:
raise HTTPException(status_code=404, detail="Fine-tuning job not found")
return job
@app.post("/fine_tuning/jobs/{job_id}", response_model=FineTuningJobResponse)
async def update_job(job_id: str, job_update: FineTuningJobUpdate):
updated_job = await service.update_fine_tuning_job(
db, job_id=job_id, job_update=job_update
)
if not updated_job:
raise HTTPException(status_code=404, detail="Fine-tuning job not found")
return updated_job
@app.delete("/fine_tuning/jobs/{job_id}")
async def delete_job(job_id: str):
await service.delete_fine_tuning_job(db, job_id=job_id)
@app.get("/fine_tuning/jobs", response_model=FineTuningJobList)
async def list_jobs(after: str, limit: int = 20):
return await service.list_fine_tuning_jobs(db, after=after, limit=limit)
@app.get("/fine_tuning/jobs/{job_id}/events", response_model=FineTuningEventList)
async def list_events(job_id: str, after: str, limit: int = 20):
return await service.list_fine_tuning_events(
db, job_id=job_id, after=after, limit=limit
)
@app.get(
"/fine_tuning/jobs/{job_id}/checkpoints", response_model=FineTuningCheckpointList
)
async def list_checkpoints(job_id: str, after: str, limit: int = 10):
return await service.list_fine_tuning_checkpoints(
db, job_id=job_id, after=after, limit=limit
)
@app.post("/fine_tuning/jobs/{job_id}/cancel", response_model=FineTuningJobResponse)
async def cancel_job(job_id: str):
cancelled_job = await service.cancel_fine_tuning_job(db, job_id=job_id)
if not cancelled_job:
raise HTTPException(status_code=404, detail="Fine-tuning job not found")
return cancelled_job
The interface must be very compeling and attractive and must include the API call functions and also a canvas to render the graph of the hyperparameters that are being monitores from the finetuned job as wekk an Uload element to Upload the dataset csv or jsonl