@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
- .run("@hf/thebloke/orca-2-13b-awq", {
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
- .run("@hf/thebloke/orca-2-13b-awq", {
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
  })
@@ -19,6 +19,7 @@ export declare class Config {
19
19
  ai: any;
20
20
  db: any;
21
21
  r2: any;
22
+ chat_model: string;
22
23
  constructor(config?: Partial<Config>);
23
24
  }
24
25
  export declare const localhost: URL;
@@ -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");
@@ -10,6 +10,7 @@ interface Environment {
10
10
  AI: string;
11
11
  DB: D1Database;
12
12
  R2: R2Bucket;
13
+ CHAT_MODEL: string;
13
14
  }
14
15
  declare const _default: {
15
16
  fetch: (request: Request, env: Environment) => Promise<Response>;
@@ -29,6 +29,7 @@ export default {
29
29
  ai: env.AI,
30
30
  db: env.DB,
31
31
  r2: env.R2,
32
+ chat_model: env.CHAT_MODEL,
32
33
  },
33
34
  {
34
35
  bot_name: "@duckduckbot",
package/package.json CHANGED
@@ -1,45 +1,48 @@
1
1
  {
2
- "name": "@codebam/cf-workers-telegram-bot",
3
- "version": "5.15.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.20240320.1",
33
- "@typescript-eslint/eslint-plugin": "^7.4.0",
34
- "@typescript-eslint/parser": "^7.4.0",
35
- "eslint": "^8.57.0",
36
- "eslint-config-prettier": "^9.1.0",
37
- "lerna": "^8.1.2",
38
- "prettier": "^3.2.5",
39
- "typescript": "^5.4.3"
40
- },
41
- "dependencies": {
42
- "@cloudflare/ai": "1.0.53"
43
- },
44
- "gitHead": "f590f9423dda46b7b591d8344c13504f6fa69d6e"
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
  }