halbot 1993.2.6 → 1993.2.8

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/index.mjs CHANGED
@@ -36,20 +36,6 @@ const init = async (options) => {
36
36
  ]);
37
37
  let embedding;
38
38
  // init ai engines
39
- if (options?.googleApiKey) {
40
- await alan.init({
41
- provider: 'GEMINI', apiKey: options?.googleApiKey,
42
- model: options?.geminiModel, // only support custom model while initiating
43
- ...options || {},
44
- });
45
- ai['Gemini'] = {
46
- engine: 'GEMINI', priority: options?.geminiPriority || 0,
47
- };
48
- engines['GEMINI'] = {
49
- // save for reference not for prompting
50
- model: options?.geminiModel,
51
- };
52
- }
53
39
  if (options?.openaiApiKey || options?.chatGptApiKey) {
54
40
  await alan.init({
55
41
  provider: 'OPENAI',
@@ -57,13 +43,27 @@ const init = async (options) => {
57
43
  ...options || {},
58
44
  });
59
45
  ai['ChatGPT'] = {
60
- engine: 'CHATGPT', priority: options?.chatGptPriority || 1,
46
+ engine: 'CHATGPT', priority: options?.chatGptPriority || 0,
61
47
  };
62
48
  engines['CHATGPT'] = {
63
49
  // only support custom model while prompting
64
50
  model: options?.chatGptModel,
65
51
  };
66
52
  }
53
+ if (options?.googleApiKey) {
54
+ await alan.init({
55
+ provider: 'GEMINI', apiKey: options?.googleApiKey,
56
+ model: options?.geminiModel, // only support custom model while initiating
57
+ ...options || {},
58
+ });
59
+ ai['Gemini'] = {
60
+ engine: 'GEMINI', priority: options?.geminiPriority || 1,
61
+ };
62
+ engines['GEMINI'] = {
63
+ // save for reference not for prompting
64
+ model: options?.geminiModel,
65
+ };
66
+ }
67
67
  if (options?.claudeApiKey) {
68
68
  await alan.init({
69
69
  provider: 'CLAUDE', apiKey: options?.claudeApiKey,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "halbot",
3
3
  "description": "Just another `ChatGPT` / `Gemini` / `Mistral (by ollama)` Telegram bob, which is simple design, easy to use, extendable and fun.",
4
- "version": "1993.2.6",
4
+ "version": "1993.2.8",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -47,12 +47,12 @@
47
47
  "mysql2": "^3.12.0",
48
48
  "office-text-extractor": "^3.0.3",
49
49
  "ollama": "^0.5.11",
50
- "openai": "^4.77.3",
50
+ "openai": "^4.77.4",
51
51
  "pg": "^8.13.1",
52
52
  "pgvector": "^0.2.0",
53
53
  "telegraf": "^4.16.3",
54
54
  "tesseract.js": "^6.0.0",
55
- "utilitas": "^1998.1.8",
55
+ "utilitas": "^1998.1.10",
56
56
  "youtube-transcript": "^1.2.1"
57
57
  }
58
58
  }
@@ -5,6 +5,7 @@ const NAME_HACK = {
5
5
  };
6
6
 
7
7
  const NAME_HACK_REVERSE = utilitas.reverseKeyValues(NAME_HACK);
8
+ const AI_CMD = '/set --ai=';
8
9
 
9
10
  let configuredAi;
10
11
 
@@ -14,9 +15,11 @@ const action = async (ctx, next) => {
14
15
  k => [k, ctx._.ai[k].priority]
15
16
  ).sort((x, y) => x[1] - y[1]);
16
17
  ctx.firstAi = arrSort[0][0];
17
- if (ctx.carry?.keyboards?.length) {
18
+ if (ctx.carry?.keyboards?.length && !ctx.carry.keyboards.find(
19
+ x => x.find(y => y.text.includes(AI_CMD))
20
+ )) {
18
21
  ctx.carry.keyboards.unshift(configuredAi.slice(0, 3).map(
19
- x => ({ text: `/set --ai=${NAME_HACK[x] || x}` })
22
+ x => ({ text: `${AI_CMD}${NAME_HACK[x] || x}` })
20
23
  ));
21
24
  }
22
25
  switch (ctx.session.config?.ai) {