generaltranslation 1.0.4 → 1.0.6
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 +44 -4
- package/models/data/AliasToModel.json +1 -0
- package/models/data/Models.json +3 -4
- package/models/models.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ npm i generaltranslation
|
|
|
12
12
|
|
|
13
13
|
## Toolkit
|
|
14
14
|
|
|
15
|
-
### getLanguageName
|
|
15
|
+
### getLanguageName(codes)
|
|
16
16
|
|
|
17
|
-
Returns a language name from a two or three-letter ISO
|
|
17
|
+
Returns a language name from a two or three-letter ISO-639 language code, or an array of codes.
|
|
18
18
|
|
|
19
19
|
```
|
|
20
20
|
import { getLanguageName } from 'generaltranslation'
|
|
@@ -22,8 +22,48 @@ import { getLanguageName } from 'generaltranslation'
|
|
|
22
22
|
const language = getLanguageName('en');
|
|
23
23
|
console.log(language) // 'English'
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
console.log(
|
|
25
|
+
const languages = getLanguageName(['fr', 'es'])
|
|
26
|
+
console.log(languages) // ['French', 'Spanish']
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### getLanguageCode(languages)
|
|
30
|
+
|
|
31
|
+
Returns an ISO-639 code from a language name or an array of language names.
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
import { getLanguageCode } from 'generaltranslation'
|
|
35
|
+
|
|
36
|
+
const code = getLanguageCode('English');
|
|
37
|
+
console.log(language) // 'en'
|
|
38
|
+
|
|
39
|
+
const codes = getLanguageCodes(['French', 'Spanish'])
|
|
40
|
+
console.log(codes) // ['fr', 'es']
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### getModelLanguages(model)
|
|
44
|
+
|
|
45
|
+
<i>in beta!</i>
|
|
46
|
+
|
|
47
|
+
Get all languages known to be compatible with a given LLM. Returns an array of languages codes, [] if the model is unknown.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
import { getModelLanguages } from 'generaltranslation'
|
|
51
|
+
|
|
52
|
+
const languages = getModelLanguages('mixtral-8x7b')
|
|
53
|
+
console.log(languages) // ['en', 'fr', 'de', 'es', 'it']
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### isSupportedLanguage(model, language)
|
|
57
|
+
|
|
58
|
+
<i>in beta!</i>
|
|
59
|
+
|
|
60
|
+
Returns true if a model is known to be compatible with a given language, represented by an ISO-639 language code. Returns false otherwise.
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
import { isSupportedLanguage } from 'generaltranslation'
|
|
64
|
+
|
|
65
|
+
const supported = isSupportedLanguage('gpt-4', 'fr')
|
|
66
|
+
console.log(supported) // true
|
|
27
67
|
```
|
|
28
68
|
|
|
29
69
|
## API
|
package/models/data/Models.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"gpt-4": {
|
|
3
3
|
"languages": [
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
]
|
|
4
|
+
"ja", "af", "ko", "grc", "la", "ar", "lv", "zh", "pl", "en", "ru",
|
|
5
|
+
"fr", "es", "de", "sw", "el", "tr", "is", "uk", "id", "cy", "it"
|
|
6
|
+
]
|
|
8
7
|
},
|
|
9
8
|
"gpt-3.5-turbo": {
|
|
10
9
|
"languages": [
|
package/models/models.js
CHANGED
|
@@ -19,7 +19,7 @@ const getModelLanguages = model => {
|
|
|
19
19
|
return getModelInfo(model)?.languages || [];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Returns true if a model is
|
|
22
|
+
// Returns true if a model is known to be compatible with a language
|
|
23
23
|
// Returns false otherwise
|
|
24
24
|
const isLanguageSupported = (model, code) => {
|
|
25
25
|
return getModelLanguages(model)?.includes(language);
|