generaltranslation 1.1.13 → 1.1.15

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 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
- Note: this package is in active development.
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 these functions, you need to sign up for an API key at <a href='https://generaltranslation.com' target='_blank'>generaltranslation.com</a>.
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 information.
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
- apiKey: process.env.GT_API_KEY // looks like 'gtx-XXX'
101
+ apiKey: process.env.GT_API_KEY // looks like 'gtx-XXX'
102
102
  });
103
103
  ```
104
104
 
105
- ### async gt.getPrompt(prompt, code)
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 `gt.getPrompt` around your prompt and go.
109
+ Just wrap `getPrompt` around your prompt and go.
110
110
 
111
111
  All of the following are valid:
112
112
 
package/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  const { _getLanguageName, _getLanguageCode } = require('./codes/codes.js');
7
7
  const { _getModelList, _getModelLanguages, _isLanguageSupported } = require('./models/models.js');
8
- const { _getPrompt } = require('./prompts/prompts.js');
8
+ const { _translate } = require('./translate/translate.js');
9
9
 
10
10
  // ----- CORE CLASS ----- //
11
11
 
@@ -30,9 +30,15 @@ class GT {
30
30
 
31
31
  // Prompt internationalization
32
32
  getPrompt = async (prompt, code) => {
33
- return await _getPrompt(prompt, code, this.defaultLanguage, this.apiKey);
33
+ return await _translate(prompt, code, this.defaultLanguage, this.apiKey);
34
34
  }
35
35
 
36
+ // Translation (same as prompt internationalization)
37
+ translate = async (prompt, code) => {
38
+ return await _translate(prompt, code, this.defaultLanguage, this.apiKey);
39
+ }
40
+
41
+
36
42
  }
37
43
 
38
44
  // ----- EXPORTS ----- //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -62,9 +62,9 @@ const _constructPrompt = ({translated, redacted = null}) => {
62
62
  }
63
63
  }
64
64
 
65
- // Get a translated prompt via General Translation API
66
- // Returns prompt string
67
- const _getPrompt = async (prompt, code, defaultLanguage, apiKey) => {
65
+ // Get a translation via General Translation API
66
+ // Returns string
67
+ const _translate = async (prompt, code, defaultLanguage, apiKey) => {
68
68
  try {
69
69
  if (!apiKey) {
70
70
  throw new Error('Missing API Key!')
@@ -80,8 +80,8 @@ const _getPrompt = async (prompt, code, defaultLanguage, apiKey) => {
80
80
  'gtx-api-key': apiKey
81
81
  },
82
82
  body: JSON.stringify({
83
- prompt: processed,
84
- language: code,
83
+ content: processed,
84
+ targetLanguage: code,
85
85
  defaultLanguage: defaultLanguage
86
86
  })
87
87
  })
@@ -99,5 +99,5 @@ const _getPrompt = async (prompt, code, defaultLanguage, apiKey) => {
99
99
  }
100
100
 
101
101
  module.exports = {
102
- _getPrompt
102
+ _translate
103
103
  }