From f21366e55f45ef0656dcdf2f566c64435146c8b8 Mon Sep 17 00:00:00 2001
From: Julian Freeman
Date: Wed, 25 Feb 2026 00:00:07 -0400
Subject: [PATCH] improve evaluation
---
src/App.vue | 108 ++++++++++++++++++++++++++++++++++++-----
src/stores/settings.ts | 4 +-
2 files changed, 100 insertions(+), 12 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 3b89309..35bf66b 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -90,20 +90,23 @@ const sourceDropdownOpen = ref(false);
const targetDropdownOpen = ref(false);
const speakerDropdownOpen = ref(false);
const toneDropdownOpen = ref(false);
+const evaluationProfileDropdownOpen = ref(false);
const closeAllDropdowns = () => {
sourceDropdownOpen.value = false;
targetDropdownOpen.value = false;
speakerDropdownOpen.value = false;
toneDropdownOpen.value = false;
+ evaluationProfileDropdownOpen.value = false;
};
-const toggleDropdown = (type: 'source' | 'target' | 'speaker' | 'tone') => {
+const toggleDropdown = (type: 'source' | 'target' | 'speaker' | 'tone' | 'evaluationProfile') => {
const states = {
source: sourceDropdownOpen,
target: targetDropdownOpen,
speaker: speakerDropdownOpen,
- tone: toneDropdownOpen
+ tone: toneDropdownOpen,
+ evaluationProfile: evaluationProfileDropdownOpen
};
const targetState = states[type];
@@ -186,6 +189,12 @@ const currentToneLabel = computed(() => {
return TONE_REGISTER_OPTIONS.find(opt => opt.value === settings.toneRegister)?.label || '正式专业';
});
+const currentEvaluationProfileLabel = computed(() => {
+ if (!settings.evaluationProfileId) return '使用主翻译配置(默认)';
+ const profile = settings.profiles.find(p => p.id === settings.evaluationProfileId);
+ return profile ? `${profile.name} — ${profile.modelName}` : '使用主翻译配置(默认)';
+});
+
const swapLanguages = () => {
const temp = { ...settings.sourceLang };
settings.sourceLang = { ...settings.targetLang };
@@ -216,6 +225,20 @@ const evaluateTranslation = async () => {
isEvaluating.value = true;
evaluationResult.value = null;
+ // Determine which API config to use for evaluation
+ let apiBaseUrl = settings.apiBaseUrl;
+ let apiKey = settings.apiKey;
+ let modelName = settings.modelName;
+
+ if (settings.evaluationProfileId) {
+ const profile = settings.profiles.find(p => p.id === settings.evaluationProfileId);
+ if (profile) {
+ apiBaseUrl = profile.apiBaseUrl;
+ apiKey = profile.apiKey;
+ modelName = profile.modelName;
+ }
+ }
+
const evaluationPrompt = settings.evaluationPromptTemplate
.replace(/{SOURCE_LANG}/g, sourceLang.value.englishName)
.replace(/{TARGET_LANG}/g, targetLang.value.englishName)
@@ -226,7 +249,7 @@ const evaluateTranslation = async () => {
.replace(/{TRANSLATED_TEXT}/g, targetText.value);
const requestBody = {
- model: settings.modelName,
+ model: modelName,
messages: [
{ role: "system", content: "You are a professional translation auditor. You must respond in valid JSON format." },
{ role: "user", content: evaluationPrompt }
@@ -238,8 +261,8 @@ const evaluateTranslation = async () => {
try {
const response = await invoke('translate', {
- apiAddress: settings.apiBaseUrl,
- apiKey: settings.apiKey,
+ apiAddress: apiBaseUrl,
+ apiKey: apiKey,
payload: requestBody
});
@@ -616,10 +639,10 @@ const translate = async () => {
-
+
-
建议优化
+
建议优化
{{ evaluationResult.improvements }}
@@ -773,6 +796,69 @@ const translate = async () => {
)">
+
+
+
+
+ 审计模型
+
+
+
+
+
+ {{ currentEvaluationProfileLabel }}
+
+
+
+
+
+
+
+
+
+ 提示:建议为审计选择更强大的模型以获得更精准的反馈
+
+
@@ -789,6 +875,9 @@ const translate = async () => {
rows="6"
class="w-full px-4 py-3 border dark:border-slate-700 rounded-lg bg-transparent focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-all font-mono text-xs leading-relaxed text-slate-900 dark:text-slate-100"
>
+
+ {{ tag }}
+
@@ -802,13 +891,10 @@ const translate = async () => {
class="w-full px-4 py-3 border dark:border-slate-700 rounded-lg bg-transparent focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-all font-mono text-xs leading-relaxed text-slate-900 dark:text-slate-100"
>
- {{ tag }}
+ {{ tag }}
-
- {{ tag }}
-
diff --git a/src/stores/settings.ts b/src/stores/settings.ts
index 675ea34..c1587ff 100644
--- a/src/stores/settings.ts
+++ b/src/stores/settings.ts
@@ -67,7 +67,7 @@ Your task is to critically evaluate the accuracy and quality of a translation.
[Instructions]
1. Compare the [Source Text] and [Translated Text] meticulously.
-2. Check if the translation respects the [Context Info] and [Speaker Identity].
+2. Check if the translation respects the [Context Info].
3. Assign an "Accuracy Score" from 0 to 100.
- Give 0 if there are fatal semantic errors, complete hallucinations, or if the meaning is reversed.
- Deduct points for minor inaccuracies, unnatural phrasing, or tone mismatches.
@@ -101,6 +101,7 @@ export const useSettingsStore = defineStore('settings', () => {
const enableEvaluation = useLocalStorage('enable-evaluation', true);
const evaluationPromptTemplate = useLocalStorage('evaluation-prompt-template', DEFAULT_EVALUATION_TEMPLATE);
+ const evaluationProfileId = useLocalStorage('evaluation-profile-id', null);
// 存储整个对象以保持一致性
const sourceLang = useLocalStorage('source-lang-v2', LANGUAGES[0]);
@@ -133,6 +134,7 @@ export const useSettingsStore = defineStore('settings', () => {
systemPromptTemplate,
enableEvaluation,
evaluationPromptTemplate,
+ evaluationProfileId,
sourceLang,
targetLang,
speakerIdentity,