Skip to content

feat: add named exercise groups to web-evals #6083

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions apps/web-evals/src/actions/exercise-groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use server"

import exerciseGroups from "@/lib/exercise-groups.json"

export interface ExerciseGroup {
name: string
exercises: string[]
}

export const getExerciseGroups = async (): Promise<ExerciseGroup[]> => {
return exerciseGroups.groups
}
54 changes: 46 additions & 8 deletions apps/web-evals/src/app/runs/new/new-run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { useForm, FormProvider } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import fuzzysort from "fuzzysort"
import { toast } from "sonner"
import { X, Rocket, Check, ChevronsUpDown, SlidersHorizontal, Book, CircleCheck } from "lucide-react"
import { X, Rocket, Check, ChevronsUpDown, SlidersHorizontal, Book, CircleCheck, Users } from "lucide-react"

import { globalSettingsSchema, providerSettingsSchema, EVALS_SETTINGS, getModelId } from "@roo-code/types"

import { createRun } from "@/actions/runs"
import { getExercises } from "@/actions/exercises"
import { getExerciseGroups } from "@/actions/exercise-groups"
import {
createRunSchema,
type CreateRun,
Expand Down Expand Up @@ -70,6 +71,7 @@ export function NewRun() {

const models = useOpenRouterModels()
const exercises = useQuery({ queryKey: ["getExercises"], queryFn: () => getExercises() })
const exerciseGroups = useQuery({ queryKey: ["getExerciseGroups"], queryFn: () => getExerciseGroups() })

const form = useForm<CreateRun>({
resolver: zodResolver(createRunSchema),
Expand Down Expand Up @@ -178,6 +180,18 @@ export function NewRun() {
[clearErrors, setValue],
)

const onSelectExerciseGroup = useCallback(
(groupName: string) => {
const group = exerciseGroups.data?.find((g) => g.name === groupName)
if (group) {
setValue("suite", "partial")
setValue("exercises", group.exercises)
toast.success(`Selected "${groupName}" exercise group with ${group.exercises.length} exercises`)
Copy link

Choose a reason for hiding this comment

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

Use the i18n function (e.g., t('...')) for the success toast message instead of inline English strings.

Suggested change
toast.success(`Selected "${groupName}" exercise group with ${group.exercises.length} exercises`)
toast.success(t('Selected "{{groupName}}" exercise group with {{count}} exercises', { groupName, count: group.exercises.length }))

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
},
[exerciseGroups.data, setValue],
)

return (
<>
<FormProvider {...form}>
Expand Down Expand Up @@ -309,13 +323,37 @@ export function NewRun() {
</TabsList>
</Tabs>
{suite === "partial" && (
<MultiSelect
options={exercises.data?.map((path) => ({ value: path, label: path })) || []}
onValueChange={(value) => setValue("exercises", value)}
placeholder="Select"
variant="inverted"
maxCount={4}
/>
<>
{exerciseGroups.data && exerciseGroups.data.length > 0 && (
<div className="flex flex-wrap gap-2 mt-2 mb-2">
<div className="text-sm text-muted-foreground flex items-center gap-1">
<Users className="size-4" />
Predefined groups:
</div>
{exerciseGroups.data.map((group) => (
<Button
key={group.name}
type="button"
variant="outline"
size="sm"
onClick={() => onSelectExerciseGroup(group.name)}
className="text-xs">
{group.name} ({group.exercises.length})
</Button>
))}
</div>
)}
<MultiSelect
options={
exercises.data?.map((path) => ({ value: path, label: path })) || []
}
onValueChange={(value) => setValue("exercises", value)}
placeholder="Select"
variant="inverted"
maxCount={4}
defaultValue={form.watch("exercises") || []}
/>
</>
)}
<FormMessage />
</FormItem>
Expand Down
35 changes: 35 additions & 0 deletions apps/web-evals/src/lib/exercise-groups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"groups": [
{
"name": "Hard",
"exercises": [
"go/connect",
"go/robot-simulator",
"go/react",
"go/forth",
"go/bowling",
"go/book-store",
"go/matrix",
"java/transpose",
"java/hangman",
"java/change",
"java/bowling",
"javascript/lodash",
"javascript/zebra-puzzle",
"javascript/connect",
"javascript/food-chain",
"javascript/go-counting",
"javascript/scale-generator",
"javascript/transpose",
"python/affine-cipher",
"python/forth",
"python/transpose",
"python/wordy",
"rust/ocr-numbers",
"rust/forth",
"rust/doubly-linked-list",
"rust/xorcism"
]
}
]
}