generaltranslation 1.1.12 → 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 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
 
@@ -64,12 +64,8 @@ We continually benchmark AI models and add new models as they are released. That
64
64
  Get the latest list of models for which there is data. Returns an array of model names.
65
65
 
66
66
  ```
67
- async function main() {
68
- const models = await gt.getModelList();
69
- console.log(models) // ['gpt-4', ... ]
70
- }
71
-
72
- main();
67
+ const models = await gt.getModelList();
68
+ console.log(models) // ['gpt-4', ... ]
73
69
  ```
74
70
 
75
71
  ### async getModelLanguages(model)
@@ -77,12 +73,8 @@ main();
77
73
  Get all languages known to be compatible with a given AI model. Returns an array of languages codes, or null if the model is unknown.
78
74
 
79
75
  ```
80
- async function main() {
81
- const languages = await gt.getModelLanguages('mixtral-8x7b')
82
- console.log(languages) // ['en', 'fr', 'de', 'es', 'it']
83
- }
84
-
85
- main();
76
+ const languages = await gt.getModelLanguages('mixtral-8x7b')
77
+ console.log(languages) // ['en', 'fr', 'de', 'es', 'it']
86
78
  ```
87
79
 
88
80
  ### async isSupportedLanguage(model, code)
@@ -90,17 +82,15 @@ main();
90
82
  Returns true if a model is known to be compatible with a given language, represented by an ISO-639 language code. Returns false otherwise.
91
83
 
92
84
  ```
93
- async function main() {
94
- const supported = await gt.isSupportedLanguage('gpt-4', 'fr')
95
- console.log(supported) // true
96
- }
97
-
98
- main();
85
+ const supported = await gt.isSupportedLanguage('gpt-4', 'fr')
86
+ console.log(supported) // true
99
87
  ```
100
88
 
101
- ## API
89
+ ## Prompt Internationalization API
102
90
 
103
- 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
+
93
+ There's a small, free allowance to let you test out the API without payment details.
104
94
 
105
95
  Add the API key to your code like this:
106
96
 
@@ -108,15 +98,17 @@ Add the API key to your code like this:
108
98
  import GT from 'generaltranslation'
109
99
 
110
100
  const gt = new GT({
111
- apiKey: process.env.GT_API_KEY // looks like 'gtx-XXX'
101
+ apiKey: process.env.GT_API_KEY // looks like 'gtx-XXX'
112
102
  });
113
103
  ```
114
104
 
115
- ### async gt.getPrompt(prompt, code)
105
+ ### async getPrompt(prompt, code)
116
106
 
117
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.
118
108
 
119
- Just wrap `gt.getPrompt` around your prompt and go. All of the following are valid:
109
+ Just wrap `getPrompt` around your prompt and go.
110
+
111
+ All of the following are valid:
120
112
 
121
113
  ```
122
114
  const translatedPrompt = await gt.getPrompt('Tell me a story', 'es');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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://prompts.gtx.dev/internationalize', {
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
- prompt: processed,
84
- language: code,
83
+ content: processed,
84
+ targetLanguage: code,
85
85
  defaultLanguage: defaultLanguage
86
86
  })
87
87
  })