@hestia-earth/api 0.28.0 → 0.28.1
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.
|
@@ -7,7 +7,7 @@ export var LlmEngine;
|
|
|
7
7
|
LlmEngine["hf"] = "hf";
|
|
8
8
|
LlmEngine["nvidia"] = "nvidia";
|
|
9
9
|
LlmEngine["deepseek"] = "deepseek";
|
|
10
|
-
LlmEngine["
|
|
10
|
+
LlmEngine["chatgpt"] = "chatgpt";
|
|
11
11
|
})(LlmEngine || (LlmEngine = {}));
|
|
12
12
|
export var LlmApiKey;
|
|
13
13
|
(function (LlmApiKey) {
|
|
@@ -20,6 +20,15 @@ export var LlmApiKey;
|
|
|
20
20
|
LlmApiKey["OPENAI_API_KEY"] = "OPENAI_API_KEY";
|
|
21
21
|
})(LlmApiKey || (LlmApiKey = {}));
|
|
22
22
|
export const llmApiKeys = Object.values(LlmApiKey);
|
|
23
|
+
export const llmEngineApiKey = {
|
|
24
|
+
[LlmEngine.openrouter]: LlmApiKey.OPENROUTER_KEY,
|
|
25
|
+
[LlmEngine.zai]: LlmApiKey.Z_AI_KEY,
|
|
26
|
+
[LlmEngine.hf]: LlmApiKey.HF_TOKEN,
|
|
27
|
+
[LlmEngine.nvidia]: LlmApiKey.NVIDIA_API_KEY,
|
|
28
|
+
[LlmEngine.deepseek]: LlmApiKey.DEEP_SEEK_API_KEY,
|
|
29
|
+
[LlmEngine.claude]: LlmApiKey.ANTHROPIC_API_KEY,
|
|
30
|
+
[LlmEngine.chatgpt]: LlmApiKey.OPENAI_API_KEY
|
|
31
|
+
};
|
|
23
32
|
export const stripPresetSecrets = (presets = []) => presets.map(({ config, ...preset }) => {
|
|
24
33
|
const { apiKeys, ...rest } = config || {};
|
|
25
34
|
return { ...preset, config: rest };
|
|
@@ -34,8 +43,8 @@ const invalid = (reason) => {
|
|
|
34
43
|
const validateEngine = (field, value) => (value === undefined || isEngine(value)) || invalid(`invalid ${field} "${value}"`);
|
|
35
44
|
const validateOptionalString = (field, value) => (value === undefined || typeof value === 'string') || invalid(`${field} must be a string`);
|
|
36
45
|
const validateOptionalBoolean = (field, value) => (value === undefined || typeof value === 'boolean') || invalid(`${field} must be a boolean`);
|
|
37
|
-
const
|
|
38
|
-
invalid(
|
|
46
|
+
const validateReviewerList = (field, value) => (value === undefined || (Array.isArray(value) && value.every(isReviewer))) ||
|
|
47
|
+
invalid(`${field} must be a list of "engine" or "engine:model"`);
|
|
39
48
|
const validateApiKeys = (apiKeys) => (apiKeys === undefined ||
|
|
40
49
|
(isStringRecord(apiKeys) &&
|
|
41
50
|
Object.entries(apiKeys).every(([key, value]) => llmApiKeys.includes(key) && typeof value === 'string'))) || invalid('apiKeys contains an unknown key or non-string value');
|
|
@@ -45,7 +54,8 @@ const validateConfig = (config) => {
|
|
|
45
54
|
validateEngine('fixEngine', config.fixEngine);
|
|
46
55
|
validateOptionalString('model', config.model);
|
|
47
56
|
validateOptionalString('fixModel', config.fixModel);
|
|
48
|
-
|
|
57
|
+
validateReviewerList('reviewers', config.reviewers);
|
|
58
|
+
validateReviewerList('pdfConversion', config.pdfConversion);
|
|
49
59
|
validateApiKeys(config.apiKeys);
|
|
50
60
|
};
|
|
51
61
|
const validatePreset = (preset) => {
|
|
@@ -6,7 +6,7 @@ export declare enum LlmEngine {
|
|
|
6
6
|
hf = "hf",
|
|
7
7
|
nvidia = "nvidia",
|
|
8
8
|
deepseek = "deepseek",
|
|
9
|
-
|
|
9
|
+
chatgpt = "chatgpt"
|
|
10
10
|
}
|
|
11
11
|
export declare enum LlmApiKey {
|
|
12
12
|
OPENROUTER_KEY = "OPENROUTER_KEY",
|
|
@@ -18,11 +18,13 @@ export declare enum LlmApiKey {
|
|
|
18
18
|
OPENAI_API_KEY = "OPENAI_API_KEY"
|
|
19
19
|
}
|
|
20
20
|
export declare const llmApiKeys: LlmApiKey[];
|
|
21
|
+
export declare const llmEngineApiKey: Partial<Record<LlmEngine, LlmApiKey>>;
|
|
21
22
|
export type LlmReviewer = LlmEngine | `${LlmEngine}:${string}`;
|
|
22
23
|
export interface LlmPresetConfig {
|
|
23
24
|
engine?: LlmEngine;
|
|
24
25
|
model?: string;
|
|
25
26
|
reviewers?: LlmReviewer[];
|
|
27
|
+
pdfConversion?: LlmReviewer[];
|
|
26
28
|
fixEngine?: LlmEngine;
|
|
27
29
|
fixModel?: string;
|
|
28
30
|
apiKeys?: Partial<Record<LlmApiKey, string>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateLlmPresets = exports.stripPresetSecrets = exports.llmApiKeys = exports.LlmApiKey = exports.LlmEngine = void 0;
|
|
3
|
+
exports.validateLlmPresets = exports.stripPresetSecrets = exports.llmEngineApiKey = exports.llmApiKeys = exports.LlmApiKey = exports.LlmEngine = void 0;
|
|
4
4
|
var LlmEngine;
|
|
5
5
|
(function (LlmEngine) {
|
|
6
6
|
LlmEngine["claude"] = "claude";
|
|
@@ -10,7 +10,7 @@ var LlmEngine;
|
|
|
10
10
|
LlmEngine["hf"] = "hf";
|
|
11
11
|
LlmEngine["nvidia"] = "nvidia";
|
|
12
12
|
LlmEngine["deepseek"] = "deepseek";
|
|
13
|
-
LlmEngine["
|
|
13
|
+
LlmEngine["chatgpt"] = "chatgpt";
|
|
14
14
|
})(LlmEngine || (exports.LlmEngine = LlmEngine = {}));
|
|
15
15
|
var LlmApiKey;
|
|
16
16
|
(function (LlmApiKey) {
|
|
@@ -23,6 +23,15 @@ var LlmApiKey;
|
|
|
23
23
|
LlmApiKey["OPENAI_API_KEY"] = "OPENAI_API_KEY";
|
|
24
24
|
})(LlmApiKey || (exports.LlmApiKey = LlmApiKey = {}));
|
|
25
25
|
exports.llmApiKeys = Object.values(LlmApiKey);
|
|
26
|
+
exports.llmEngineApiKey = {
|
|
27
|
+
[LlmEngine.openrouter]: LlmApiKey.OPENROUTER_KEY,
|
|
28
|
+
[LlmEngine.zai]: LlmApiKey.Z_AI_KEY,
|
|
29
|
+
[LlmEngine.hf]: LlmApiKey.HF_TOKEN,
|
|
30
|
+
[LlmEngine.nvidia]: LlmApiKey.NVIDIA_API_KEY,
|
|
31
|
+
[LlmEngine.deepseek]: LlmApiKey.DEEP_SEEK_API_KEY,
|
|
32
|
+
[LlmEngine.claude]: LlmApiKey.ANTHROPIC_API_KEY,
|
|
33
|
+
[LlmEngine.chatgpt]: LlmApiKey.OPENAI_API_KEY
|
|
34
|
+
};
|
|
26
35
|
const stripPresetSecrets = (presets = []) => presets.map(({ config, ...preset }) => {
|
|
27
36
|
const { apiKeys, ...rest } = config || {};
|
|
28
37
|
return { ...preset, config: rest };
|
|
@@ -38,8 +47,8 @@ const invalid = (reason) => {
|
|
|
38
47
|
const validateEngine = (field, value) => (value === undefined || isEngine(value)) || invalid(`invalid ${field} "${value}"`);
|
|
39
48
|
const validateOptionalString = (field, value) => (value === undefined || typeof value === 'string') || invalid(`${field} must be a string`);
|
|
40
49
|
const validateOptionalBoolean = (field, value) => (value === undefined || typeof value === 'boolean') || invalid(`${field} must be a boolean`);
|
|
41
|
-
const
|
|
42
|
-
invalid(
|
|
50
|
+
const validateReviewerList = (field, value) => (value === undefined || (Array.isArray(value) && value.every(isReviewer))) ||
|
|
51
|
+
invalid(`${field} must be a list of "engine" or "engine:model"`);
|
|
43
52
|
const validateApiKeys = (apiKeys) => (apiKeys === undefined ||
|
|
44
53
|
(isStringRecord(apiKeys) &&
|
|
45
54
|
Object.entries(apiKeys).every(([key, value]) => exports.llmApiKeys.includes(key) && typeof value === 'string'))) || invalid('apiKeys contains an unknown key or non-string value');
|
|
@@ -49,7 +58,8 @@ const validateConfig = (config) => {
|
|
|
49
58
|
validateEngine('fixEngine', config.fixEngine);
|
|
50
59
|
validateOptionalString('model', config.model);
|
|
51
60
|
validateOptionalString('fixModel', config.fixModel);
|
|
52
|
-
|
|
61
|
+
validateReviewerList('reviewers', config.reviewers);
|
|
62
|
+
validateReviewerList('pdfConversion', config.pdfConversion);
|
|
53
63
|
validateApiKeys(config.apiKeys);
|
|
54
64
|
};
|
|
55
65
|
const validatePreset = (preset) => {
|