Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions firestore-translate-text/functions/src/translate/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ export class GenkitTranslator implements ITranslator {
async translate(text: string, targetLanguage: string): Promise<string> {
try {
// Sanitize input text by escaping special characters
const sanitizedText = text
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/\n/g, " ");

// Construct the prompt with strict boundaries and clear instructions
const prompt = `<translation_task>
<instructions>
Expand All @@ -131,7 +126,7 @@ export class GenkitTranslator implements ITranslator {
- Do not provide explanations or alternate translations
- Maintain the original formatting
</instructions>
<text_to_translate>${sanitizedText}</text_to_translate>
<text_to_translate>${text}</text_to_translate>
</translation_task>`;

const response = await this.client.generate({
Expand Down