generaltranslation 1.0.10 → 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 +1 -3
- package/models/models.js +11 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,8 +42,6 @@ console.log(codes) // ['fr', 'es']
|
|
|
42
42
|
|
|
43
43
|
## Async Toolkit Functions
|
|
44
44
|
|
|
45
|
-
As we update m
|
|
46
|
-
|
|
47
45
|
### async getModelLanguages(model)
|
|
48
46
|
|
|
49
47
|
Get all languages known to be compatible with a given LLM. Returns an array of languages codes, [] if the model is unknown.
|
|
@@ -59,7 +57,7 @@ async function main() {
|
|
|
59
57
|
main();
|
|
60
58
|
```
|
|
61
59
|
|
|
62
|
-
### isSupportedLanguage(model, language)
|
|
60
|
+
### async isSupportedLanguage(model, language)
|
|
63
61
|
|
|
64
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.
|
|
65
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
+
const modelLanguages = await getModelLanguages(model);
|
|
27
|
+
return modelLanguages?.includes(code);
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
module.exports = {
|