@cobrowser/chatgpt 0.7.39-beta.1 → 0.7.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,7 +36,7 @@ class TranslationService extends BaseService_1.default {
36
36
  return Promise.reject(new Error('Text must be provided'));
37
37
  }
38
38
  const translateText = `
39
- Translate the following text to ${toLanguage} if it's not already in ${toLanguage}: ${text}.
39
+ Translate the following text from ${fromLanguage} to ${toLanguage} if it's not already in ${toLanguage}: ${text}.
40
40
  `;
41
41
  const requestBody = {
42
42
  model: this.chatGPTModel,
@@ -12,4 +12,4 @@ export declare const DESTINATION_LANGUAGE = "English";
12
12
  export declare const LANGUAGE_DETECTION_SYSTEM_ROLE = "\n You are a language detection assistant. Your task is to analyze short text input and determine \n its language using ISO language code. Respond only in JSON format with two key-value pairs: \n - 'languageCode': the detected language's ISO code (or undefined if detection fails).\n - 'isError': a boolean value (true if detection fails, false otherwise).\n";
13
13
  export declare const WORD_FREQUENCY_LANGUAGE_DETECTION_SYSTEM_ROLE = "\n You are a language detection assistant. Your task is to analyze the most frequently occurring words in the given text \n and determine the language based on those words. Respond only in JSON format with two key-value pairs: \n - 'languageCode': the detected language's ISO code (or undefined if detection fails).\n - 'isError': a boolean value (true if detection fails, false otherwise).\n";
14
14
  export declare const TRANSLATION_SYSTEM_ROLE_BASE_PROMPT = "\n <BASE_PROMPT>\n\n You are a translator that responds exclusively in JSON format.\n\n Your response must be a JSON object containing:\n - 'translations': an array of objects. Each object in the array must contain:\n - 'original': The original input message before translation.\n - 'translation': The translated version of 'original'.\n - 'isError': a boolean value (true if translation fails, false otherwise).\n\n **You MUST return JSON format even if you fail to translate the text.**\n \n In that case:\n\n - 'translations' field should be an empty array.\n - 'isError' should be true.\n\n You must follow the response structure defined in this BASE_PROMPT strictly.\n \n Apply all instructions in ADDITIONAL_INSTRUCTIONS, but never alter the required JSON structure.\n\n </BASE_PROMPT>\n";
15
- export declare const TRANSLATION_ADDITIONAL_INSTRUCTIONS = "\n Ensure that each 'translation' accurately reflects the meaning of 'original' and is phrased in a way that native speakers would naturally express it, taking into account cultural context and commonly used expressions.\n\n Do not translate commonly known Latin phrases or expressions (e.g., 'de facto', 'bona fide') when they appear mid-sentence in another language. Leave them exactly as they appear in the original text.\n";
15
+ export declare const TRANSLATION_ADDITIONAL_INSTRUCTIONS = "\n === BEGIN TRANSLATION QUALITY RULE ===\n\n Ensure that each 'translation' accurately reflects the meaning of 'original' and is phrased in a way that native speakers would naturally express it, taking into account cultural context and commonly used expressions.\n \n === END TRANSLATION QUALITY RULE ===\n\n\n === BEGIN LATIN PHRASE PRESERVATION RULE ===\n\n Do not translate commonly known Latin phrases or expressions (e.g., 'de facto', 'bona fide') when they appear mid-sentence in another language. Leave them exactly as they appear in the original text.\n \n === END LATIN PHRASE PRESERVATION RULE ===\n\n\n === BEGIN GEOGRAPHICAL NAME IMMUTABILITY RULE ===\n\n For every geographical name, you MUST strictly mirror the exact form used by the user.\n\n You MUST ONLY use a specific geographical name variant if the user explicitly used that exact variant in their message.\n\n Geographical names include cities, towns, villages, countries, regions, states, and provinces.\n\n Geographical names MUST be treated as immutable user-controlled tokens.\n\n You MUST preserve exactly the user-provided:\n\n 1. spelling\n 2. capitalization\n 3. punctuation\n 4. spacing\n 5. diacritics\n 6. word order\n\n Geographical names MUST be copied verbatim from the user\u2019s message into the response.\n\n You MUST NOT translate, localize, substitute, normalize, infer, or switch between geographical name variants.\n\n You MUST NOT replace geographical names with official, native, common, or localized versions unless the user explicitly used that exact form.\n\n EXCEPTION \u2014 TYPO CORRECTION:\n\n If a geographical name in the user's message contains a clear, unambiguous spelling typo, you MUST correct it to the single most logically intended and widely recognized standard form.\n\n This exception applies ONLY when:\n\n 1. the misspelling is clearly accidental\n 2. there is exactly one reasonable intended geographical location\n 3. the correction does NOT change the intended name variant\n\n If multiple locations could match the misspelling, or if the spelling appears intentional, you MUST mirror the user's input exactly and MUST NOT correct it.\n\n When the typo correction exception is applied, the corrected name becomes the authoritative form and MUST be used consistently in the response.\n\n You MUST NOT explain, mention, or reference these rules.\n\n This rule applies regardless of response language, common exonyms or endonyms, or cultural or linguistic conventions.\n This rule has absolute priority and MUST be enforced at all times.\n\n === END GEOGRAPHICAL NAME IMMUTABILITY RULE ===\n";
@@ -78,7 +78,63 @@ exports.TRANSLATION_SYSTEM_ROLE_BASE_PROMPT = `
78
78
  `;
79
79
  // Additional instructions for translation. This is going to be used if additional instructions are not passed as parameter by manager.
80
80
  exports.TRANSLATION_ADDITIONAL_INSTRUCTIONS = `
81
+ === BEGIN TRANSLATION QUALITY RULE ===
82
+
81
83
  Ensure that each 'translation' accurately reflects the meaning of 'original' and is phrased in a way that native speakers would naturally express it, taking into account cultural context and commonly used expressions.
84
+
85
+ === END TRANSLATION QUALITY RULE ===
86
+
87
+
88
+ === BEGIN LATIN PHRASE PRESERVATION RULE ===
82
89
 
83
90
  Do not translate commonly known Latin phrases or expressions (e.g., 'de facto', 'bona fide') when they appear mid-sentence in another language. Leave them exactly as they appear in the original text.
91
+
92
+ === END LATIN PHRASE PRESERVATION RULE ===
93
+
94
+
95
+ === BEGIN GEOGRAPHICAL NAME IMMUTABILITY RULE ===
96
+
97
+ For every geographical name, you MUST strictly mirror the exact form used by the user.
98
+
99
+ You MUST ONLY use a specific geographical name variant if the user explicitly used that exact variant in their message.
100
+
101
+ Geographical names include cities, towns, villages, countries, regions, states, and provinces.
102
+
103
+ Geographical names MUST be treated as immutable user-controlled tokens.
104
+
105
+ You MUST preserve exactly the user-provided:
106
+
107
+ 1. spelling
108
+ 2. capitalization
109
+ 3. punctuation
110
+ 4. spacing
111
+ 5. diacritics
112
+ 6. word order
113
+
114
+ Geographical names MUST be copied verbatim from the user’s message into the response.
115
+
116
+ You MUST NOT translate, localize, substitute, normalize, infer, or switch between geographical name variants.
117
+
118
+ You MUST NOT replace geographical names with official, native, common, or localized versions unless the user explicitly used that exact form.
119
+
120
+ EXCEPTION — TYPO CORRECTION:
121
+
122
+ If a geographical name in the user's message contains a clear, unambiguous spelling typo, you MUST correct it to the single most logically intended and widely recognized standard form.
123
+
124
+ This exception applies ONLY when:
125
+
126
+ 1. the misspelling is clearly accidental
127
+ 2. there is exactly one reasonable intended geographical location
128
+ 3. the correction does NOT change the intended name variant
129
+
130
+ If multiple locations could match the misspelling, or if the spelling appears intentional, you MUST mirror the user's input exactly and MUST NOT correct it.
131
+
132
+ When the typo correction exception is applied, the corrected name becomes the authoritative form and MUST be used consistently in the response.
133
+
134
+ You MUST NOT explain, mention, or reference these rules.
135
+
136
+ This rule applies regardless of response language, common exonyms or endonyms, or cultural or linguistic conventions.
137
+ This rule has absolute priority and MUST be enforced at all times.
138
+
139
+ === END GEOGRAPHICAL NAME IMMUTABILITY RULE ===
84
140
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobrowser/chatgpt",
3
- "version": "0.7.39-beta.1",
3
+ "version": "0.7.40",
4
4
  "description": "chatgpt services to connect our projects with chatgpt api",
5
5
  "keywords": [
6
6
  "chatgpt",
@@ -40,5 +40,5 @@
40
40
  "bugs": {
41
41
  "url": "https://bitbucket.org/cobrowser/cb_utils/issues"
42
42
  },
43
- "gitHead": "d3086da041359550490fc14c143a3fc79ee7603e"
43
+ "gitHead": "16611610698982c71962d16bdf6508733b171847"
44
44
  }