halbot 1990.1.91 → 1990.1.93
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/index.mjs +21 -15
- package/package.json +13 -12
- package/skills/10_engine.mjs +2 -1
- package/skills/20_instant.mjs +2 -1
- package/skills/30_wording.mjs +3 -2
- package/skills/40_image.mjs +28 -0
- package/skills/{40_prompt.mjs → 50_prompt.mjs} +3 -2
- package/skills/{50_prepare.mjs → 60_prepare.mjs} +2 -1
- package/skills/{60_chat.mjs → 70_chat.mjs} +2 -1
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bot, hal, shot, speech, utilitas, vision } from 'utilitas';
|
|
1
|
+
import { bot, hal, image, shot, speech, utilitas, vision } from 'utilitas';
|
|
2
2
|
import { parse } from 'csv-parse/sync';
|
|
3
3
|
|
|
4
4
|
await utilitas.locate(utilitas.__(import.meta.url, 'package.json'));
|
|
@@ -7,7 +7,7 @@ const skillPath = utilitas.__(import.meta.url, 'skills');
|
|
|
7
7
|
|
|
8
8
|
const promptSource = new Set([
|
|
9
9
|
// 'https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv',
|
|
10
|
-
'https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/
|
|
10
|
+
'https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/82f15563c9284c01ca54f0b915ae1aeda5a0fc3a/prompts.csv'
|
|
11
11
|
]);
|
|
12
12
|
|
|
13
13
|
const fetchPrompts = async () => {
|
|
@@ -29,20 +29,25 @@ const fetchPrompts = async () => {
|
|
|
29
29
|
|
|
30
30
|
const init = async (options) => {
|
|
31
31
|
assert(options?.telegramToken, 'Telegram Bot API Token is required.');
|
|
32
|
-
const [pkg, ai, _speech
|
|
33
|
-
|
|
32
|
+
const [pkg, ai, _speech, speechOptions]
|
|
33
|
+
= [await utilitas.which(), {}, {}, { tts: true, stt: true }];
|
|
34
|
+
const info = bot.lines([
|
|
35
|
+
`[${bot.EMOJI_BOT} ${pkg.title}](${pkg.homepage})`, pkg.description
|
|
36
|
+
]);
|
|
34
37
|
const cacheOptions = options?.storage ? { store: options.storage } : null;
|
|
35
|
-
if (options?.
|
|
36
|
-
const apiKey = { apiKey: options
|
|
37
|
-
await Promise.all([
|
|
38
|
-
speech.init({ ...apiKey, tts: true, stt: true }),
|
|
39
|
-
vision.init(apiKey),
|
|
40
|
-
]);
|
|
41
|
-
}
|
|
42
|
-
if (options?.chatGptKey) {
|
|
38
|
+
if (options?.openaiApiKey) {
|
|
39
|
+
const apiKey = { apiKey: options.openaiApiKey };
|
|
43
40
|
ai['ChatGPT'] = await hal.init({
|
|
44
|
-
provider: 'CHATGPT', clientOptions:
|
|
45
|
-
|
|
41
|
+
provider: 'CHATGPT', clientOptions: apiKey, cacheOptions,
|
|
42
|
+
});
|
|
43
|
+
await speech.init({ ...apiKey, provider: 'OPENAI', ...speechOptions });
|
|
44
|
+
await image.init(apiKey);
|
|
45
|
+
}
|
|
46
|
+
if (options?.googleApiKey) {
|
|
47
|
+
const apiKey = { apiKey: options.googleApiKey };
|
|
48
|
+
await vision.init(apiKey);
|
|
49
|
+
options?.openaiApiKey || await speech.init({
|
|
50
|
+
...apiKey, provider: 'GOOGLE', ...speechOptions,
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
53
|
if (options?.bingToken) {
|
|
@@ -67,11 +72,12 @@ const init = async (options) => {
|
|
|
67
72
|
provider: 'telegram',
|
|
68
73
|
session: options?.storage,
|
|
69
74
|
skillPath: options?.skillPath || skillPath,
|
|
70
|
-
speech: options?.googleApiKey && speech,
|
|
75
|
+
speech: (options?.openaiApiKey || options?.googleApiKey) && speech,
|
|
71
76
|
vision: options?.googleApiKey && vision,
|
|
72
77
|
});
|
|
73
78
|
_bot._.ai = ai; // Should be an array of a map of AIs.
|
|
74
79
|
_bot._.lang = options?.lang || 'English';
|
|
80
|
+
_bot._.image = options?.openaiApiKey && image;
|
|
75
81
|
_bot._.prompts = await fetchPrompts();
|
|
76
82
|
return _bot;
|
|
77
83
|
};
|
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.
|
|
4
|
+
"version": "1990.1.93",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/halbot",
|
|
7
7
|
"type": "module",
|
|
@@ -30,21 +30,22 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
33
|
-
"@ffprobe-installer/ffprobe": "^2.1.
|
|
34
|
-
"@google-cloud/speech": "^
|
|
35
|
-
"@google-cloud/text-to-speech": "^
|
|
36
|
-
"@google-cloud/vision": "^
|
|
33
|
+
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
34
|
+
"@google-cloud/speech": "^6.1.0",
|
|
35
|
+
"@google-cloud/text-to-speech": "^5.0.1",
|
|
36
|
+
"@google-cloud/vision": "^4.0.2",
|
|
37
37
|
"@mozilla/readability": "^0.4.4",
|
|
38
|
-
"@waylaidwanderer/chatgpt-api": "^1.37.
|
|
39
|
-
"csv-parse": "^5.
|
|
38
|
+
"@waylaidwanderer/chatgpt-api": "^1.37.3",
|
|
39
|
+
"csv-parse": "^5.5.2",
|
|
40
40
|
"fluent-ffmpeg": "^2.1.2",
|
|
41
41
|
"ioredis": "^5.3.2",
|
|
42
42
|
"jsdom": "^22.1.0",
|
|
43
|
-
"mysql2": "^3.
|
|
44
|
-
"office-text-extractor": "^3.0.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
43
|
+
"mysql2": "^3.6.3",
|
|
44
|
+
"office-text-extractor": "^3.0.2",
|
|
45
|
+
"openai": "^4.17.3",
|
|
46
|
+
"telegraf": "^4.15.0",
|
|
47
|
+
"tesseract.js": "^5.0.3",
|
|
48
|
+
"utilitas": "^1995.1.14",
|
|
48
49
|
"youtube-transcript": "^1.0.6"
|
|
49
50
|
}
|
|
50
51
|
}
|
package/skills/10_engine.mjs
CHANGED
package/skills/20_instant.mjs
CHANGED
package/skills/30_wording.mjs
CHANGED
|
@@ -14,7 +14,7 @@ const promptTranslate = (ctx, lang) => execPrompt(ctx, [
|
|
|
14
14
|
// Inspired by:
|
|
15
15
|
// https://github.com/yetone/bob-plugin-openai-polisher/blob/main/src/main.js
|
|
16
16
|
const promptPolish = ctx => execPrompt(ctx, [
|
|
17
|
-
'Revise
|
|
17
|
+
'Revise the following sentences to make them more clear, concise, and coherent.',
|
|
18
18
|
'Please note that you need to list the changes and briefly explain why.',
|
|
19
19
|
]);
|
|
20
20
|
|
|
@@ -47,7 +47,8 @@ const action = async (ctx, next) => {
|
|
|
47
47
|
await next();
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export const { run, priority, func, cmds, help } = {
|
|
50
|
+
export const { name, run, priority, func, cmds, help } = {
|
|
51
|
+
name: 'Wording',
|
|
51
52
|
run: true,
|
|
52
53
|
priority: 30,
|
|
53
54
|
func: action,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { bot } from 'utilitas';
|
|
2
|
+
|
|
3
|
+
const action = async (ctx, next) => {
|
|
4
|
+
if (!ctx.cmd.args) {
|
|
5
|
+
return await ctx.ok('Please input your prompt.');
|
|
6
|
+
}
|
|
7
|
+
const objMsg = (await ctx.ok('✍️'))[0];
|
|
8
|
+
const images = await ctx._.image.generate(ctx.cmd.args, { expected: 'URL' });
|
|
9
|
+
await ctx.deleteMessage(objMsg.message_id);
|
|
10
|
+
for (let image of images) {
|
|
11
|
+
await ctx.image(image.url, { caption: image.revised_prompt });
|
|
12
|
+
await ctx.speech(image.revised_prompt);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const { name, run, priority, func, cmds, help } = {
|
|
17
|
+
name: 'Image',
|
|
18
|
+
run: true,
|
|
19
|
+
priority: 40,
|
|
20
|
+
func: action,
|
|
21
|
+
help: bot.lines([
|
|
22
|
+
'¶ Use DALL-E to generate images.',
|
|
23
|
+
'Example 1: /image a cat',
|
|
24
|
+
]),
|
|
25
|
+
cmds: {
|
|
26
|
+
image: 'Use DALL-E to generate images: /image `PROMPT`',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -59,9 +59,10 @@ const action = async (ctx, next) => {
|
|
|
59
59
|
await next();
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export const { run, priority, func, help, cmds, cmdx } = {
|
|
62
|
+
export const { name, run, priority, func, help, cmds, cmdx } = {
|
|
63
|
+
name: 'Prompt',
|
|
63
64
|
run: true,
|
|
64
|
-
priority:
|
|
65
|
+
priority: 50,
|
|
65
66
|
func: action,
|
|
66
67
|
help: bot.lines([
|
|
67
68
|
'¶ Maintain custom prompts.',
|