halbot 1993.2.56 → 1993.2.57

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "halbot",
3
3
  "description": "Just another `ChatGPT` / `Gemini` / `Ollama` Telegram bob, which is simple design, easy to use, extendable and fun.",
4
- "version": "1993.2.56",
4
+ "version": "1993.2.57",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  "pgvector": "^0.2.0",
52
52
  "telegraf": "^4.16.3",
53
53
  "tesseract.js": "^6.0.0",
54
- "utilitas": "^1999.1.6",
54
+ "utilitas": "^1999.1.8",
55
55
  "youtube-transcript": "^1.2.1"
56
56
  }
57
57
  }
@@ -35,8 +35,8 @@ const action = async (ctx, next) => {
35
35
  }
36
36
  // prompt
37
37
  await checkUnsupportedMimeType(ctx);
38
- const maxInputTokens = alan.getMaxChatPromptLimit()
39
- - alan.ATTACHMENT_TOKEN_COST * ctx.carry.attachments.length;
38
+ const maxInputTokens = await alan.getChatPromptLimit()
39
+ - await alan.getChatAttachmentCost() * ctx.carry.attachments.length;
40
40
  const additionInfo = ctx.collected.filter(
41
41
  x => String.isString(x.content)
42
42
  ).map(x => x.content).join('\n').split(' ').filter(x => x);
@@ -1,4 +1,4 @@
1
- import { alan, bot, utilitas } from 'utilitas';
1
+ import { alan, bot, storage, utilitas } from 'utilitas';
2
2
 
3
3
  const onProgress = { onProgress: true };
4
4
  const [joinL1, joinL2] = [a => a.join(LN2), a => a.join(LN2)];
@@ -12,8 +12,9 @@ const [BOT, BOTS, LN2] = [`${bot.EMOJI_BOT} `, {
12
12
 
13
13
  const action = async (ctx, next) => {
14
14
  if (!ctx.prompt && !ctx.carry.attachments.length) { return await next(); }
15
- const [YOU, msgs, tts, rsm, pms, extra, firstResp]
16
- = [`${ctx.avatar} You:`, {}, {}, {}, [], { buttons: [] }, Date.now()];
15
+ const [YOU, msgs, tts, rsm, pms, extra, firstResp, images] = [
16
+ `${ctx.avatar} You:`, {}, {}, {}, [], { buttons: [] }, Date.now(), []
17
+ ];
17
18
  let [lastMsg, lastSent, references, audio] = [null, 0, null, null];
18
19
  const packMsg = options => {
19
20
  const said = !options?.tts && ctx.result ? ctx.result : '';
@@ -69,6 +70,10 @@ const action = async (ctx, next) => {
69
70
  && !msgs[ai].split('\n').some(x => /^\s*```/.test(x))
70
71
  ? resp.spoken : '';
71
72
  rsm[ai] = resp.model;
73
+ for (let img of resp?.images || []) {
74
+ await ctx.image(img.data, { caption: `🎨 by ${resp.model}` });
75
+ await ctx.timeout();
76
+ }
72
77
  return resp;
73
78
  } catch (err) {
74
79
  msgs[ai] = `⚠️ ${err?.message || err}`;