-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: batch evaluations backend #2
This commit implements the full cycle of a batch evaluation. Now users can run batch evaluations on top of their prompts with dataset data.
- Loading branch information
Showing
43 changed files
with
913 additions
and
287 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
51 changes: 51 additions & 0 deletions
51
...sions/[commitUuid]/documents/[documentUuid]/evaluations/dashboard/_components/Actions.tsx
This file contains 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,51 @@ | ||
'use client' | ||
|
||
import { Button, TableWithHeader } from '@latitude-data/web-ui' | ||
import { runBatchEvaluationAction } from '$/actions/evaluations/runBatch' | ||
import useLatitudeAction from '$/hooks/useLatitudeAction' | ||
import { ROUTES } from '$/services/routes' | ||
import Link from 'next/link' | ||
|
||
export function Actions({ | ||
projectId, | ||
commitUuid, | ||
documentUuid, | ||
}: { | ||
projectId: string | ||
commitUuid: string | ||
documentUuid: string | ||
}) { | ||
const href = ROUTES.projects | ||
.detail({ id: Number(projectId) }) | ||
.commits.detail({ uuid: commitUuid }) | ||
.documents.detail({ uuid: documentUuid }).evaluations.dashboard.connect.root | ||
const { execute: executeBatchEvaluation } = useLatitudeAction( | ||
runBatchEvaluationAction, | ||
) | ||
|
||
return ( | ||
<> | ||
<Link href={href}> | ||
<TableWithHeader.Button>Connect evaluation</TableWithHeader.Button> | ||
</Link> | ||
<Button | ||
fancy | ||
onClick={() => | ||
executeBatchEvaluation({ | ||
projectId: Number(projectId), | ||
commitUuid, | ||
documentUuid, | ||
evaluationIds: [1], | ||
datasetId: 1, | ||
parameters: { | ||
nombre_usuario: 0, | ||
nombre: 2, | ||
}, | ||
}) | ||
} | ||
> | ||
Execute batch evaluation | ||
</Button> | ||
</> | ||
) | ||
} |
This file contains 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
2 changes: 2 additions & 0 deletions
2
apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/layout.tsx
This file contains 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use server' | ||
|
||
import { ReactNode } from 'react' | ||
|
||
import { | ||
|
7 changes: 7 additions & 0 deletions
7
packages/core/public/uploads/workspaces/1/datasets/batchtest.csv
This file contains 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 @@ | ||
Username, Identifier,First name,Last name | ||
booker12,9012,Rachel,Booker | ||
grey07,2070,Laura,Grey | ||
johnson81,4081,Craig,Johnson | ||
jenkins46,9346,Mary,Jenkins | ||
smith79,5079,Jamie,Smith | ||
|
This file contains 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,40 @@ | ||
import { eq, getTableColumns } from 'drizzle-orm' | ||
|
||
import { DocumentLog } from '../browser' | ||
import { database } from '../client' | ||
import { | ||
commits, | ||
documentLogs, | ||
documentVersions, | ||
projects, | ||
workspaces, | ||
} from '../schema' | ||
|
||
export const findWorkspaceFromDocumentLog = async ( | ||
documentLog: DocumentLog, | ||
db = database, | ||
) => { | ||
const result = await db | ||
.select(getTableColumns(workspaces)) | ||
.from(workspaces) | ||
.innerJoin(projects, eq(projects.workspaceId, workspaces.id)) | ||
.innerJoin(commits, eq(commits.projectId, projects.id)) | ||
.innerJoin(documentVersions, eq(documentVersions.commitId, commits.id)) | ||
.where(eq(documentVersions.documentUuid, documentLog.documentUuid)) | ||
.limit(1) | ||
|
||
return result[0] | ||
} | ||
|
||
export const unsafelyFindDocumentLogByUuid = async ( | ||
documentLogUuid: string, | ||
db = database, | ||
) => { | ||
const result = await db | ||
.select() | ||
.from(documentLogs) | ||
.where(eq(documentLogs.uuid, documentLogUuid)) | ||
.limit(1) | ||
|
||
return result[0] | ||
} |
This file contains 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,14 @@ | ||
import { eq } from 'drizzle-orm' | ||
|
||
import { Evaluation } from '../browser' | ||
import { database } from '../client' | ||
import { evaluations } from '../schema' | ||
|
||
export async function unsafelyFindEvaluation( | ||
id: number, | ||
db = database, | ||
): Promise<Evaluation | undefined> { | ||
return await db.query.evaluations.findFirst({ | ||
where: eq(evaluations.id, id), | ||
}) | ||
} |
This file contains 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
Oops, something went wrong.