From 81c5e7b9ed218e342aba154cdd5ed436c7775966 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 28 Dec 2025 13:54:09 -0500 Subject: wip: benchmark --- packages/console/app/src/routes/bench/index.tsx | 52 ++++++++++++++++++++++ .../console/app/src/routes/bench/submission.ts | 29 ++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 packages/console/app/src/routes/bench/index.tsx create mode 100644 packages/console/app/src/routes/bench/submission.ts (limited to 'packages/console/app') diff --git a/packages/console/app/src/routes/bench/index.tsx b/packages/console/app/src/routes/bench/index.tsx new file mode 100644 index 000000000..adf31fbc6 --- /dev/null +++ b/packages/console/app/src/routes/bench/index.tsx @@ -0,0 +1,52 @@ +import { Title } from "@solidjs/meta" +import { createAsync, query } from "@solidjs/router" +import { For } from "solid-js" +import { Database, desc } from "@opencode-ai/console-core/drizzle/index.js" +import { BenchmarkTable } from "@opencode-ai/console-core/schema/benchmark.sql.js" + +async function getBenchmarks() { + "use server" + const rows = await Database.use((tx) => + tx.select().from(BenchmarkTable).orderBy(desc(BenchmarkTable.timeCreated)).limit(100), + ) + return rows.map((row) => { + const parsed = JSON.parse(row.result) as { averageScore: number } + return { + agent: row.agent, + model: row.model, + averageScore: parsed.averageScore, + } + }) +} + +const queryBenchmarks = query(getBenchmarks, "benchmarks.list") + +export default function Bench() { + const benchmarks = createAsync(() => queryBenchmarks()) + + return ( +
+ Benchmark + + + + + + + + + + + {(row) => ( + + + + + + )} + + +
AgentModelAverage Score
{row.agent}{row.model}{row.averageScore}
+
+ ) +} diff --git a/packages/console/app/src/routes/bench/submission.ts b/packages/console/app/src/routes/bench/submission.ts new file mode 100644 index 000000000..94639439b --- /dev/null +++ b/packages/console/app/src/routes/bench/submission.ts @@ -0,0 +1,29 @@ +import type { APIEvent } from "@solidjs/start/server" +import { Database } from "@opencode-ai/console-core/drizzle/index.js" +import { BenchmarkTable } from "@opencode-ai/console-core/schema/benchmark.sql.js" +import { Identifier } from "@opencode-ai/console-core/identifier.js" + +interface SubmissionBody { + model: string + agent: string + result: string +} + +export async function POST(event: APIEvent) { + const body = (await event.request.json()) as SubmissionBody + + if (!body.model || !body.agent || !body.result) { + return Response.json({ error: "All fields are required" }, { status: 400 }) + } + + await Database.use((tx) => + tx.insert(BenchmarkTable).values({ + id: Identifier.create("benchmark"), + model: body.model, + agent: body.agent, + result: body.result, + }), + ) + + return Response.json({ success: true }, { status: 200 }) +} -- cgit v1.2.3