halbot 1993.2.22 → 1993.2.23

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.22",
4
+ "version": "1993.2.23",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -55,29 +55,29 @@ const action = async (ctx, next) => {
55
55
  };
56
56
  ctx.carry.threadInfo.length || await ok(onProgress);
57
57
  for (let n of ctx.selectedAi) {
58
- pms.push((async () => {
58
+ pms.push((async ai => {
59
59
  try {
60
60
  const resp = await alan.talk(ctx.prompt, {
61
- engine: ctx._.ai[n].engine, ...ctx.carry,
61
+ engine: ctx._.ai[ai].engine, ...ctx.carry,
62
62
  stream: async r => {
63
- msgs[n] = r.text;
63
+ msgs[ai] = r.text;
64
64
  ctx.carry.threadInfo.length || await ok(onProgress);
65
65
  },
66
66
  });
67
67
  references = resp.references;
68
68
  audio = resp.audio;
69
- msgs[n] = ctx.session.config?.render === false
69
+ msgs[ai] = ctx.session.config?.render === false
70
70
  ? resp.text : resp.richText;
71
- tts[n] = ctx.selectedAi.length === 1
72
- && !msgs[n].split('\n').some(x => /^\s*```/.test(x))
71
+ tts[ai] = ctx.selectedAi.length === 1
72
+ && !msgs[ai].split('\n').some(x => /^\s*```/.test(x))
73
73
  ? resp.spoken : '';
74
74
  return resp;
75
75
  } catch (err) {
76
- msgs[n] = err?.message || err;
77
- tts[n] = msgs[n];
76
+ msgs[ai] = err?.message || err;
77
+ tts[ai] = msgs[ai];
78
78
  log(err);
79
79
  }
80
- })());
80
+ })(n));
81
81
  }
82
82
  await Promise.all(pms);
83
83
  await ok({ final: true });