mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 16:45:25 +02:00
Fix: Improve AI description completeness and increase Gemini token limit to 4096
This commit is contained in:
@@ -197,7 +197,7 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
let prompt = '';
|
||||
const baseContext = `Article Name: ${row[COLUMNS.ARTICLE_NAME]}\nArticle Details (EN): ${formData.detailsEn || 'N/A'}\nArticle Details (DE): ${formData.detailsDe || 'N/A'}`;
|
||||
|
||||
const systemPrompt = "You are a professional copywriter and expert translator for CRAZE GmbH, a German toy company. CRITICAL: Output ONLY the translated or generated content. Do not include any introductions, conclusions, or conversational text. Translate EVERYTHING, including phrases in ALL CAPS (maintain the all-caps casing for those phrases in the translation). Your response must contain only the final product description.";
|
||||
const systemPrompt = "You are a professional copywriter and expert translator for CRAZE GmbH, a German toy company. CRITICAL: Output ONLY the translated or generated content. Do not include any introductions, conclusions, or conversational text. Translate EVERYTHING, including phrases in ALL CAPS (maintain the all-caps casing for those phrases in the translation). Your response must be complete, with all sentences finished and logically concluded. Never end mid-sentence.";
|
||||
|
||||
if (field === 'longDe') {
|
||||
if (formData.longEn) {
|
||||
@@ -208,11 +208,13 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
3. Keep all technical specs intact.
|
||||
4. Translate every single paragraph into natural, commercial German for toy buyers.
|
||||
5. Translate ALL text, including titles or phrases in ALL CAPS, and keep them in ALL CAPS in the translation.
|
||||
6. ENSURE the translation is complete and does not cut off. The final sentence must be fully finished.
|
||||
|
||||
English Text to Translate:
|
||||
${formData.longEn}`;
|
||||
} else {
|
||||
prompt = `Based on the following product details, generate a long commercial description in German. It should be fluent, oriented towards B2B toy buyers, 3-5 paragraphs long. Include features, benefits, and material if available.\n\n${baseContext}`;
|
||||
prompt = `Based on the following product details, generate a long commercial description in German. It should be fluent, oriented towards B2B toy buyers, 3-5 paragraphs long. Include features, benefits, and material if available.
|
||||
IMPORTANT: Ensure the description is complete and ends with a finished sentence.\n\n${baseContext}`;
|
||||
}
|
||||
} else if (field === 'longEn') {
|
||||
if (formData.longDe) {
|
||||
@@ -223,29 +225,45 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
3. Keep all technical specs intact.
|
||||
4. Translate every single paragraph into natural, commercial English for toy buyers.
|
||||
5. Translate ALL text, including titles or phrases in ALL CAPS, and keep them in ALL CAPS in the translation.
|
||||
6. ENSURE the translation is complete and does not cut off. The final sentence must be fully finished.
|
||||
|
||||
German Text to Translate:
|
||||
${formData.longDe}`;
|
||||
} else {
|
||||
prompt = `Based on the following product details, generate a long commercial description in English. It should be fluent, oriented towards B2B toy buyers, 3-5 paragraphs long.\n\n${baseContext}`;
|
||||
prompt = `Based on the following product details, generate a long commercial description in English. It should be fluent, oriented towards B2B toy buyers, 3-5 paragraphs long.
|
||||
IMPORTANT: Ensure the description is complete and ends with a finished sentence.\n\n${baseContext}`;
|
||||
}
|
||||
} else if (field === 'shortDe') {
|
||||
if (formData.shortEn) {
|
||||
prompt = `Translate exactly this short English product description into professional German for the toy market. IMPORTANT: Translate everything, including any ALL CAPS phrases, maintaining the all-caps formatting:\n\n${formData.shortEn}`;
|
||||
prompt = `Translate exactly this short English product description into professional German for the toy market.
|
||||
IMPORTANT:
|
||||
1. Translate everything, including any ALL CAPS phrases, maintaining the all-caps formatting.
|
||||
2. ENSURE the translation is complete and does not cut off mid-sentence.\n\n${formData.shortEn}`;
|
||||
} else if (formData.longDe) {
|
||||
const targetChars = Math.round(formData.longDe.length * 0.3);
|
||||
prompt = `Create a concise summary of the following German product description. The summary must be approximately ${targetChars} characters long (about 30% of the original). Preserve the most important commercial highlights and features in natural, professional German for B2B toy buyers. Do not use bullet points — write flowing prose.\n\nOriginal description:\n${formData.longDe}`;
|
||||
prompt = `Create a concise summary of the following German product description.
|
||||
The summary must be approximately ${targetChars} characters long (about 30% of the original).
|
||||
Preserve the most important commercial highlights and features in natural, professional German for B2B toy buyers.
|
||||
Do not use bullet points — write flowing prose.
|
||||
IMPORTANT: Ensure the summary is a complete thought and ends with a finished sentence.\n\nOriginal description:\n${formData.longDe}`;
|
||||
} else {
|
||||
prompt = `Based on the following product details, generate a short commercial description in German (2-4 sentences max).\n\n${baseContext}`;
|
||||
prompt = `Based on the following product details, generate a short commercial description in German (2-4 sentences max). Ensure the text is complete and ends with a finished sentence.\n\n${baseContext}`;
|
||||
}
|
||||
} else if (field === 'shortEn') {
|
||||
if (formData.shortDe) {
|
||||
prompt = `Translate exactly this short German product description into professional English for the toy market. IMPORTANT: Translate everything, including any ALL CAPS phrases, maintaining the all-caps formatting:\n\n${formData.shortDe}`;
|
||||
prompt = `Translate exactly this short German product description into professional English for the toy market.
|
||||
IMPORTANT:
|
||||
1. Translate everything, including any ALL CAPS phrases, maintaining the all-caps formatting.
|
||||
2. ENSURE the translation is complete and does not cut off mid-sentence.\n\n${formData.shortDe}`;
|
||||
} else if (formData.longEn) {
|
||||
const targetChars = Math.round(formData.longEn.length * 0.3);
|
||||
prompt = `Create a concise summary of the following English product description. The summary must be approximately ${targetChars} characters long (about 30% of the original). Preserve the most important commercial highlights and features in natural, professional English for B2B toy buyers. Do not use bullet points — write flowing prose.\n\nOriginal description:\n${formData.longEn}`;
|
||||
prompt = `Create a concise summary of the following English product description.
|
||||
The summary must be approximately ${targetChars} characters long (about 30% of the original).
|
||||
Preserve the most important commercial highlights and features in natural, professional English for B2B toy buyers.
|
||||
Do not use bullet points — write flowing prose.
|
||||
IMPORTANT: Ensure the summary is a complete thought and ends with a finished sentence.\n\nOriginal description:\n${formData.longEn}`;
|
||||
} else {
|
||||
prompt = `Based on the following product details, generate a short commercial description in English (2-4 sentences max).\n\n${baseContext}`;
|
||||
prompt = `Based on the following product details, generate a short commercial description in English (2-4 sentences max). Ensure the text is complete and ends with a finished sentence.\n\n${baseContext}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function generateGemini(prompt: string, systemPrompt: string): Prom
|
||||
}]
|
||||
}],
|
||||
generationConfig: {
|
||||
maxOutputTokens: 2048,
|
||||
maxOutputTokens: 4096,
|
||||
temperature: 0.2
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user