mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-02 14:32:45 +00:00
converge/final lands on main's lineage: the 2026-08-01 upstream base with the ee tree deleted, the canary pipeline and the red fixes, melded with the live line's commits — project language, honest empty states, native flags, the assistant on Hanzo cloud, the replay writer chain, heatmaps, /v1 serving, and the rust purge. Crates whose planes the Go cloud binary serves stay deleted; the workspace keeps what python and nodejs actually build (insightsql/parser, deltalite, replay-anonymizer, cyclotron). Replay files by org, not project token; a token with no org goes to the DLQ.
150 lines
4.4 KiB
TypeScript
150 lines
4.4 KiB
TypeScript
import { MakeLogicType, actions, connect, kea, path, reducers } from 'kea'
|
|
import { loaders } from 'kea-loaders'
|
|
|
|
import api from 'lib/api'
|
|
import { toast } from 'lib/elements/Toast'
|
|
import { teamLogic } from 'scenes/teamLogic'
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface llmEvaluationExecutionLogicValues {
|
|
currentTeamId: number | null // teamLogic
|
|
evaluationRun: {
|
|
workflow_id: string
|
|
} | null
|
|
evaluationRunLoading: boolean
|
|
lastRunWorkflowId: string | null
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface llmEvaluationExecutionLogicActions {
|
|
runEvaluation: (
|
|
evaluationId: string,
|
|
targetEventId: string,
|
|
timestamp: string,
|
|
event: string,
|
|
distinctId?: string
|
|
) => {
|
|
distinctId: string | undefined
|
|
evaluationId: string
|
|
event: string
|
|
targetEventId: string
|
|
timestamp: string
|
|
}
|
|
runEvaluationFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
runEvaluationSuccess: (
|
|
evaluationRun: {
|
|
evaluation: {
|
|
id: string
|
|
name: string
|
|
}
|
|
status: string
|
|
target_event_id: string
|
|
workflow_id: string
|
|
},
|
|
payload?: {
|
|
distinctId: string | undefined
|
|
evaluationId: string
|
|
event: string
|
|
targetEventId: string
|
|
timestamp: string
|
|
}
|
|
) => {
|
|
evaluationRun: {
|
|
evaluation: {
|
|
id: string
|
|
name: string
|
|
}
|
|
status: string
|
|
target_event_id: string
|
|
workflow_id: string
|
|
}
|
|
payload?: {
|
|
distinctId: string | undefined
|
|
evaluationId: string
|
|
event: string
|
|
targetEventId: string
|
|
timestamp: string
|
|
}
|
|
}
|
|
}
|
|
|
|
export type llmEvaluationExecutionLogicType = MakeLogicType<
|
|
llmEvaluationExecutionLogicValues,
|
|
llmEvaluationExecutionLogicActions
|
|
>
|
|
|
|
export const llmEvaluationExecutionLogic = kea<llmEvaluationExecutionLogicType>([
|
|
path(['products', 'ai_observability', 'frontend', 'llmEvaluationExecutionLogic']),
|
|
connect(() => ({
|
|
values: [teamLogic, ['currentTeamId']],
|
|
})),
|
|
actions({
|
|
runEvaluation: (
|
|
evaluationId: string,
|
|
targetEventId: string,
|
|
timestamp: string,
|
|
event: string,
|
|
distinctId?: string
|
|
) => ({
|
|
evaluationId,
|
|
targetEventId,
|
|
timestamp,
|
|
event,
|
|
distinctId,
|
|
}),
|
|
}),
|
|
loaders(({ values }) => ({
|
|
evaluationRun: [
|
|
null as { workflow_id: string } | null,
|
|
{
|
|
runEvaluation: async ({ evaluationId, targetEventId, timestamp, event, distinctId }) => {
|
|
if (!values.currentTeamId) {
|
|
throw new Error('No project selected')
|
|
}
|
|
|
|
try {
|
|
const payload: {
|
|
evaluation_id: string
|
|
target_event_id: string
|
|
timestamp: string
|
|
event: string
|
|
distinct_id?: string
|
|
} = {
|
|
evaluation_id: evaluationId,
|
|
target_event_id: targetEventId,
|
|
timestamp: timestamp,
|
|
event: event,
|
|
}
|
|
|
|
if (distinctId) {
|
|
payload.distinct_id = distinctId
|
|
}
|
|
|
|
const response = await api.evaluationRuns.create(payload)
|
|
|
|
toast.success('Evaluation started successfully')
|
|
return response
|
|
} catch (error) {
|
|
toast.error('Failed to start evaluation')
|
|
throw error
|
|
}
|
|
},
|
|
},
|
|
],
|
|
})),
|
|
reducers({
|
|
lastRunWorkflowId: [
|
|
null as string | null,
|
|
{
|
|
runEvaluationSuccess: (_, { evaluationRun }) => evaluationRun?.workflow_id || null,
|
|
},
|
|
],
|
|
}),
|
|
])
|