improve ui and temp
This commit is contained in:
14
src/App.vue
14
src/App.vue
@@ -324,11 +324,6 @@ const translate = async () => {
|
|||||||
targetText.value = response;
|
targetText.value = response;
|
||||||
}
|
}
|
||||||
settings.addLog('response', 'Translation completed');
|
settings.addLog('response', 'Translation completed');
|
||||||
|
|
||||||
// Trigger evaluation if enabled
|
|
||||||
if (settings.enableEvaluation) {
|
|
||||||
await evaluateTranslation();
|
|
||||||
}
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
const errorMsg = String(err);
|
const errorMsg = String(err);
|
||||||
settings.addLog('error', errorMsg);
|
settings.addLog('error', errorMsg);
|
||||||
@@ -336,6 +331,11 @@ const translate = async () => {
|
|||||||
} finally {
|
} finally {
|
||||||
isTranslating.value = false;
|
isTranslating.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trigger evaluation if enabled
|
||||||
|
if (settings.enableEvaluation) {
|
||||||
|
await evaluateTranslation();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ const translate = async () => {
|
|||||||
|
|
||||||
<div class="p-4 border-t dark:border-slate-800 bg-slate-50/30 dark:bg-transparent flex justify-end shrink-0"> <button
|
<div class="p-4 border-t dark:border-slate-800 bg-slate-50/30 dark:bg-transparent flex justify-end shrink-0"> <button
|
||||||
@click="translate"
|
@click="translate"
|
||||||
:disabled="isTranslating || !sourceText.trim()"
|
:disabled="isTranslating || isEvaluating || !sourceText.trim()"
|
||||||
class="bg-blue-600 hover:bg-blue-700 disabled:bg-blue-300 dark:disabled:bg-blue-900/40 text-white px-6 py-2.5 rounded-lg font-medium transition-all flex items-center gap-2 shadow-sm"
|
class="bg-blue-600 hover:bg-blue-700 disabled:bg-blue-300 dark:disabled:bg-blue-900/40 text-white px-6 py-2.5 rounded-lg font-medium transition-all flex items-center gap-2 shadow-sm"
|
||||||
>
|
>
|
||||||
<Loader2 v-if="isTranslating" class="w-4 h-4 animate-spin" />
|
<Loader2 v-if="isTranslating" class="w-4 h-4 animate-spin" />
|
||||||
@@ -658,7 +658,7 @@ const translate = async () => {
|
|||||||
<button
|
<button
|
||||||
@click="evaluateTranslation"
|
@click="evaluateTranslation"
|
||||||
:disabled="isEvaluating || isTranslating || !targetText.trim()"
|
:disabled="isEvaluating || isTranslating || !targetText.trim()"
|
||||||
class="bg-slate-200 hover:bg-slate-300 dark:bg-slate-800 dark:hover:bg-slate-700 disabled:opacity-50 text-slate-700 dark:text-slate-200 px-6 py-2.5 rounded-lg font-medium transition-all flex items-center gap-2 shadow-sm border border-slate-300/50 dark:border-slate-700/50"
|
class="bg-slate-200 enabled:hover:bg-slate-300 dark:bg-slate-800 dark:enabled:hover:bg-slate-700 disabled:opacity-50 text-slate-700 dark:text-slate-200 px-6 py-2.5 rounded-lg font-medium transition-all flex items-center gap-2 shadow-sm border border-slate-300/50 dark:border-slate-700/50"
|
||||||
>
|
>
|
||||||
<Loader2 v-if="isEvaluating" class="w-4 h-4 animate-spin" />
|
<Loader2 v-if="isEvaluating" class="w-4 h-4 animate-spin" />
|
||||||
<Check v-else class="w-4 h-4" />
|
<Check v-else class="w-4 h-4" />
|
||||||
|
|||||||
@@ -51,31 +51,40 @@ export const DEFAULT_TEMPLATE = `You are a professional {SOURCE_LANG} ({SOURCE_C
|
|||||||
3. Produce ONLY the {TARGET_LANG} translation, without any additional explanations, notes, or commentary.
|
3. Produce ONLY the {TARGET_LANG} translation, without any additional explanations, notes, or commentary.
|
||||||
4. If [Context] is provided, use it strictly to disambiguate polysemous words. DO NOT add any factual information or descriptive details from the [Context] that are not present in the [Text to Translate].`;
|
4. If [Context] is provided, use it strictly to disambiguate polysemous words. DO NOT add any factual information or descriptive details from the [Context] that are not present in the [Text to Translate].`;
|
||||||
|
|
||||||
export const DEFAULT_EVALUATION_TEMPLATE = `You are an expert translation auditor proficient in {SOURCE_LANG} and {TARGET_LANG}.
|
export const DEFAULT_EVALUATION_TEMPLATE = `# Role
|
||||||
Your task is to critically evaluate the accuracy and quality of a translation.
|
You are an **Objective Translation Auditor**. Your task is to evaluate translation quality based on accuracy, grammar, and fundamental readability. Avoid pedantic nitpicking over synonyms, but do point out issues that hinder professional quality.
|
||||||
|
|
||||||
[Context Info]
|
# Context Info
|
||||||
- Source Language: {SOURCE_LANG}
|
- **Source Language**: {SOURCE_LANG}
|
||||||
- Target Language: {TARGET_LANG}
|
- **Target Language**: {TARGET_LANG}
|
||||||
- Speaker Identity: {SPEAKER_IDENTITY}
|
- **Speaker Identity**: {SPEAKER_IDENTITY}
|
||||||
- Intended Tone/Register: {TONE_REGISTER}
|
- **Intended Tone/Register**: {TONE_REGISTER}
|
||||||
- Context: {CONTEXT}
|
- **Context**: {CONTEXT}
|
||||||
|
|
||||||
[Input]
|
# Input
|
||||||
- Source Text: {SOURCE_TEXT}
|
- **Source Text**: {SOURCE_TEXT}
|
||||||
- Translated Text: {TRANSLATED_TEXT}
|
- **Translated Text**: {TRANSLATED_TEXT}
|
||||||
|
|
||||||
[Instructions]
|
# Audit Criteria
|
||||||
1. Compare the [Source Text] and [Translated Text] meticulously.
|
Only penalize and provide improvements if the translation meets one of these criteria:
|
||||||
2. Check if the translation respects the [Context Info].
|
1. **Semantic Error**: Objective misalignment with the source meaning or complete hallucinations.
|
||||||
3. Assign an "Accuracy Score" from 0 to 100.
|
2. **Grammatical Error**: Clear violations of target language grammar or syntax rules.
|
||||||
- Give 0 if there are fatal semantic errors, complete hallucinations, or if the meaning is reversed.
|
3. **Tone Failure**: A tone that is the opposite or significantly different from the [Intended Tone/Register].
|
||||||
- Deduct points for minor inaccuracies, unnatural phrasing, or tone mismatches.
|
4. **Poor Readability**: The phrasing is so stiff, unnatural, or convoluted that it hinders smooth comprehension (e.g., obvious "translationese" or broken logic).
|
||||||
4. Provide a concise "Analysis" of why you gave that score.
|
|
||||||
5. (Optional) Provide "Improvements" for a more accurate/natural translation.
|
|
||||||
|
|
||||||
[Output Format]
|
**Note**: Do NOT penalize if the translation is simply "not the most elegant" or if there's a subjective preference for a different synonym. If it's natural enough for a native speaker to understand without effort, it's acceptable.
|
||||||
You MUST respond in JSON format with the following keys. The values for "analysis" and "improvements" MUST be written in Simplified Chinese (简体中文), except when quoting the source or target text:
|
|
||||||
|
# Instructions
|
||||||
|
1. **Evaluation**: Compare the [Source Text] and [Translated Text] based on the [Audit Criteria].
|
||||||
|
2. **Scoring Strategy**:
|
||||||
|
- **90-100**: Accurate, grammatically sound, and flows naturally.
|
||||||
|
- **75-89**: Accurate meaning, but suffers from "stiff" phrasing or minor flow issues that need adjustment.
|
||||||
|
- **Below 75**: Contains semantic errors, severe grammar issues, or tone mismatches.
|
||||||
|
3. **Analysis**: Provide a concise explanation in Simplified Chinese. Focus on *why* the error matters (e.g., "meaning is reversed" or "too awkward to read").
|
||||||
|
4. **Improvements**: Provide suggestions in Simplified Chinese. If the score is 95+, this field can be an empty string "".
|
||||||
|
|
||||||
|
# Output Format
|
||||||
|
Respond ONLY in JSON format. The "analysis" and "improvements" MUST be in Simplified Chinese:
|
||||||
{
|
{
|
||||||
"score": number,
|
"score": number,
|
||||||
"analysis": "string",
|
"analysis": "string",
|
||||||
|
|||||||
Reference in New Issue
Block a user