halbot 1990.1.118 → 1990.1.119
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 +19 -4
- package/index.mjs +24 -10
- package/package.json +1 -1
- package/skills/10_engine.mjs +4 -1
package/README.md
CHANGED
|
@@ -67,26 +67,41 @@ All supported configuration fields:
|
|
|
67
67
|
// REQUIRED, string.
|
|
68
68
|
"telegramToken": "[[Telegram Bot API Token]]",
|
|
69
69
|
|
|
70
|
-
// OPTIONAL, string.
|
|
71
70
|
// Set some of these fields if you need ChatGPT features.
|
|
71
|
+
// OPTIONAL, string.
|
|
72
72
|
"openaiApiKey": "[[OpenAI API Key]]",
|
|
73
|
+
// OPTIONAL, string.
|
|
73
74
|
"openaiEndpoint": "[[Custom OpenAI API endpoint]]",
|
|
75
|
+
// OPTIONAL, string, default: "gpt-3.5-turbo".
|
|
74
76
|
"chatGptModel": "[[Custom ChatGPT Model ID]]",
|
|
77
|
+
// OPTIONAL, integer, default: 0.
|
|
78
|
+
"chatGptPriority": "[[Custom ChatGPT Priority]]",
|
|
75
79
|
|
|
76
|
-
// OPTIONAL, string.
|
|
77
80
|
// Set some of these fields if you need to use custom ChatGPT API.
|
|
81
|
+
// OPTIONAL, string.
|
|
78
82
|
"chatGptApiKey": "[[Custom ChatGPT API Key]]",
|
|
83
|
+
// OPTIONAL, string.
|
|
79
84
|
"chatGptEndpoint": "[[Custom ChatGPT API endpoint]]",
|
|
80
85
|
|
|
81
|
-
// OPTIONAL, string.
|
|
82
86
|
// Set this field if you need Gemini features.
|
|
87
|
+
// OPTIONAL, string.
|
|
83
88
|
"googleCredentials": "[[Google Cloud Credentials]]",
|
|
89
|
+
// OPTIONAL, string.
|
|
84
90
|
"googleProject": "[[Google Cloud Project ID]]",
|
|
91
|
+
// OPTIONAL, string, default: "gemini-pro-vision".
|
|
92
|
+
"geminiModel": "[[Custom Gemini Model ID]]",
|
|
93
|
+
// OPTIONAL, integer, default: 1.
|
|
94
|
+
"geminiPriority": "[[Custom Gemini Priority]]",
|
|
85
95
|
|
|
86
|
-
// OPTIONAL, boolean.
|
|
87
96
|
// Set this field if you need Mistral features.
|
|
97
|
+
// OPTIONAL, boolean.
|
|
88
98
|
"mistralEnabled": "[[Enable Mistral hosted by Ollama]]",
|
|
99
|
+
// OPTIONAL, string.
|
|
89
100
|
"mistralEndpoint": "[[Custom Mistral API endpoint]]",
|
|
101
|
+
// OPTIONAL, string, default: "Mistral" (Mistral 7B).
|
|
102
|
+
"mistralModel": "[[Custom Mistral Model ID]]",
|
|
103
|
+
// OPTIONAL, integer, default: 2.
|
|
104
|
+
"mistralPriority": "[[Custom Mistral Priority]]",
|
|
90
105
|
|
|
91
106
|
// OPTIONAL, string.
|
|
92
107
|
// Set this field if you need TTS/STT/OCR/OBJECT_DETECT features.
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { alan, bot, image, shot, speech, utilitas, vision } from 'utilitas';
|
|
2
2
|
import { parse } from 'csv-parse/sync';
|
|
3
|
-
import { end } from 'utilitas/lib/event.mjs';
|
|
4
3
|
|
|
5
4
|
await utilitas.locate(utilitas.__(import.meta.url, 'package.json'));
|
|
6
5
|
const log = content => utilitas.log(content, 'halbot');
|
|
@@ -41,8 +40,13 @@ const init = async (options) => {
|
|
|
41
40
|
provider: 'openai', ...apiKey,
|
|
42
41
|
baseURL: options?.chatGptEndpoint || options?.openaiEndpoint,
|
|
43
42
|
});
|
|
44
|
-
ai['ChatGPT'] = {
|
|
45
|
-
|
|
43
|
+
ai['ChatGPT'] = {
|
|
44
|
+
engine: 'CHATGPT', priority: options?.chatGptPriority || 0,
|
|
45
|
+
};
|
|
46
|
+
engines['CHATGPT'] = {
|
|
47
|
+
// only support custom model while prompting
|
|
48
|
+
model: options?.chatGptModel,
|
|
49
|
+
};
|
|
46
50
|
}
|
|
47
51
|
if (options?.openaiApiKey) {
|
|
48
52
|
const apiKey = { apiKey: options.openaiApiKey };
|
|
@@ -61,18 +65,28 @@ const init = async (options) => {
|
|
|
61
65
|
provider: 'VERTEX',
|
|
62
66
|
credentials: options.googleCredentials,
|
|
63
67
|
project: options.googleProject,
|
|
68
|
+
// only support custom model while initiating
|
|
69
|
+
model: options?.geminiModel,
|
|
64
70
|
});
|
|
65
|
-
ai['Gemini'] = {
|
|
66
|
-
|
|
71
|
+
ai['Gemini'] = {
|
|
72
|
+
engine: 'VERTEX', priority: options?.geminiPriority || 1,
|
|
73
|
+
};
|
|
74
|
+
engines['VERTEX'] = {
|
|
75
|
+
// save for reference not for prompting
|
|
76
|
+
model: options?.geminiModel,
|
|
77
|
+
};
|
|
67
78
|
}
|
|
68
79
|
if (options?.mistralEnabled || options?.mistralEndpoint) {
|
|
69
80
|
await alan.init({
|
|
70
|
-
provider: 'OLLAMA',
|
|
71
|
-
endpoint: options?.mistralEndpoint,
|
|
72
|
-
model: options?.mistralModel,
|
|
81
|
+
provider: 'OLLAMA', endpoint: options?.mistralEndpoint,
|
|
73
82
|
});
|
|
74
|
-
ai['Mistral'] = {
|
|
75
|
-
|
|
83
|
+
ai['Mistral'] = {
|
|
84
|
+
engine: 'OLLAMA', priority: options?.mistralPriority || 2,
|
|
85
|
+
};
|
|
86
|
+
engines['OLLAMA'] = {
|
|
87
|
+
// only support custom model while prompting
|
|
88
|
+
model: options?.mistralModel,
|
|
89
|
+
};
|
|
76
90
|
}
|
|
77
91
|
await alan.initChat({ engines, sessions: options?.storage });
|
|
78
92
|
assert(utilitas.countKeys(ai), 'No AI provider is configured.');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "halbot",
|
|
3
3
|
"description": "Just another ChatGPT/Bing Chat Telegram bob, which is simple design, easy to use, extendable and fun.",
|
|
4
|
-
"version": "1990.1.
|
|
4
|
+
"version": "1990.1.119",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/halbot",
|
|
7
7
|
"type": "module",
|
package/skills/10_engine.mjs
CHANGED
|
@@ -4,7 +4,10 @@ let configuredAi;
|
|
|
4
4
|
|
|
5
5
|
const action = async (ctx, next) => {
|
|
6
6
|
ctx.isDefaultAi = name => name === ctx.firstAi;
|
|
7
|
-
|
|
7
|
+
const arrSort = (configuredAi = Object.keys(ctx._.ai)).map(
|
|
8
|
+
k => [k, ctx._.ai[k].priority]
|
|
9
|
+
).sort((x, y) => x[1] - y[1]);
|
|
10
|
+
ctx.firstAi = arrSort[0][0];
|
|
8
11
|
switch (ctx.session.config?.ai) {
|
|
9
12
|
case '': ctx.selectedAi = [ctx.firstAi]; break;
|
|
10
13
|
case '@': ctx.selectedAi = configuredAi; break;
|