Skip to content

Commit b5e0e6e

Browse files
committed
use same format as arch_config for usage preferences in request path
1 parent ef2be7c commit b5e0e6e

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

webview-ui/src/components/settings/providers/ArchGw.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,17 @@ export const ArchGw = ({ apiConfiguration, setApiConfigurationField, organizatio
197197
{t("settings:providers.archgwPreferenceConfigUse")}
198198
<div>
199199
<pre style={{ whiteSpace: "pre-wrap" }}>
200-
{`- name: code generation
201-
model: openai/gpt-4.1
202-
usage: generating new code snippets
203-
- name: code understanding
204-
model: openai/gpt-4o-mini
205-
usage: understand and explain existing code snippets`}
200+
{`
201+
- model: openai/gpt-4o
202+
routing_preferences:
203+
- name: code understanding
204+
description: understand and explain code
205+
206+
- model: openai/gpt-4.1
207+
routing_preferences:
208+
- name: code generation
209+
description: generating new code
210+
`}
206211
</pre>
207212
</div>
208213
{t("settings:providers.archgwPreferenceConfigDesc")}

webview-ui/src/utils/validate.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ export function validateApiConfigurationExcludingModelErrors(
308308
return undefined
309309
}
310310

311+
/**
312+
* Validates the ArchGw preference configuration YAML
313+
* @param archgwPreferenceConfig The YAML string to validate
314+
* @returns An object with validation results: { isValid, errorMessage }
315+
*/
311316
export function validateArchGwPreferenceConfig(archgwPreferenceConfig: string) {
312317
try {
313318
// Only validate if not empty
@@ -316,19 +321,33 @@ export function validateArchGwPreferenceConfig(archgwPreferenceConfig: string) {
316321
if (!Array.isArray(parsed)) {
317322
return {
318323
isValid: false,
319-
errorMessage: "YAML must be a list of objects with 'name', 'model' and 'usage'.",
324+
errorMessage: "YAML must be a list of objects, each with 'model' and 'routing_preferences' array.",
320325
}
321326
}
322327
for (const item of parsed) {
323-
if (
324-
typeof item !== "object" ||
325-
typeof item.name !== "string" ||
326-
typeof item.model !== "string" ||
327-
typeof item.usage !== "string"
328-
) {
328+
if (typeof item !== "object" || typeof item.model !== "string") {
329+
return {
330+
isValid: false,
331+
errorMessage: "Each item must have a 'model' string field.",
332+
}
333+
}
334+
if (!Array.isArray(item.routing_preferences)) {
329335
return {
330336
isValid: false,
331-
errorMessage: "Each item must have 'name', 'model' and 'usage' as strings.",
337+
errorMessage: "Each item must have a 'routing_preferences' array.",
338+
}
339+
}
340+
for (const pref of item.routing_preferences) {
341+
if (
342+
typeof pref !== "object" ||
343+
typeof pref.name !== "string" ||
344+
typeof pref.description !== "string"
345+
) {
346+
return {
347+
isValid: false,
348+
errorMessage:
349+
"Each routing preference must be an object with 'name' and 'description' (both strings).",
350+
}
332351
}
333352
}
334353
}

0 commit comments

Comments
 (0)