codexmate 0.1.38 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.vi.md +1 -1
- package/README.zh.md +1 -1
- package/cli.js +4 -1
- package/lib/model-test.js +126 -21
- package/package.json +3 -1
- package/plugins/prompt-templates/overview.mjs +1 -7
- package/web-ui/modules/i18n/locales/en.mjs +1945 -2018
- package/web-ui/modules/i18n/locales/expand.mjs +18 -0
- package/web-ui/modules/i18n/locales/ja.mjs +1946 -2019
- package/web-ui/modules/i18n/locales/keys.mjs +1945 -0
- package/web-ui/modules/i18n/locales/vi.mjs +1945 -1987
- package/web-ui/modules/i18n/locales/zh-tw.mjs +1945 -2016
- package/web-ui/modules/i18n/locales/zh.mjs +1944 -2016
- package/web-ui/modules/model-test.mjs +114 -26
- package/web-ui/partials/index/layout-header.html +2 -2
- package/web-ui/partials/index/panel-plugins.html +12 -27
- package/web-ui/partials/index/plugin-file-sharing.html +1 -1
- package/web-ui/partials/index/routing-model-test.html +29 -9
- package/web-ui/res/web-ui-render.precompiled.js +1 -14783
- package/web-ui/styles/navigation-panels.css +8 -9
- package/web-ui/styles/plugins-panel.css +16 -91
- package/web-ui/styles/responsive.css +7 -7
- package/web-ui/styles/routing.css +8 -0
- package/web-ui/styles/sub-tabs.css +13 -0
|
@@ -2,18 +2,19 @@ import { api } from './api.mjs';
|
|
|
2
2
|
import { buildMarkdownPreviewHtml } from '../logic.markdown-editor.mjs';
|
|
3
3
|
|
|
4
4
|
const MAX_PROMPT_LENGTH = 8000;
|
|
5
|
+
const MODEL_TEST_SELECTIONS_KEY = 'codexmate.modelTest.selections';
|
|
5
6
|
|
|
6
7
|
export function modelTestData() {
|
|
7
8
|
return {
|
|
8
9
|
modelTestTarget: 'codex', modelTestCatalogs: { codex: [], pi: [] }, modelTestProvider: '', modelTestModel: '',
|
|
9
|
-
modelTestPrompt: '', modelTestLoading: false, modelTestRunning: false, modelTestError: '', modelTestResult: null
|
|
10
|
+
modelTestSelections: null, modelTestPrompt: '', modelTestLoading: false, modelTestRunning: false, modelTestError: '', modelTestResult: null, modelTestBatch: null, modelTestDiscovering: false
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export function createModelTestMethods({ request }) {
|
|
14
|
+
export function createModelTestMethods({ request, getStorage = () => globalThis.localStorage }) {
|
|
14
15
|
return {
|
|
15
16
|
async loadModelTestCatalog() {
|
|
16
|
-
if (this.modelTestLoading || this.modelTestRunning) return;
|
|
17
|
+
if (this.modelTestLoading || this.modelTestRunning || this.modelTestDiscovering) return;
|
|
17
18
|
this.modelTestLoading = true;
|
|
18
19
|
this.modelTestError = '';
|
|
19
20
|
try {
|
|
@@ -26,22 +27,63 @@ export function createModelTestMethods({ request }) {
|
|
|
26
27
|
},
|
|
27
28
|
modelTestProviders() { return this.modelTestCatalogs[this.modelTestTarget]; },
|
|
28
29
|
modelTestModels() { return this.modelTestProviders().find(entry => entry.name === this.modelTestProvider)?.models || []; },
|
|
29
|
-
|
|
30
|
+
canRunModelTest() {
|
|
31
|
+
return this.modelTestModel === null ? Boolean(this.modelTestProvider) : this.modelTestModels().includes(this.modelTestModel);
|
|
32
|
+
},
|
|
33
|
+
getModelTestSelections() {
|
|
34
|
+
if (this.modelTestSelections === null) {
|
|
35
|
+
let saved;
|
|
36
|
+
try { saved = JSON.parse(getStorage()?.getItem(MODEL_TEST_SELECTIONS_KEY) ?? 'null'); }
|
|
37
|
+
catch (_) { /* Storage may be blocked or corrupted; keep an in-memory selection. */ }
|
|
38
|
+
this.modelTestSelections = { codex: saved?.codex, pi: saved?.pi };
|
|
39
|
+
}
|
|
40
|
+
return this.modelTestSelections;
|
|
41
|
+
},
|
|
42
|
+
saveModelTestSelection() {
|
|
43
|
+
if (!this.modelTestProviders().some(({ name }) => name === this.modelTestProvider)) return;
|
|
44
|
+
const selections = this.getModelTestSelections();
|
|
45
|
+
const previous = selections[this.modelTestTarget];
|
|
46
|
+
selections[this.modelTestTarget] = {
|
|
47
|
+
provider: this.modelTestProvider,
|
|
48
|
+
models: { ...previous?.models, [this.modelTestProvider]: this.modelTestModel }
|
|
49
|
+
};
|
|
50
|
+
try { getStorage()?.setItem(MODEL_TEST_SELECTIONS_KEY, JSON.stringify(selections)); }
|
|
51
|
+
catch (_) { /* Retain the in-memory selection if writing fails. */ }
|
|
52
|
+
},
|
|
53
|
+
selectModelTestProvider(event) {
|
|
30
54
|
const providers = this.modelTestProviders();
|
|
55
|
+
if (!providers.length) {
|
|
56
|
+
this.modelTestProvider = '';
|
|
57
|
+
this.modelTestModel = '';
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const saved = this.getModelTestSelections()[this.modelTestTarget];
|
|
31
61
|
const current = this.modelTestTarget === 'codex' ? this.currentProvider : this.piActiveProvider;
|
|
32
|
-
|
|
33
|
-
|
|
62
|
+
const hasProvider = providers.some(({ name }) => name === this.modelTestProvider);
|
|
63
|
+
if (!hasProvider) {
|
|
64
|
+
this.modelTestProvider = providers.find(({ name }) => name === saved?.provider)?.name
|
|
65
|
+
|| providers.find(({ name }) => name === current)?.name || providers[0].name;
|
|
34
66
|
}
|
|
35
67
|
const models = this.modelTestModels();
|
|
36
|
-
const
|
|
37
|
-
|
|
68
|
+
const savedModels = saved?.models;
|
|
69
|
+
const hasSavedModel = savedModels && Object.hasOwn(savedModels, this.modelTestProvider);
|
|
70
|
+
const savedModel = hasSavedModel ? savedModels[this.modelTestProvider] : undefined;
|
|
71
|
+
if ((event || !hasProvider) && (savedModel === null || models.includes(savedModel))) {
|
|
72
|
+
this.modelTestModel = savedModel;
|
|
73
|
+
} else if (!(models.includes(this.modelTestModel) || (!event && hasProvider && this.modelTestModel === null))) {
|
|
74
|
+
const currentModel = this.modelTestTarget === 'codex' ? this.currentModels?.[this.modelTestProvider] || this.currentModel : this.piActiveModel;
|
|
75
|
+
this.modelTestModel = models.includes(currentModel) ? currentModel : models[0] || '';
|
|
76
|
+
}
|
|
77
|
+
if (event) this.saveModelTestSelection();
|
|
38
78
|
},
|
|
39
79
|
setModelTestTarget(target) {
|
|
40
|
-
if (this.modelTestRunning) return;
|
|
41
|
-
this.modelTestTarget
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
80
|
+
if (this.modelTestRunning || this.modelTestDiscovering) return;
|
|
81
|
+
if (this.modelTestTarget !== target) {
|
|
82
|
+
this.modelTestTarget = target;
|
|
83
|
+
this.modelTestProvider = '';
|
|
84
|
+
this.modelTestModel = '';
|
|
85
|
+
this.selectModelTestProvider();
|
|
86
|
+
}
|
|
45
87
|
if (!this.__webUiPreferencesApplying && typeof this.persistWebUiPreferences === 'function') {
|
|
46
88
|
this.persistWebUiPreferences({ navigation: { modelTestTarget: target } });
|
|
47
89
|
}
|
|
@@ -49,27 +91,73 @@ export function createModelTestMethods({ request }) {
|
|
|
49
91
|
modelTestDuration(result = this.modelTestResult) {
|
|
50
92
|
return this.t('modelTest.seconds', { seconds: (result.durationMs / 1000).toFixed(2) });
|
|
51
93
|
},
|
|
52
|
-
modelTestPreview() {
|
|
53
|
-
return buildMarkdownPreviewHtml(
|
|
94
|
+
modelTestPreview(result = this.modelTestResult) {
|
|
95
|
+
return buildMarkdownPreviewHtml(result?.text, globalThis.marked, globalThis.DOMPurify);
|
|
96
|
+
},
|
|
97
|
+
toggleModelTestResult(result, event) {
|
|
98
|
+
result.open = event.currentTarget.open;
|
|
99
|
+
if (result.open && result.ok && !result.rendered) result.rendered = this.modelTestPreview(result);
|
|
100
|
+
},
|
|
101
|
+
async sendModelTest(identity, prompt, catalogId) {
|
|
102
|
+
const entry = { ...identity, prompt };
|
|
103
|
+
const started = Date.now();
|
|
104
|
+
try {
|
|
105
|
+
const result = await request('model-test-run', { ...entry, ...(catalogId === undefined ? {} : { catalogId }) });
|
|
106
|
+
return { ...entry, durationMs: Date.now() - started, ...result };
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return { ...entry, ok: false, error: error.message, durationMs: Date.now() - started };
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
async runAllModelTests() {
|
|
112
|
+
if (this.modelTestRunning || this.modelTestLoading || this.modelTestDiscovering) return;
|
|
113
|
+
const prompt = this.modelTestPrompt.trim();
|
|
114
|
+
if (!prompt || this.modelTestPrompt.length > MAX_PROMPT_LENGTH || !this.modelTestProvider) {
|
|
115
|
+
this.modelTestError = this.t('modelTest.batchRequired');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const identity = { target: this.modelTestTarget, provider: this.modelTestProvider };
|
|
119
|
+
this.modelTestError = '';
|
|
120
|
+
this.modelTestDiscovering = true;
|
|
121
|
+
try {
|
|
122
|
+
const catalog = await request('model-test-discover', identity);
|
|
123
|
+
if (catalog.error) throw new Error(catalog.error.message || catalog.error);
|
|
124
|
+
const models = [...new Set(catalog.models)];
|
|
125
|
+
if (!models.length) throw new Error(this.t('modelTest.batchEmpty'));
|
|
126
|
+
const confirmed = await this.requestConfirmDialog({
|
|
127
|
+
title: this.t('modelTest.runAll'), confirmText: this.t('modelTest.runAll'),
|
|
128
|
+
message: this.t('modelTest.confirmAll', { provider: identity.provider, count: models.length })
|
|
129
|
+
});
|
|
130
|
+
if (!confirmed) return;
|
|
131
|
+
this.modelTestRunning = true;
|
|
132
|
+
this.modelTestDiscovering = false;
|
|
133
|
+
this.modelTestResult = null;
|
|
134
|
+
this.modelTestBatch = { ...identity, prompt, total: models.length, current: '', results: [] };
|
|
135
|
+
for (const model of models) {
|
|
136
|
+
this.modelTestBatch.current = model;
|
|
137
|
+
const result = await this.sendModelTest({ ...identity, model }, prompt, catalog.catalogId);
|
|
138
|
+
this.modelTestBatch.results.push(result);
|
|
139
|
+
}
|
|
140
|
+
} catch (error) { this.modelTestError = error.message; }
|
|
141
|
+
finally {
|
|
142
|
+
this.modelTestDiscovering = false;
|
|
143
|
+
this.modelTestRunning = false;
|
|
144
|
+
if (this.modelTestBatch) this.modelTestBatch.current = '';
|
|
145
|
+
}
|
|
54
146
|
},
|
|
55
147
|
async runModelTest() {
|
|
56
|
-
if (this.modelTestRunning || this.modelTestLoading) return;
|
|
148
|
+
if (this.modelTestRunning || this.modelTestLoading || this.modelTestDiscovering) return;
|
|
149
|
+
if (this.modelTestModel === null) return this.runAllModelTests();
|
|
57
150
|
const prompt = this.modelTestPrompt.trim();
|
|
58
151
|
if (!prompt || this.modelTestPrompt.length > MAX_PROMPT_LENGTH || !this.modelTestModels().includes(this.modelTestModel)) {
|
|
59
152
|
this.modelTestError = this.t('modelTest.required'); return;
|
|
60
153
|
}
|
|
61
154
|
this.modelTestRunning = true;
|
|
62
155
|
this.modelTestError = '';
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
this.modelTestResult = { ...this.modelTestResult, durationMs: Date.now() - started, ...result };
|
|
70
|
-
} catch (error) {
|
|
71
|
-
this.modelTestResult = { ...this.modelTestResult, ok: false, error: error.message, durationMs: Date.now() - started };
|
|
72
|
-
} finally { this.modelTestRunning = false; }
|
|
156
|
+
const identity = { target: this.modelTestTarget, provider: this.modelTestProvider, model: this.modelTestModel };
|
|
157
|
+
this.modelTestBatch = null;
|
|
158
|
+
this.modelTestResult = { ...identity, prompt };
|
|
159
|
+
try { this.modelTestResult = await this.sendModelTest(identity, prompt); }
|
|
160
|
+
finally { this.modelTestRunning = false; }
|
|
73
161
|
}
|
|
74
162
|
};
|
|
75
163
|
}
|
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
@pointerdown="onPluginsTabPointerDown('prompt-templates', $event)"
|
|
347
347
|
@click="onPluginsTabClick('prompt-templates', $event)">
|
|
348
348
|
<svg class="side-item-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12 3 9 9-9 9-9-9zm0 5 4 4-4 4-4-4z"/></svg>
|
|
349
|
-
<div class="side-item-title" :title="t('
|
|
349
|
+
<div class="side-item-title" :title="t('plugins.catalog.promptTemplates.title')">{{ t('plugins.catalog.promptTemplates.title') }}</div>
|
|
350
350
|
<div class="side-item-meta">
|
|
351
351
|
<span>{{ t('side.plugins.templatesCount', { count: promptTemplatesList.length }) }}</span>
|
|
352
352
|
</div>
|
|
@@ -461,7 +461,7 @@
|
|
|
461
461
|
<div class="main-panel-topbar">
|
|
462
462
|
<div class="panel-header panel-header-refined" v-if="!sessionStandalone">
|
|
463
463
|
<div class="panel-header-copy">
|
|
464
|
-
<div v-if="mainTabKicker" class="panel-kicker">{{ mainTabKicker }}</div>
|
|
464
|
+
<div v-if="mainTabKicker && mainTab !== 'plugins'" class="panel-kicker">{{ mainTabKicker }}</div>
|
|
465
465
|
<h1 class="main-title">{{ mainTabTitle }}</h1>
|
|
466
466
|
</div>
|
|
467
467
|
</div>
|
|
@@ -4,15 +4,9 @@
|
|
|
4
4
|
id="panel-plugins"
|
|
5
5
|
role="tabpanel"
|
|
6
6
|
aria-labelledby="tab-plugins">
|
|
7
|
-
<div
|
|
8
|
-
<
|
|
9
|
-
<div class="
|
|
10
|
-
<div>
|
|
11
|
-
<span class="selector-title">{{ t('plugins.sidebar.title') }}</span>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<div class="plugins-list" role="list">
|
|
7
|
+
<div class="plugins-layout">
|
|
8
|
+
<nav v-if="pluginsSidebarVisible" class="plugins-sidebar" :aria-label="t('plugins.sidebar.ariaList')">
|
|
9
|
+
<div class="plugins-list">
|
|
16
10
|
<button
|
|
17
11
|
v-for="plugin in pluginsCatalog"
|
|
18
12
|
:key="'plugin-' + plugin.id"
|
|
@@ -22,14 +16,10 @@
|
|
|
22
16
|
:aria-current="pluginsActiveId === plugin.id ? 'page' : null"
|
|
23
17
|
:disabled="loading || !!initError || pluginsLoading"
|
|
24
18
|
@click="selectPlugin(plugin.id)">
|
|
25
|
-
<
|
|
26
|
-
<div class="plugins-item-title">{{ plugin.title }}</div>
|
|
27
|
-
<div class="plugins-item-meta">{{ plugin.description }}</div>
|
|
28
|
-
</div>
|
|
29
|
-
<span :class="['pill', plugin.tone]">{{ plugin.statusLabel }}</span>
|
|
19
|
+
<span class="plugins-item-title">{{ plugin.title }}</span>
|
|
30
20
|
</button>
|
|
31
21
|
</div>
|
|
32
|
-
</
|
|
22
|
+
</nav>
|
|
33
23
|
|
|
34
24
|
<section class="plugins-main" :aria-label="t('plugins.main.ariaWorkspace')">
|
|
35
25
|
<div v-if="pluginsLoading" class="skills-empty-state">{{ t('common.loading') }}</div>
|
|
@@ -39,9 +29,7 @@
|
|
|
39
29
|
</div>
|
|
40
30
|
<div v-else-if="pluginsActiveId === 'prompt-templates'" class="plugins-panel">
|
|
41
31
|
<div class="plugins-panel-head">
|
|
42
|
-
<
|
|
43
|
-
<h2 class="plugins-panel-title">{{ t('plugins.promptTemplates.title') }}</h2>
|
|
44
|
-
</div>
|
|
32
|
+
<h2 class="sr-only">{{ t('plugins.promptTemplates.title') }}</h2>
|
|
45
33
|
<div v-if="!pluginsSidebarVisible" class="settings-tab-actions">
|
|
46
34
|
<button type="button" class="btn-tool btn-tool-compact" @click="loadPluginsOverview({ forceRefresh: true, silent: false })" :disabled="loading || !!initError || pluginsLoading">
|
|
47
35
|
{{ pluginsLoading ? t('plugins.refreshing') : t('plugins.refresh') }}
|
|
@@ -55,13 +43,13 @@
|
|
|
55
43
|
role="tab"
|
|
56
44
|
:aria-selected="promptTemplatesMode === 'compose'"
|
|
57
45
|
:class="['mode-pill', { active: promptTemplatesMode === 'compose' }]"
|
|
58
|
-
@click="promptTemplatesMode = 'compose'; if(typeof saveNavState==='function')saveNavState()"
|
|
46
|
+
@click="promptTemplatesMode = 'compose'; if(typeof saveNavState==='function')saveNavState()">{{ t('plugins.promptTemplates.mode.compose') }}</button>
|
|
59
47
|
<button
|
|
60
48
|
type="button"
|
|
61
49
|
role="tab"
|
|
62
50
|
:aria-selected="promptTemplatesMode !== 'compose'"
|
|
63
51
|
:class="['mode-pill', { active: promptTemplatesMode !== 'compose' }]"
|
|
64
|
-
@click="promptTemplatesMode = 'manage'; if(typeof saveNavState==='function')saveNavState()"
|
|
52
|
+
@click="promptTemplatesMode = 'manage'; if(typeof saveNavState==='function')saveNavState()">{{ t('plugins.promptTemplates.mode.manage') }}</button>
|
|
65
53
|
</div>
|
|
66
54
|
|
|
67
55
|
<div v-if="promptTemplatesMode === 'compose'" class="prompt-compose">
|
|
@@ -159,7 +147,7 @@
|
|
|
159
147
|
<span class="mono">{{ tpl.updatedLabel }}</span>
|
|
160
148
|
</div>
|
|
161
149
|
</div>
|
|
162
|
-
<span
|
|
150
|
+
<span v-if="tpl.isBuiltin" class="prompt-template-origin">{{ t('plugins.promptTemplates.manage.builtin') }}</span>
|
|
163
151
|
</button>
|
|
164
152
|
</div>
|
|
165
153
|
</div>
|
|
@@ -258,13 +246,10 @@
|
|
|
258
246
|
</div>
|
|
259
247
|
</div>
|
|
260
248
|
<div v-else-if="pluginsActiveId === 'text-tools'" class="plugins-panel plugins-panel-text-tools">
|
|
261
|
-
<div class="plugins-panel-head">
|
|
262
|
-
<
|
|
263
|
-
<h2 class="plugins-panel-title">{{ t('plugins.textTools.title') }}</h2>
|
|
264
|
-
</div>
|
|
249
|
+
<div v-if="textToolsList.length === 1" class="plugins-panel-head">
|
|
250
|
+
<h2 class="plugins-panel-title">{{ textToolsList[0].label }}</h2>
|
|
265
251
|
</div>
|
|
266
|
-
|
|
267
|
-
<div class="prompt-templates-modebar" role="tablist" :aria-label="t('plugins.textTools.tools.aria')">
|
|
252
|
+
<div v-else-if="textToolsList.length > 1" class="prompt-templates-modebar" role="tablist" :aria-label="t('plugins.textTools.title')">
|
|
268
253
|
<button
|
|
269
254
|
v-for="tool in textToolsList"
|
|
270
255
|
:key="'text-tool-' + tool.id"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div v-else-if="pluginsActiveId === 'file-sharing'" class="plugins-panel" id="plugin-file-sharing">
|
|
2
2
|
<div class="plugins-panel-head">
|
|
3
|
-
<h2 class="
|
|
3
|
+
<h2 class="sr-only">{{ t('plugins.fileSharing.title') }}</h2>
|
|
4
4
|
<div class="file-sharing-actions">
|
|
5
5
|
<button type="button" class="btn-mini" :disabled="fileSharingBusy" @click="$refs.fileSharingFiles.click()">{{ t('plugins.fileSharing.chooseFiles') }}</button>
|
|
6
6
|
<button type="button" class="btn-mini" :disabled="fileSharingBusy" @click="$refs.fileSharingFolder.click()">{{ t('plugins.fileSharing.chooseFolder') }}</button>
|
|
@@ -1,40 +1,60 @@
|
|
|
1
1
|
<div class="routing-test">
|
|
2
|
-
<form novalidate @submit.prevent="runModelTest" :aria-busy="modelTestRunning">
|
|
2
|
+
<form novalidate @submit.prevent="runModelTest" :aria-busy="modelTestRunning || modelTestDiscovering">
|
|
3
3
|
<fieldset :disabled="modelTestRunning || modelTestLoading">
|
|
4
4
|
<legend class="routing-test-legend">{{ t('modelTest.selection') }}</legend>
|
|
5
5
|
<div class="routing-test-heading">
|
|
6
6
|
<div class="segmented-control" role="group" :aria-label="t('modelTest.source')">
|
|
7
|
-
<button v-for="target in ['codex', 'pi']" :key="target" type="button" :class="['segment', { active: modelTestTarget === target }]" :aria-pressed="modelTestTarget === target" @click="setModelTestTarget(target)">{{ target === 'codex' ? 'Codex' : 'Pi' }}</button>
|
|
7
|
+
<button v-for="target in ['codex', 'pi']" :key="target" type="button" :class="['segment', { active: modelTestTarget === target }]" :aria-pressed="modelTestTarget === target" :disabled="modelTestDiscovering" @click="setModelTestTarget(target)">{{ target === 'codex' ? 'Codex' : 'Pi' }}</button>
|
|
8
8
|
</div>
|
|
9
|
-
<button type="button" class="btn-tool routing-icon-btn" :disabled="modelTestLoading || modelTestRunning" :aria-label="t('routing.refresh')" :title="t('routing.refresh')" @click="loadModelTestCatalog">
|
|
9
|
+
<button type="button" class="btn-tool routing-icon-btn" :disabled="modelTestLoading || modelTestRunning || modelTestDiscovering" :aria-label="t('routing.refresh')" :title="t('routing.refresh')" @click="loadModelTestCatalog">
|
|
10
10
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" focusable="false"><path d="M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-1l2 3M4 15l2 3a7 7 0 0 0 12-1"/></svg>
|
|
11
11
|
</button>
|
|
12
12
|
</div>
|
|
13
13
|
<div class="routing-form-head">
|
|
14
14
|
<label class="routing-field"><span class="form-label">{{ t('routing.provider') }}</span>
|
|
15
|
-
<select class="model-select" v-model="modelTestProvider" @change="selectModelTestProvider">
|
|
15
|
+
<select class="model-select" :disabled="modelTestDiscovering" v-model="modelTestProvider" @change="selectModelTestProvider">
|
|
16
16
|
<option value="" disabled>{{ t('routing.selectProvider') }}</option>
|
|
17
17
|
<option v-for="provider in modelTestProviders()" :key="provider.name" :value="provider.name">{{ provider.name }}</option>
|
|
18
18
|
</select>
|
|
19
19
|
</label>
|
|
20
20
|
<label class="routing-field"><span class="form-label">{{ t('routing.model') }}</span>
|
|
21
|
-
<select class="model-select" v-model="modelTestModel">
|
|
21
|
+
<select class="model-select" :disabled="modelTestDiscovering" v-model="modelTestModel" @change="saveModelTestSelection">
|
|
22
22
|
<option value="" disabled>{{ t('modelTest.selectModel') }}</option>
|
|
23
|
+
<option v-if="modelTestProvider" :value="null">{{ t('modelTest.allModels') }}</option>
|
|
23
24
|
<option v-for="model in modelTestModels()" :key="model" :value="model">{{ model }}</option>
|
|
24
25
|
</select>
|
|
25
26
|
</label>
|
|
26
27
|
</div>
|
|
27
|
-
<p v-if="!modelTestLoading && !modelTestModels().length" class="routing-hint">{{ t('modelTest.empty') }} <button type="button" class="btn-tool" @click="switchConfigMode(modelTestTarget)">{{ t('routing.openConfig') }}</button></p>
|
|
28
|
+
<p v-if="!modelTestLoading && !modelTestModels().length" class="routing-hint">{{ t('modelTest.empty') }} <button type="button" class="btn-tool" :disabled="modelTestDiscovering" @click="switchConfigMode(modelTestTarget)">{{ t('routing.openConfig') }}</button></p>
|
|
28
29
|
<label class="routing-field routing-test-prompt"><span class="form-label">{{ t('modelTest.prompt') }}</span>
|
|
29
|
-
<textarea class="form-input" v-model="modelTestPrompt" rows="4" maxlength="8000"></textarea>
|
|
30
|
+
<textarea class="form-input" :disabled="modelTestDiscovering" v-model="modelTestPrompt" rows="4" maxlength="8000"></textarea>
|
|
30
31
|
</label>
|
|
31
32
|
<div class="routing-test-actions">
|
|
32
|
-
<button type="submit" class="btn-tool btn-primary" :disabled="!modelTestPrompt.trim() || !
|
|
33
|
+
<button type="submit" class="btn-tool btn-primary" :disabled="modelTestDiscovering || !modelTestPrompt.trim() || !canRunModelTest()">{{ t(modelTestRunning ? 'modelTest.running' : 'modelTest.run') }}</button>
|
|
33
34
|
</div>
|
|
34
35
|
</fieldset>
|
|
35
36
|
</form>
|
|
36
37
|
<p v-if="modelTestError" class="routing-error" role="alert">{{ modelTestError }}</p>
|
|
37
|
-
<
|
|
38
|
+
<p v-if="modelTestDiscovering" class="routing-hint" role="status">{{ t('modelTest.discovering') }}</p>
|
|
39
|
+
<section v-if="modelTestBatch" class="routing-test-response">
|
|
40
|
+
<strong class="routing-test-result-head">{{ modelTestBatch.provider }}</strong>
|
|
41
|
+
<p class="routing-hint" role="status">{{ t('modelTest.progressAll', { done: modelTestBatch.results.length, total: modelTestBatch.total }) }}<template v-if="modelTestBatch.current"> · {{ modelTestBatch.current }}</template></p>
|
|
42
|
+
<p class="routing-test-question">{{ modelTestBatch.prompt }}</p>
|
|
43
|
+
<details v-for="result in modelTestBatch.results" :key="result.model" class="routing-batch-result" :open="!!result.open" @toggle="toggleModelTestResult(result, $event)">
|
|
44
|
+
<summary>
|
|
45
|
+
<strong>{{ result.model }}</strong>
|
|
46
|
+
<span v-if="result.responseModel && result.responseModel !== result.model"> → {{ result.responseModel }}</span>
|
|
47
|
+
<span class="routing-hint"> · {{ t(result.ok ? 'modelTest.completed' : 'modelTest.failed') }} · {{ modelTestDuration(result) }}</span>
|
|
48
|
+
</summary>
|
|
49
|
+
<p v-if="result.open && !result.ok" class="routing-error">{{ result.error }}</p>
|
|
50
|
+
<template v-else-if="result.open && result.rendered">
|
|
51
|
+
<div v-if="result.rendered.html" class="routing-test-answer" v-html="result.rendered.html"></div>
|
|
52
|
+
<p v-else class="routing-test-answer routing-test-plain">{{ result.text }}</p>
|
|
53
|
+
<p v-if="result.incomplete" class="routing-hint">{{ t('modelTest.incomplete') }}</p>
|
|
54
|
+
</template>
|
|
55
|
+
</details>
|
|
56
|
+
</section>
|
|
57
|
+
<div v-else class="routing-test-response" aria-live="polite" :aria-busy="modelTestRunning">
|
|
38
58
|
<p v-if="modelTestLoading" class="routing-hint" role="status">{{ t('modelTest.loading') }}</p>
|
|
39
59
|
<template v-else-if="modelTestResult">
|
|
40
60
|
<div class="routing-test-result-head">
|