@codebam/cf-workers-telegram-bot 5.15.0 → 5.16.0
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.
|
@@ -9,6 +9,7 @@ export default class TelegramBot extends TelegramApi {
|
|
|
9
9
|
db: D1Database;
|
|
10
10
|
r2: R2Bucket;
|
|
11
11
|
bot_name: string;
|
|
12
|
+
chat_model: string;
|
|
12
13
|
constructor(config: Config);
|
|
13
14
|
translate: (update: TelegramUpdate, args: string[]) => Promise<Response>;
|
|
14
15
|
clear: (update: TelegramUpdate) => Promise<Response>;
|
|
@@ -11,6 +11,7 @@ export default class TelegramBot extends TelegramApi {
|
|
|
11
11
|
db;
|
|
12
12
|
r2;
|
|
13
13
|
bot_name;
|
|
14
|
+
chat_model;
|
|
14
15
|
constructor(config) {
|
|
15
16
|
super(config.commands, config.webhook, config.handler);
|
|
16
17
|
this.url = config.url;
|
|
@@ -20,6 +21,7 @@ export default class TelegramBot extends TelegramApi {
|
|
|
20
21
|
this.db = config.db;
|
|
21
22
|
this.r2 = config.r2;
|
|
22
23
|
this.bot_name = config.bot_name;
|
|
24
|
+
this.chat_model = config.chat_model;
|
|
23
25
|
}
|
|
24
26
|
// bot command: /translate
|
|
25
27
|
translate = async (update, args) => {
|
|
@@ -140,7 +142,8 @@ export default class TelegramBot extends TelegramApi {
|
|
|
140
142
|
const p = system_prompt + "[INST]" + _prompt + "[/INST]";
|
|
141
143
|
const prompt = p.slice(p.length - 4096, p.length);
|
|
142
144
|
const response = await ai
|
|
143
|
-
|
|
145
|
+
// @ts-expect-error ModelName doesn't need to be verified at build time
|
|
146
|
+
.run(this.chat_model, {
|
|
144
147
|
prompt,
|
|
145
148
|
max_tokens: 596,
|
|
146
149
|
})
|
|
@@ -224,7 +227,8 @@ export default class TelegramBot extends TelegramApi {
|
|
|
224
227
|
const p = system_prompt + "[INST]" + _prompt + "[/INST]";
|
|
225
228
|
const prompt = p.slice(p.length - 4096, p.length);
|
|
226
229
|
const response = await ai
|
|
227
|
-
|
|
230
|
+
// @ts-expect-error ModelName doesn't need to be verified at build time
|
|
231
|
+
.run(this.chat_model, {
|
|
228
232
|
prompt,
|
|
229
233
|
max_tokens: 596,
|
|
230
234
|
})
|
package/dist/main/src/types.d.ts
CHANGED
package/dist/main/src/types.js
CHANGED
|
@@ -16,6 +16,7 @@ export class Config {
|
|
|
16
16
|
db;
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
r2;
|
|
19
|
+
chat_model;
|
|
19
20
|
constructor(config = {}) {
|
|
20
21
|
this.bot_name = config.bot_name || "";
|
|
21
22
|
this.api = config.api || BotApi;
|
|
@@ -27,6 +28,7 @@ export class Config {
|
|
|
27
28
|
this.ai = config.ai;
|
|
28
29
|
this.db = config.db;
|
|
29
30
|
this.r2 = config.r2;
|
|
31
|
+
this.chat_model = config.chat_model;
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
export const localhost = new URL("http://localhost");
|
package/package.json
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
"name": "@codebam/cf-workers-telegram-bot",
|
|
3
|
+
"version": "5.16.0",
|
|
4
|
+
"description": "serverless telegram bot on cf workers",
|
|
5
|
+
"main": "./dist/main/src/main.js",
|
|
6
|
+
"module": "./dist/main/src/main.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"LICENSE_MIT",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"cloudflare",
|
|
15
|
+
"telegram",
|
|
16
|
+
"worker",
|
|
17
|
+
"webhook"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"private": false,
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc --project tsconfig.json",
|
|
23
|
+
"lint": "eslint src"
|
|
24
|
+
},
|
|
25
|
+
"author": "codebam",
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/codebam/cf-workers-telegram-bot.git"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@cloudflare/workers-types": "^4.20240502.0",
|
|
33
|
+
"@eslint/js": "^9.1.1",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
35
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
36
|
+
"eslint": "^8.56.0",
|
|
37
|
+
"eslint-config-prettier": "^9.1.0",
|
|
38
|
+
"globals": "^15.1.0",
|
|
39
|
+
"lerna": "^8.1.2",
|
|
40
|
+
"prettier": "^3.2.5",
|
|
41
|
+
"typescript": "^5.4.5",
|
|
42
|
+
"typescript-eslint": "^7.8.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@cloudflare/ai": "1.0.53"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "fb3449a1162c24d725a1cde10ea9a5b3fde0fba0"
|
|
45
48
|
}
|