Skip to content

Commit f747215

Browse files
authored
Improve evals settings import (#2298)
1 parent 8f35671 commit f747215

File tree

3 files changed

+60
-16
lines changed

3 files changed

+60
-16
lines changed

evals/apps/web/src/app/runs/new/new-run.tsx

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import fuzzysort from "fuzzysort"
99
import { toast } from "sonner"
1010
import { X, Rocket, Check, ChevronsUpDown, HardDriveUpload, CircleCheck } from "lucide-react"
1111

12-
import { globalSettingsSchema, rooCodeDefaults } from "@evals/types"
12+
import { globalSettingsSchema, providerSettingsSchema, rooCodeDefaults } from "@evals/types"
1313

1414
import { createRun } from "@/lib/server/runs"
1515
import { createRunSchema as formSchema, type CreateRun as FormValues } from "@/lib/schemas"
@@ -73,7 +73,6 @@ export function NewRun() {
7373

7474
const {
7575
setValue,
76-
setError,
7776
clearErrors,
7877
watch,
7978
formState: { isSubmitting },
@@ -147,14 +146,51 @@ export function NewRun() {
147146
clearErrors("settings")
148147

149148
try {
150-
const result = z.object({ globalSettings: globalSettingsSchema }).parse(JSON.parse(await file.text()))
151-
setValue("settings", result.globalSettings)
149+
const { providerProfiles, globalSettings } = z
150+
.object({
151+
providerProfiles: z.object({
152+
currentApiConfigName: z.string(),
153+
apiConfigs: z.record(z.string(), providerSettingsSchema),
154+
}),
155+
globalSettings: globalSettingsSchema,
156+
})
157+
.parse(JSON.parse(await file.text()))
158+
159+
const providerSettings = providerProfiles.apiConfigs[providerProfiles.currentApiConfigName] ?? {}
160+
161+
if (providerSettings.apiProvider === "openrouter" && providerSettings.openRouterModelId) {
162+
const {
163+
openRouterModelId,
164+
modelMaxTokens,
165+
modelMaxThinkingTokens,
166+
modelTemperature,
167+
includeMaxTokens,
168+
} = providerSettings
169+
170+
const model = openRouterModelId
171+
172+
const settings = {
173+
...rooCodeDefaults,
174+
openRouterModelId,
175+
modelMaxTokens,
176+
modelMaxThinkingTokens,
177+
modelTemperature,
178+
includeMaxTokens,
179+
...globalSettings,
180+
}
181+
182+
setValue("model", model)
183+
setValue("settings", settings)
184+
} else {
185+
setValue("settings", globalSettings)
186+
}
187+
152188
event.target.value = ""
153-
} catch (_error) {
154-
setError("settings", { message: "Error parsing JSON file. Please check the file format." })
189+
} catch (e) {
190+
toast.error(e instanceof Error ? e.message : "An unknown error occurred.")
155191
}
156192
},
157-
[clearErrors, setError, setValue],
193+
[clearErrors, setValue],
158194
)
159195

160196
return (

evals/apps/web/src/app/runs/new/settings-diff.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Fragment, HTMLAttributes } from "react"
22

3-
import { RooCodeSettings } from "@evals/types"
3+
import { RooCodeSettings, ROO_CODE_SETTINGS_KEYS } from "@evals/types"
44

55
import { cn } from "@/lib/utils"
66

@@ -23,7 +23,8 @@ export function SettingsDiff({
2323
<div className="font-medium text-muted-foreground">Setting</div>
2424
<div className="font-medium text-muted-foreground">Default</div>
2525
<div className="font-medium text-muted-foreground">Custom</div>
26-
{Object.entries(defaults).flatMap(([key, defaultValue]) => {
26+
{ROO_CODE_SETTINGS_KEYS.map((key) => {
27+
const defaultValue = defaults[key as keyof typeof defaults]
2728
const customValue = custom[key as keyof typeof custom]
2829
const isDefault = JSON.stringify(defaultValue) === JSON.stringify(customValue)
2930

@@ -49,9 +50,15 @@ type SettingDiffProps = HTMLAttributes<HTMLDivElement> & {
4950
export function SettingDiff({ name, defaultValue, customValue, ...props }: SettingDiffProps) {
5051
return (
5152
<Fragment {...props}>
52-
<div className="overflow-hidden font-mono">{name}</div>
53-
<pre className="inline text-rose-500 line-through">{defaultValue}</pre>
54-
<pre className="inline text-teal-500">{customValue}</pre>
53+
<div className="overflow-hidden font-mono" title={name}>
54+
{name}
55+
</div>
56+
<pre className="overflow-hidden inline text-rose-500 line-through" title={defaultValue}>
57+
{defaultValue}
58+
</pre>
59+
<pre className="overflow-hidden inline text-teal-500" title={customValue}>
60+
{customValue}
61+
</pre>
5562
</Fragment>
5663
)
5764
}

evals/packages/types/src/roo-code.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,10 @@ export const providerSettingsSchema = z.object({
373373
requestyApiKey: z.string().optional(),
374374
requestyModelId: z.string().optional(),
375375
requestyModelInfo: modelInfoSchema.optional(),
376-
// Claude 3.7 Sonnet Thinking
377-
modelTemperature: z.number().nullish(),
378-
modelMaxTokens: z.number().optional(),
379-
modelMaxThinkingTokens: z.number().optional(),
380376
// Generic
377+
modelMaxTokens: z.number().optional(), // Currently only used by Anthropic hybrid thinking models.
378+
modelMaxThinkingTokens: z.number().optional(), // Currently only used by Anthropic hybrid thinking models.
379+
modelTemperature: z.number().nullish(),
381380
includeMaxTokens: z.boolean().optional(),
382381
// Fake AI
383382
fakeAi: z.unknown().optional(),
@@ -619,6 +618,8 @@ export const rooCodeSettingsSchema = providerSettingsSchema.merge(globalSettings
619618

620619
export type RooCodeSettings = GlobalSettings & ProviderSettings
621620

621+
export const ROO_CODE_SETTINGS_KEYS = [...GLOBAL_SETTINGS_KEYS, ...PROVIDER_SETTINGS_KEYS] as Keys<RooCodeSettings>[]
622+
622623
/**
623624
* SecretState
624625
*/

0 commit comments

Comments
 (0)