halbot 1990.1.87 → 1990.1.88

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/Bing Chat Telegram bob, which is simple design, easy to use, extendable and fun.",
4
- "version": "1990.1.87",
4
+ "version": "1990.1.88",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -33,14 +33,14 @@
33
33
  "@google-cloud/text-to-speech": "^4.2.3",
34
34
  "@google-cloud/vision": "^3.1.4",
35
35
  "@mozilla/readability": "^0.4.4",
36
- "@waylaidwanderer/chatgpt-api": "1.37",
36
+ "@waylaidwanderer/chatgpt-api": "^1.37.2",
37
37
  "csv-parse": "^5.4.0",
38
38
  "ioredis": "^5.3.2",
39
39
  "jsdom": "^22.1.0",
40
40
  "mysql2": "^3.5.2",
41
41
  "office-text-extractor": "^3.0.1",
42
42
  "telegraf": "^4.12.2",
43
- "utilitas": "^1995.0.11",
43
+ "utilitas": "^1995.0.12",
44
44
  "youtube-transcript": "^1.0.6"
45
45
  }
46
46
  }
@@ -1,8 +1,4 @@
1
- import { bot, utilitas } from 'utilitas';
2
-
3
- // https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them
4
- const countTokens = text => Math.ceil(text.split(/[^a-z0-9]/i).length * 100 / 75);
5
- const maxTokens = Math.floor(8192 * 0.6); // remaining 40% for response
1
+ import { bot, hal, utilitas } from 'utilitas';
6
2
 
7
3
  const action = async (ctx, next) => {
8
4
  // avatar
@@ -24,7 +20,8 @@ const action = async (ctx, next) => {
24
20
  x => x.content
25
21
  ).join('\n').split(' ') : [];
26
22
  ctx.prompt = (ctx.text || '') + '\n\n';
27
- while (countTokens(ctx.prompt) < maxTokens && additionInfo.length) {
23
+ while (hal.countTokens(ctx.prompt) < hal.MAX_PROMPT_TOKENS
24
+ && additionInfo.length) {
28
25
  ctx.prompt += ` ${additionInfo.shift()}`;
29
26
  }
30
27
  ctx.prompt = utilitas.trim(ctx.prompt);