generaltranslation 1.0.11 → 1.0.12

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
@@ -57,7 +57,7 @@ async function main() {
57
57
  main();
58
58
  ```
59
59
 
60
- ### isSupportedLanguage(model, language)
60
+ ### async isSupportedLanguage(model, language)
61
61
 
62
62
  Returns true if a model is known to be compatible with a given language, represented by an ISO-639 language code. Returns false otherwise.
63
63
 
package/models/models.js CHANGED
@@ -4,21 +4,27 @@
4
4
  // Returns an object or null if invalid
5
5
  const getModelInfo = async model => {
6
6
  model = model?.toLowerCase();
7
- const result = await fetch(`https://gtx.dev/model/${model}`);
8
- const modelInfo = await result.json();
9
- return modelInfo;
7
+ try {
8
+ const result = await fetch(`https://gtx.dev/model/${model}`);
9
+ const modelInfo = await result.json();
10
+ return modelInfo;
11
+ } catch {
12
+ return null;
13
+ }
10
14
  }
11
15
 
12
16
  // Get all languages known to be compatible with a given LLM
13
17
  // Returns an array of languages codes, [] if unknown
14
18
  const getModelLanguages = async model => {
15
- return (await getModelInfo(model))?.languages || [];
19
+ const modelInfo = await getModelInfo(model);
20
+ return modelInfo?.languages || [];
16
21
  }
17
22
 
18
23
  // Returns true if a model is known to be compatible with a language
19
24
  // Returns false otherwise
20
25
  const isLanguageSupported = async (model, code) => {
21
- return (await getModelLanguages(model))?.includes(code);
26
+ const modelLanguages = await getModelLanguages(model);
27
+ return modelLanguages?.includes(code);
22
28
  }
23
29
 
24
30
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "index.js",
6
6
  "scripts": {