add check and refine

This commit is contained in:
Julian Freeman
2026-04-03 19:56:47 -04:00
parent 8acef5e4e7
commit 5b0e6321cc
2 changed files with 306 additions and 11 deletions

View File

@@ -140,6 +140,9 @@ export interface ChatMessage {
original: string;
translated: string;
timestamp: string;
evaluation?: string; // AI 审计结果 (JSON 字符串)
isEvaluating?: boolean; // 审计状态
isRefining?: boolean; // 润色状态
}
export interface ChatSession {
@@ -171,6 +174,66 @@ Translate the incoming text from {FROM_LANG} to {TO_LANG}.
4. Strictly avoid over-translation: Do not add extra information not present in the source text.
5. Output ONLY the translated text, no explanations.`;
export const CONVERSATION_EVALUATION_PROMPT_TEMPLATE = `# Role
You are an expert Conversation Auditor. Your task is to evaluate if the [Current Translation] accurately reflects the [Source Text] within the specific flow of the [Conversation History].
# Context Info
- Me: {ME_NAME} ({ME_GENDER}, {ME_LANG})
- Partner: {PART_NAME} ({PART_GENDER}, {PART_LANG})
- Target Tone: {TARGET_TONE}
[Conversation History]
{HISTORY_BLOCK}
# Audit Priorities
1. **Contextual Accuracy**: Do pronouns (it, that, etc.) correctly point to objects/topics mentioned in the [Conversation History]?
2. **Relational Tone**: Does the translation match the [Target Tone]? (e.g., if set to 'Polite', is it too casual?)
3. **Consistency**: Are names, terms, or previously established facts handled consistently?
4. **Naturalness**: Is it concise and fit for an IM (Instant Messaging) environment?
# Instructions
1. Analyze the [Source Text] and [Current Translation] against the history.
2. Scoring: 0-100.
3. Suggestions: Provide actionable improvements.
4. **Severity Level**: For each suggestion, assign an "importance" score (0-100).
- **80-100 (Critical)**: Misunderstanding meaning, wrong pronoun reference, or offensive tone.
- **40-79 (Moderate)**: Unnatural phrasing, minor tone mismatch.
- **0-39 (Minor)**: Polishing, stylistic preferences.
# Output Format
Respond ONLY in JSON. "analysis" and "text" MUST be in Simplified Chinese:
{
"score": number,
"analysis": "string",
"suggestions": [
{ "id": 1, "text": "suggestion text", "importance": number }
]
}`;
export const CONVERSATION_REFINEMENT_PROMPT_TEMPLATE = `You are a professional conversation editor. Refine the [Current Translation] based on the [Audit Suggestions] and [Conversation History].
# Context Info
- Role A (Me): {ME_NAME}, Gender: {ME_GENDER}, Language: {ME_LANG}.
- Role B (Partner): {PART_NAME}, Gender: {PART_GENDER}, Language: {PART_LANG}.
- Target Tone: {TARGET_TONE}
[Conversation History]
{HISTORY_BLOCK}
[Current Translation]
{CURRENT_TRANSLATION}
[Audit Suggestions]
{SUGGESTIONS}
# Task
Produce a new, refined version of the translation that addresses the suggestions while remaining naturally integrated into the conversation flow.
# Constraints
1. Maintain semantic identity with the [Source Text].
2. Strictly follow the {TARGET_TONE}.
3. Output ONLY the refined translation text. No explanations.`;
export const useSettingsStore = defineStore('settings', () => {
const isDark = useLocalStorage('is-dark', false);
const apiBaseUrl = useLocalStorage('api-base-url', 'http://localhost:11434/v1');