generaltranslation 1.1.13 → 1.1.14
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 +8 -8
- package/package.json +1 -1
- package/prompts/prompts.js +3 -3
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<a href='https://www.generaltranslation.com' target="_blank">generaltranslation.com</a>
|
|
4
4
|
|
|
5
|
-
A language toolkit for AI developers.
|
|
5
|
+
A language toolkit for AI developers.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Full documentation coming soon!
|
|
8
8
|
|
|
9
9
|
## Getting Started
|
|
10
10
|
|
|
@@ -86,11 +86,11 @@ const supported = await gt.isSupportedLanguage('gpt-4', 'fr')
|
|
|
86
86
|
console.log(supported) // true
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
## API
|
|
89
|
+
## Prompt Internationalization API
|
|
90
90
|
|
|
91
|
-
For
|
|
91
|
+
For this function, you need to sign up for an API key at <a href='https://generaltranslation.com' target='_blank'>generaltranslation.com</a>.
|
|
92
92
|
|
|
93
|
-
There's a small, free allowance to let you test out the API without payment
|
|
93
|
+
There's a small, free allowance to let you test out the API without payment details.
|
|
94
94
|
|
|
95
95
|
Add the API key to your code like this:
|
|
96
96
|
|
|
@@ -98,15 +98,15 @@ Add the API key to your code like this:
|
|
|
98
98
|
import GT from 'generaltranslation'
|
|
99
99
|
|
|
100
100
|
const gt = new GT({
|
|
101
|
-
|
|
101
|
+
apiKey: process.env.GT_API_KEY // looks like 'gtx-XXX'
|
|
102
102
|
});
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
### async
|
|
105
|
+
### async getPrompt(prompt, code)
|
|
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 `getPrompt` around your prompt and go.
|
|
110
110
|
|
|
111
111
|
All of the following are valid:
|
|
112
112
|
|
package/package.json
CHANGED
package/prompts/prompts.js
CHANGED
|
@@ -73,15 +73,15 @@ const _getPrompt = async (prompt, code, defaultLanguage, apiKey) => {
|
|
|
73
73
|
return _constructPrompt(prompt);
|
|
74
74
|
}
|
|
75
75
|
const { processed, redacted } = _processPrompt(prompt);
|
|
76
|
-
const response = await fetch('http://
|
|
76
|
+
const response = await fetch('http://localhost:8787/internationalize', {
|
|
77
77
|
method: 'POST',
|
|
78
78
|
headers: {
|
|
79
79
|
'Content-Type': 'application/json',
|
|
80
80
|
'gtx-api-key': apiKey
|
|
81
81
|
},
|
|
82
82
|
body: JSON.stringify({
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
content: processed,
|
|
84
|
+
targetLanguage: code,
|
|
85
85
|
defaultLanguage: defaultLanguage
|
|
86
86
|
})
|
|
87
87
|
})
|