generaltranslation 1.1.35 → 1.2.0
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 -32
- package/index.js +0 -8
- package/package.json +1 -1
- package/translate/html.js +1 -1
- package/translate/prompts.js +1 -1
- package/models/models.js +0 -87
package/README.md
CHANGED
|
@@ -129,35 +129,4 @@ This also works:
|
|
|
129
129
|
|
|
130
130
|
```
|
|
131
131
|
const translatedPrompt = await gt.translatePrompt({ text: 'Tell me a story' }, 'es');
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Which languages do AI models understand?
|
|
135
|
-
|
|
136
|
-
We continually benchmark AI models and add new models as they are released. That means these functions have to be <code>async</code>. This information is provided as a public service. It's completely free and requires no API key.
|
|
137
|
-
|
|
138
|
-
### async getModelList()
|
|
139
|
-
|
|
140
|
-
Get the latest list of models for which there is data. Returns an array of model names.
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
const models = await getModelList();
|
|
144
|
-
console.log(models) // ['gpt-4', ... ]
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### async getModelLanguages(model)
|
|
148
|
-
|
|
149
|
-
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.
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
const languages = await getModelLanguages('mixtral-8x7b')
|
|
153
|
-
console.log(languages) // ['en', 'fr', 'de', 'es', 'it']
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### async isSupportedLanguage(model, code)
|
|
157
|
-
|
|
158
|
-
Returns true if a model is known to be compatible with a given language, represented by an ISO-639 language code. Returns false otherwise.
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
const supported = await isSupportedLanguage('gpt-4', 'fr')
|
|
162
|
-
console.log(supported) // true
|
|
163
|
-
```
|
|
132
|
+
```
|
package/index.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import _getUserLanguage from "./client/getUserLanguage.js";
|
|
7
7
|
import { _getLanguageCode, _getLanguageName } from "./codes/codes.js"
|
|
8
|
-
import { _getModelInfo, _getModelList, _getModelLanguages, _isLanguageSupported, _getModelsByDeveloper, _getModelsByLanguage, _getAllModelInfo } from "./models/models.js"
|
|
9
8
|
import _translatePrompt from "./translate/prompts.js"
|
|
10
9
|
import _createI18N from "./translate/html.js";
|
|
11
10
|
|
|
@@ -49,12 +48,5 @@ export default class GT {
|
|
|
49
48
|
export {
|
|
50
49
|
_getLanguageCode as getLanguageCode,
|
|
51
50
|
_getLanguageName as getLanguageName,
|
|
52
|
-
_getModelList as getModelList,
|
|
53
|
-
_getModelInfo as getModelInfo,
|
|
54
|
-
_getModelLanguages as getModelLanguages,
|
|
55
|
-
_getAllModelInfo as getAllModelInfo,
|
|
56
|
-
_isLanguageSupported as isLanguageSupported,
|
|
57
|
-
_getModelsByDeveloper as getModelsByDeveloper,
|
|
58
|
-
_getModelsByLanguage as getModelsByLanguage,
|
|
59
51
|
_getUserLanguage as getUserLanguage
|
|
60
52
|
};
|
package/package.json
CHANGED
package/translate/html.js
CHANGED
package/translate/prompts.js
CHANGED
package/models/models.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// ----- MODEL INFORMATION ----- //
|
|
2
|
-
|
|
3
|
-
// Get all info on all models
|
|
4
|
-
export const _getAllModelInfo = async () => {
|
|
5
|
-
try {
|
|
6
|
-
const result = await fetch(`https://models.gtx.dev/all`);
|
|
7
|
-
return await result.json();
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error(error)
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Get all models by a given developer
|
|
15
|
-
// Returns an empty array if none
|
|
16
|
-
export const _getModelsByDeveloper = async developer => {
|
|
17
|
-
if (!developer) return null;
|
|
18
|
-
developer = developer?.toLowerCase();
|
|
19
|
-
try {
|
|
20
|
-
const result = await fetch(`https://models.gtx.dev/developer/${developer}`);
|
|
21
|
-
const models = await result.json();
|
|
22
|
-
return models;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(error)
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Get all models certified for a given language
|
|
30
|
-
// Returns an empty array if none
|
|
31
|
-
export const _getModelsByLanguage = async language => {
|
|
32
|
-
if (!language) return null;
|
|
33
|
-
language = language?.toLowerCase();
|
|
34
|
-
try {
|
|
35
|
-
const result = await fetch(`https://models.gtx.dev/language/${language}`);
|
|
36
|
-
const models = await result.json();
|
|
37
|
-
return models;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error(error)
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Get all models
|
|
45
|
-
// Returns an array of model names
|
|
46
|
-
export const _getModelList = async () => {
|
|
47
|
-
try {
|
|
48
|
-
const result = await fetch(`https://models.gtx.dev/models`);
|
|
49
|
-
const models = await result.json();
|
|
50
|
-
return models;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error(error);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Get all info about a given model
|
|
58
|
-
// Returns an object or null if invalid
|
|
59
|
-
export const _getModelInfo = async model => {
|
|
60
|
-
if (!model) return null;
|
|
61
|
-
model = model?.toLowerCase();
|
|
62
|
-
try {
|
|
63
|
-
const result = await fetch(`https://models.gtx.dev/model/${model}`);
|
|
64
|
-
const modelInfo = await result.json();
|
|
65
|
-
return modelInfo;
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(error)
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ----- FUNCTIONS FROM MODEL INFO ----- //
|
|
73
|
-
|
|
74
|
-
// Get all languages known to be compatible with a given LLM
|
|
75
|
-
// Returns an array of languages codes, or null if unknown
|
|
76
|
-
export const _getModelLanguages = async model => {
|
|
77
|
-
const modelInfo = await _getModelInfo(model);
|
|
78
|
-
return modelInfo?.languages;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Returns true if a model is known to be compatible with a language
|
|
82
|
-
// Returns false otherwise
|
|
83
|
-
export const _isLanguageSupported = async (model, code) => {
|
|
84
|
-
if (!code) return false;
|
|
85
|
-
const modelLanguages = await _getModelLanguages(model);
|
|
86
|
-
return modelLanguages?.includes(code) ? true : false;
|
|
87
|
-
}
|