generaltranslation 1.1.22 → 1.1.23
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.
- package/README.md +7 -7
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,23 +102,23 @@ const gt = new GT({
|
|
|
102
102
|
});
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
### async
|
|
105
|
+
### async translatePrompt(prompt, language)
|
|
106
106
|
|
|
107
107
|
Translates prompt into the language represented by an ISO-639 language code. Designed for translating prompts into other languages, to internationalize responses from AI models.
|
|
108
108
|
|
|
109
|
-
Just wrap `
|
|
109
|
+
Just wrap `translatePrompt` around your prompt and go.
|
|
110
110
|
|
|
111
111
|
All of the following are valid:
|
|
112
112
|
|
|
113
113
|
```
|
|
114
|
-
const translatedPrompt = await gt.
|
|
114
|
+
const translatedPrompt = await gt.translatePrompt('Tell me a story', 'es');
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
```
|
|
118
118
|
const first = 'Tell me a story ';
|
|
119
119
|
const second = 'about a cat'
|
|
120
120
|
|
|
121
|
-
const translatedPrompt = await gt.
|
|
121
|
+
const translatedPrompt = await gt.translatePrompt([
|
|
122
122
|
first, second
|
|
123
123
|
], 'es');
|
|
124
124
|
```
|
|
@@ -129,7 +129,7 @@ To mark text that shouldn't be translated, wrap it in `{ text: "", translate: fa
|
|
|
129
129
|
const prompt = 'Tell me a story about ';
|
|
130
130
|
const input = 'gatos con espadas'
|
|
131
131
|
|
|
132
|
-
const translatedPrompt = await gt.
|
|
132
|
+
const translatedPrompt = await gt.translatePrompt([
|
|
133
133
|
prompt, { text: input, translate: false }
|
|
134
134
|
], 'es');
|
|
135
135
|
```
|
|
@@ -140,7 +140,7 @@ For type consistency, you can also make everything in the prompt parameter an ob
|
|
|
140
140
|
const prompt = 'Tell me a story about ';
|
|
141
141
|
const input = 'gatos con espadas'
|
|
142
142
|
|
|
143
|
-
const translatedPrompt = await gt.
|
|
143
|
+
const translatedPrompt = await gt.translatePrompt([
|
|
144
144
|
{ text: prompt },
|
|
145
145
|
{ text: input, translate: false }
|
|
146
146
|
], 'es');
|
|
@@ -149,5 +149,5 @@ const translatedPrompt = await gt.getPrompt([
|
|
|
149
149
|
This also works:
|
|
150
150
|
|
|
151
151
|
```
|
|
152
|
-
const translatedPrompt = await gt.
|
|
152
|
+
const translatedPrompt = await gt.translatePrompt({ text: 'Tell me a story' }, 'es');
|
|
153
153
|
```
|
package/index.js
CHANGED
|
@@ -35,7 +35,7 @@ class GT {
|
|
|
35
35
|
getModelsByDeveloper = _getModelsByDeveloper; // returns array of model names
|
|
36
36
|
|
|
37
37
|
// Prompt I18N
|
|
38
|
-
|
|
38
|
+
translatePrompt = async (prompt, language) => {
|
|
39
39
|
return await _translatePrompt({
|
|
40
40
|
content: prompt, language: language, context: this
|
|
41
41
|
});
|