fix bug
This commit is contained in:
@@ -175,7 +175,7 @@ const translateMessage = async (sender: 'me' | 'partner', retranslateId?: string
|
||||
|
||||
const historyBlock = recentMessages.map(m => {
|
||||
const senderName = m.sender === 'me' ? activeSession.value!.me.name : activeSession.value!.partner.name;
|
||||
return `${senderName}: [Original] ${m.original} -> [Translated] ${m.translated}`;
|
||||
return `${senderName}: "${m.original}"`;
|
||||
}).join('\n');
|
||||
|
||||
// 3. Prepare Prompt
|
||||
@@ -219,7 +219,7 @@ const translateMessage = async (sender: 'me' | 'partner', retranslateId?: string
|
||||
const translatedText = fullResponseJson.choices?.[0]?.message?.content || response;
|
||||
settings.updateChatMessage(activeSession.value.id, messageId, { translated: translatedText });
|
||||
} else {
|
||||
settings.addLog('response', '(Streaming output captured)');
|
||||
settings.addLog('response', response);
|
||||
}
|
||||
} catch (err: any) {
|
||||
const errorMsg = String(err);
|
||||
@@ -261,7 +261,7 @@ const evaluateMessage = async (messageId: string, force = false) => {
|
||||
// 净化历史:只提供原文流
|
||||
const historyBlock = recentMessages.map(m => {
|
||||
const senderName = m.sender === 'me' ? activeSession.value!.me.name : activeSession.value!.partner.name;
|
||||
return `${senderName}: ${m.original}`;
|
||||
return `${senderName}: "${m.original}"`;
|
||||
}).join('\n');
|
||||
|
||||
// 动态确定语言方向
|
||||
@@ -364,7 +364,7 @@ const refineMessage = async (messageId: string) => {
|
||||
// 净化历史:只提供原文流
|
||||
const historyBlock = recentMessages.map(m => {
|
||||
const senderName = m.sender === 'me' ? activeSession.value!.me.name : activeSession.value!.partner.name;
|
||||
return `${senderName}: ${m.original}`;
|
||||
return `${senderName}: "${m.original}"`;
|
||||
}).join('\n');
|
||||
|
||||
const myToneLabel = TONE_REGISTER_OPTIONS.find(o => o.value === activeSession.value!.me.tone)?.label || '随和';
|
||||
@@ -429,7 +429,7 @@ const refineMessage = async (messageId: string) => {
|
||||
const refinedText = fullResponseJson.choices?.[0]?.message?.content || response;
|
||||
settings.updateChatMessage(activeSession.value.id, messageId, { translated: refinedText });
|
||||
} else {
|
||||
settings.addLog('response', '(Streaming output captured)');
|
||||
settings.addLog('response', response);
|
||||
}
|
||||
} catch (err: any) {
|
||||
settings.addLog('error', String(err));
|
||||
|
||||
@@ -157,7 +157,7 @@ export interface ChatSession {
|
||||
export const CONVERSATION_SYSTEM_PROMPT_TEMPLATE = `You are a professional real-time conversation translator.
|
||||
Current Context:
|
||||
- Role A (Me): {ME_NAME}, Gender: {ME_GENDER}, Language: {ME_LANG}.
|
||||
- Role B (Partner): {PART_NAME}, Gender: {PART_GENDER}, Language: {PART_LANG}.
|
||||
- Role B (Other): {PART_NAME}, Gender: {PART_GENDER}, Language: {PART_LANG}.
|
||||
|
||||
[Conversation History]
|
||||
{HISTORY_BLOCK}
|
||||
@@ -169,7 +169,7 @@ Translate the incoming text from {FROM_LANG} to {TO_LANG}.
|
||||
1. Contextual Awareness: Use the [Conversation History] to resolve pronouns (it, that, etc.) and maintain consistency.
|
||||
2. Tone & Register:
|
||||
- If translating for 'Me', strictly use the tone: {MY_TONE}.
|
||||
- If translating for 'Partner', auto-detect and preserve their original tone/emotion.
|
||||
- If translating for 'Other', auto-detect and preserve their original tone/emotion.
|
||||
3. Natural Flow: Keep the translation concise and natural for a chat environment. Avoid "translationese".
|
||||
4. Strictly avoid over-translation: Do not add extra information not present in the source text.
|
||||
5. Output ONLY the translated text, no explanations.`;
|
||||
@@ -178,8 +178,7 @@ export const CONVERSATION_EVALUATION_PROMPT_TEMPLATE = `# Role: Expert Conversat
|
||||
|
||||
# Context Info
|
||||
- Role A (Me): {ME_NAME} ({ME_GENDER}, Native {ME_LANG})
|
||||
- Role B (Partner): {PART_NAME} ({PART_GENDER}, Native {PART_LANG})
|
||||
- Target Tone: {TARGET_TONE}
|
||||
- Role B (Other): {PART_NAME} ({PART_GENDER}, Native {PART_LANG})
|
||||
|
||||
# Recent Conversation Flow (Original Messages Only):
|
||||
{HISTORY_BLOCK}
|
||||
@@ -192,9 +191,20 @@ export const CONVERSATION_EVALUATION_PROMPT_TEMPLATE = `# Role: Expert Conversat
|
||||
|
||||
# Audit Priorities
|
||||
1. **Contextual Accuracy**: Does the translation correctly reflect the meaning based on the [Recent Conversation Flow]?
|
||||
2. **Relational Tone**: Does it match the [Target Tone]?
|
||||
2. **Relational Tone**:
|
||||
- If the Speaker is 'Me', does it match the target tone({TARGET_TONE})?
|
||||
- If the Speaker is 'Other', does it preserve their original tone/emotion?
|
||||
3. **Naturalness**: Is it concise and fit for an IM (Instant Messaging) environment?
|
||||
|
||||
# Instructions
|
||||
1. **Evaluation**: Compare the [Source Text] and [Translation] based on the [Audit Priorities].
|
||||
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. **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. "analysis" and "text" MUST be in Simplified Chinese:
|
||||
{
|
||||
@@ -208,25 +218,27 @@ Respond ONLY in JSON. "analysis" and "text" MUST be in Simplified Chinese:
|
||||
export const CONVERSATION_REFINEMENT_PROMPT_TEMPLATE = `# Role: Professional Conversation Editor
|
||||
|
||||
# Context:
|
||||
- Role A: {ME_NAME} ({ME_GENDER}, Native {ME_LANG})
|
||||
- Role B: {PART_NAME} ({PART_GENDER}, Native {PART_LANG})
|
||||
- Target Tone: {TARGET_TONE}
|
||||
- Role A (Me): {ME_NAME} ({ME_GENDER}, Native {ME_LANG})
|
||||
- Role B (Other): {PART_NAME} ({PART_GENDER}, Native {PART_LANG})
|
||||
|
||||
# Recent Conversation Flow (Original Messages Only):
|
||||
{HISTORY_BLOCK}
|
||||
|
||||
# Task: Refine the following translation
|
||||
# Current Turn to Refine:
|
||||
- Speaker: {SENDER_NAME}
|
||||
- Direction: {FROM_LANG} -> {TO_LANG}
|
||||
- Source Text ({FROM_LANG}): {ORIGINAL_TEXT}
|
||||
- Current Draft ({TO_LANG}): {CURRENT_TRANSLATION}
|
||||
- Current Translation ({TO_LANG}): {CURRENT_TRANSLATION}
|
||||
|
||||
# Suggestions to Apply:
|
||||
{SUGGESTIONS}
|
||||
|
||||
# Instructions:
|
||||
1. Produce a new version of the translation that addresses the [Suggestions] while ensuring it fits naturally into the [Recent Conversation Flow].
|
||||
2. Strictly maintain the {TARGET_TONE}.
|
||||
3. Output ONLY the refined {TO_LANG} text. No preamble, no commentary.`;
|
||||
1. Carefully review the [Suggestions] and apply the requested improvements to the [Current Translation] while ensuring it fits naturally into the [Recent Conversation Flow].
|
||||
2. Ensure that the refined translation remains semantically identical to the [Source Text].
|
||||
3. If the Speaker is 'Me', strictly maintain the target tone({TARGET_TONE}); if the Speaker is 'Other', auto-detect and preserve their original tone/emotion.
|
||||
4. If a piece of feedback contradicts the [Source Text], prioritize accuracy and provide a balanced refinement.
|
||||
5. Produce ONLY the refined {TO_LANG} translation, without any additional explanations, notes, or commentary.`;
|
||||
|
||||
export const useSettingsStore = defineStore('settings', () => {
|
||||
const isDark = useLocalStorage('is-dark', false);
|
||||
|
||||
Reference in New Issue
Block a user