support refinement

This commit is contained in:
Julian Freeman
2026-02-25 13:22:39 -04:00
parent f20a9bb851
commit dd06a3159b
2 changed files with 177 additions and 14 deletions

View File

@@ -77,16 +77,34 @@ Only penalize and provide improvements if the translation meets one of these cri
- **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 "".
4. **Suggestions**: Provide a list of specific, actionable suggestions. For each, assign an "importance" from 0 to 100 (0 = unnecessary/optional, 100 = critical error).
# Output Format
Respond ONLY in JSON format. The "analysis" and "improvements" MUST be in Simplified Chinese:
Respond ONLY in JSON format. The "analysis" and "text" within "suggestions" MUST be in Simplified Chinese:
{
"score": number,
"analysis": "string",
"improvements": "string"
"suggestions": [
{ "id": 1, "text": "suggestion text", "importance": number }
]
}`;
export const DEFAULT_REFINEMENT_TEMPLATE = `You are a senior translation editor. Your task is to refine the [Current Translation] based on specific [User Feedback], while strictly maintaining the original meaning of the [Source Text] and adhering to the established context.
[Context Info]
- Source Language: {SOURCE_LANG}
- Target Language: {TARGET_LANG}
- Speaker Identity: {SPEAKER_IDENTITY}
- Intended Tone/Register: {TONE_REGISTER}
- Context: {CONTEXT}
[Instructions]
1. Carefully review the [User Feedback] and apply the requested improvements to the [Current Translation].
2. Ensure that the refined translation remains semantically identical to the [Source Text].
3. Maintain the [Speaker Identity] and [Intended Tone/Register] as specified.
4. If a piece of feedback contradicts the [Source Text], prioritize accuracy and provide a balanced refinement.
5. Produce ONLY the refined {TARGET_LANG} translation, without any additional explanations, notes, or commentary.`;
export interface ApiProfile {
id: string;
name: string;
@@ -107,6 +125,7 @@ export const useSettingsStore = defineStore('settings', () => {
const enableEvaluation = useLocalStorage('enable-evaluation', true);
const evaluationPromptTemplate = useLocalStorage('evaluation-prompt-template', DEFAULT_EVALUATION_TEMPLATE);
const evaluationProfileId = useLocalStorage<string | null>('evaluation-profile-id', null);
const refinementPromptTemplate = useLocalStorage('refinement-prompt-template', DEFAULT_REFINEMENT_TEMPLATE);
// 存储整个对象以保持一致性
const sourceLang = useLocalStorage<Language>('source-lang-v2', LANGUAGES[0]);
@@ -140,6 +159,7 @@ export const useSettingsStore = defineStore('settings', () => {
enableEvaluation,
evaluationPromptTemplate,
evaluationProfileId,
refinementPromptTemplate,
sourceLang,
targetLang,
speakerIdentity,