Skip to content
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

Decouple evaluation logs from aggregations #230

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use server'

import { EvaluationsRepository } from '@latitude-data/core/repositories'
import { getEvaluationTotalsQuery } from '@latitude-data/core/services/evaluationResults/index'
import { findCommitCached } from '$/app/(private)/_data-access'
import { z } from 'zod'

import { withDocument } from '../procedures'

export const computeEvaluationResultsCountersAction = withDocument
.createServerAction()
.input(
z.object({
commitUuid: z.string(),
documentUuid: z.string(),
evaluationId: z.number(),
}),
)
.handler(async ({ input, ctx }) => {
const { evaluationId, documentUuid } = input
const { workspace } = ctx
const evaluationScope = new EvaluationsRepository(workspace.id)
const commit = await findCommitCached({
projectId: ctx.project.id,
uuid: input.commitUuid,
})
const evaluation = await evaluationScope
.find(evaluationId)
.then((r) => r.unwrap())
return getEvaluationTotalsQuery({
workspaceId: workspace.id,
commit,
evaluation,
documentUuid,
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use server'

import { EvaluationsRepository } from '@latitude-data/core/repositories'
import { getEvaluationMeanValueQuery } from '@latitude-data/core/services/evaluationResults/index'
import { findCommitCached } from '$/app/(private)/_data-access'
import { z } from 'zod'

import { withDocument } from '../procedures'

export const computeEvaluationResultsMeanValueAction = withDocument
.createServerAction()
.input(
z.object({
commitUuid: z.string(),
documentUuid: z.string(),
evaluationId: z.number(),
}),
)
.handler(async ({ input, ctx }) => {
const { evaluationId, documentUuid } = input
const { workspace } = ctx
const evaluationScope = new EvaluationsRepository(workspace.id)
const commit = await findCommitCached({
projectId: ctx.project.id,
uuid: input.commitUuid,
})
const evaluation = await evaluationScope
.find(evaluationId)
.then((r) => r.unwrap())
return getEvaluationMeanValueQuery({
workspaceId: workspace.id,
commit,
evaluation,
documentUuid,
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use server'

import { EvaluationsRepository } from '@latitude-data/core/repositories'
import { getEvaluationModalValueQuery } from '@latitude-data/core/services/evaluationResults/index'
import { findCommitCached } from '$/app/(private)/_data-access'
import { z } from 'zod'

import { withDocument } from '../procedures'

export const computeEvaluationResultsModalValueAction = withDocument
.createServerAction()
.input(
z.object({
commitUuid: z.string(),
documentUuid: z.string(),
evaluationId: z.number(),
}),
)
.handler(async ({ input, ctx }) => {
const { evaluationId, documentUuid } = input
const { workspace } = ctx
const evaluationScope = new EvaluationsRepository(workspace.id)
const commit = await findCommitCached({
projectId: ctx.project.id,
uuid: input.commitUuid,
})
const evaluation = await evaluationScope
.find(evaluationId)
.then((r) => r.unwrap())
return getEvaluationModalValueQuery({
workspaceId: workspace.id,
commit,
evaluation,
documentUuid,
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ export const computeEvaluationResultsWithMetadataAction = withProject
evaluation,
documentUuid,
draft: commit,
limit: 1000,
}).then((r) => r.unwrap())
})
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ export default function Chat({
for await (const serverEvent of readStreamableValue(output)) {
if (!serverEvent) continue

console.log('serverEvent', serverEvent)

const { event, data } = serverEvent
const hasMessages = 'messages' in data
if (hasMessages) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

import {
EvaluationDto,
EvaluationResultableType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client'

import { useState } from 'react'
import { useEffect, useState } from 'react'

import { EvaluationDto } from '@latitude-data/core/browser'
import { EvaluationResultWithMetadata } from '@latitude-data/core/repositories'
import { type EvaluationResultWithMetadata } from '@latitude-data/core/repositories'
import {
TableBlankSlate,
Text,
Expand All @@ -12,16 +12,19 @@ import {
useCurrentProject,
} from '@latitude-data/web-ui'
import { DocumentRoutes, ROUTES } from '$/services/routes'
import useEvaluationResultsWithMetadata from '$/stores/evaluationResultsWithMetadata'
import { useProviderLog } from '$/stores/providerLogs'
import Link from 'next/link'

import { EvaluationResultInfo } from './EvaluationResultInfo'
import { EvaluationResultsTable } from './EvaluationResultsTable'
import { EvaluationStatusBanner } from './EvaluationStatusBanner'

const FIVE_SECONDS = 5000

export function EvaluationResults({
evaluation,
evaluationResults,
evaluationResults: serverData,
}: {
evaluation: EvaluationDto
evaluationResults: EvaluationResultWithMetadata[]
Expand All @@ -33,6 +36,27 @@ export function EvaluationResults({
EvaluationResultWithMetadata | undefined
>(undefined)
const { data: providerLog } = useProviderLog(selectedResult?.providerLogId)
const { data: evaluationResults, mutate } = useEvaluationResultsWithMetadata(
{
evaluationId: evaluation.id,
documentUuid: document.documentUuid,
commitUuid: commit.uuid,
projectId: project.id,
},
{
fallbackData: serverData,
},
)
Copy link
Collaborator

@geclos geclos Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the interval refetch every x seconds please, we need it until we implement realtime streaming of logs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can manually refetch with websockets, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you mean from actual real logs, not only from batches

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do it from websockets but until that is implemented i don't want to break the realtime feeling of this section


// FIXME: Listen to websockets to update new evaluation results
useEffect(() => {
const interval = setInterval(() => {
mutate()
}, FIVE_SECONDS)

return () => clearInterval(interval)
}, [mutate])

return (
<div className='flex flex-col gap-4'>
<Text.H4>Evaluation Results</Text.H4>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client'

import { Evaluation, EvaluationMeanValue } from '@latitude-data/core/browser'
import { RangeBadge } from '@latitude-data/web-ui'
import useEvaluationResultsMeanValue from '$/stores/evaluationResultCharts/evaluationResultsMeanValue'

import Panel from '../Panel'

export default function MeanValuePanel({
mean,
commitUuid,
documentUuid,
evaluation,
}: {
commitUuid: string
documentUuid: string
evaluation: Evaluation
mean: EvaluationMeanValue
}) {
const { data } = useEvaluationResultsMeanValue(
{
commitUuid,
documentUuid,
evaluationId: evaluation.id,
},
{
fallbackData: mean,
},
)
const config = evaluation.configuration.detail!
const defaultMinValue = config.range.from
const defaultMaxValue = config.range.to
return (
<Panel
label='Current average'
additionalInfo='The mean value of all the evaluated results from the current version.'
>
<div className='w-fit'>
<RangeBadge
minValue={data?.minValue ?? defaultMinValue}
maxValue={data?.maxValue ?? defaultMaxValue}
value={data?.meanValue ?? 0}
/>
</div>
</Panel>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use client'

import { EvaluationModalValue } from '@latitude-data/core/browser'
import { Text } from '@latitude-data/web-ui'
import useEvaluationResultsModalValue from '$/stores/evaluationResultCharts/evaluationResultsModalValue'

import Panel from '../Panel'

export default function ModalValuePanel({
modal,
commitUuid,
documentUuid,
evaluationId,
}: {
commitUuid: string
documentUuid: string
evaluationId: number
modal: EvaluationModalValue
}) {
const { data } = useEvaluationResultsModalValue(
{
commitUuid,
documentUuid,
evaluationId,
},
{
fallbackData: modal,
},
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for all of these

return (
<Panel
label='Value more repeated'
additionalInfo='Value more repeated in the evaluation results.'
>
<Text.H3B>{data?.mostCommon ?? '-'}</Text.H3B>
<Text.H3 color='foregroundMuted'>
{' '}
It appeared ({data?.percentage ?? '0'}%)
</Text.H3>
</Panel>
)
}
Loading
Loading