apexify.js 3.3.11 → 4.0.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.
- package/README.md +183 -0
- package/dist/ai/ApexAI.d.ts +88 -8
- package/dist/ai/ApexAI.d.ts.map +1 -1
- package/dist/ai/ApexAI.js +61 -161
- package/dist/ai/ApexAI.js.map +1 -1
- package/dist/ai/direct-use.d.ts +9 -0
- package/dist/ai/direct-use.d.ts.map +1 -0
- package/dist/ai/direct-use.js +572 -0
- package/dist/ai/direct-use.js.map +1 -0
- package/dist/ai/functions/Gemini.d.ts +6 -0
- package/dist/ai/functions/Gemini.d.ts.map +1 -0
- package/dist/ai/functions/Gemini.js +103 -0
- package/dist/ai/functions/Gemini.js.map +1 -0
- package/dist/ai/functions/draw.d.ts +2 -1
- package/dist/ai/functions/draw.d.ts.map +1 -1
- package/dist/ai/functions/draw.js +476 -102
- package/dist/ai/functions/draw.js.map +1 -1
- package/dist/ai/functions/generateVoiceResponse.d.ts +3 -1
- package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -1
- package/dist/ai/functions/generateVoiceResponse.js +29 -18
- package/dist/ai/functions/generateVoiceResponse.js.map +1 -1
- package/dist/ai/functions/typeWriter.d.ts +1 -1
- package/dist/ai/functions/typeWriter.d.ts.map +1 -1
- package/dist/ai/functions/typeWriter.js +3 -2
- package/dist/ai/functions/typeWriter.js.map +1 -1
- package/dist/ai/functions/validOptions.d.ts +10 -0
- package/dist/ai/functions/validOptions.d.ts.map +1 -0
- package/dist/ai/functions/validOptions.js +130 -0
- package/dist/ai/functions/validOptions.js.map +1 -0
- package/dist/ai/modals-chat/Gemini-flash.d.ts +6 -0
- package/dist/ai/modals-chat/Gemini-flash.d.ts.map +1 -0
- package/dist/ai/modals-chat/Gemini-flash.js +111 -0
- package/dist/ai/modals-chat/Gemini-flash.js.map +1 -0
- package/dist/ai/modals-chat/Gemini-pro.d.ts +6 -0
- package/dist/ai/modals-chat/Gemini-pro.d.ts.map +1 -0
- package/dist/ai/modals-chat/Gemini-pro.js +96 -0
- package/dist/ai/modals-chat/Gemini-pro.js.map +1 -0
- package/dist/ai/modals-chat/apexChat.d.ts +2 -0
- package/dist/ai/modals-chat/apexChat.d.ts.map +1 -0
- package/dist/ai/modals-chat/apexChat.js +33 -0
- package/dist/ai/modals-chat/apexChat.js.map +1 -0
- package/dist/ai/modals-chat/config.d.ts +5 -0
- package/dist/ai/modals-chat/config.d.ts.map +1 -0
- package/dist/ai/modals-chat/config.js +13 -0
- package/dist/ai/modals-chat/config.js.map +1 -0
- package/dist/ai/modals-chat/facebook-ai.d.ts +2 -0
- package/dist/ai/modals-chat/facebook-ai.d.ts.map +1 -0
- package/dist/ai/modals-chat/facebook-ai.js +21 -0
- package/dist/ai/modals-chat/facebook-ai.js.map +1 -0
- package/dist/ai/modals-chat/gemma.d.ts +3 -0
- package/dist/ai/modals-chat/gemma.d.ts.map +1 -0
- package/dist/ai/modals-chat/gemma.js +54 -0
- package/dist/ai/modals-chat/gemma.js.map +1 -0
- package/dist/ai/modals-chat/modals.d.ts +8 -0
- package/dist/ai/modals-chat/modals.d.ts.map +1 -0
- package/dist/ai/modals-chat/modals.js +16 -0
- package/dist/ai/modals-chat/modals.js.map +1 -0
- package/dist/ai/modals-chat/starChat.d.ts +2 -0
- package/dist/ai/modals-chat/starChat.d.ts.map +1 -0
- package/dist/ai/modals-chat/starChat.js +32 -0
- package/dist/ai/modals-chat/starChat.js.map +1 -0
- package/dist/ai/modals-chat/yi-ai.d.ts +2 -0
- package/dist/ai/modals-chat/yi-ai.d.ts.map +1 -0
- package/dist/ai/modals-chat/yi-ai.js +41 -0
- package/dist/ai/modals-chat/yi-ai.js.map +1 -0
- package/dist/ai/utils.d.ts +3 -2
- package/dist/ai/utils.d.ts.map +1 -1
- package/dist/ai/utils.js +6 -4
- package/dist/ai/utils.js.map +1 -1
- package/dist/canvas/utils/general functions.js +1 -1
- package/dist/canvas/utils/general functions.js.map +1 -1
- package/lib/ai/ApexAI.ts +215 -193
- package/lib/ai/{models.ts → direct-use.ts} +9 -12
- package/lib/ai/functions/draw.ts +479 -83
- package/lib/ai/functions/generateVoiceResponse.ts +16 -8
- package/lib/ai/functions/typeWriter.ts +4 -2
- package/lib/ai/functions/validOptions.ts +210 -0
- package/lib/ai/modals-chat/Gemini-flash.ts +108 -0
- package/lib/ai/modals-chat/Gemini-pro.ts +93 -0
- package/lib/ai/modals-chat/apexChat.ts +31 -0
- package/lib/ai/modals-chat/config.ts +11 -0
- package/lib/ai/modals-chat/facebook-ai.ts +14 -0
- package/lib/ai/modals-chat/modals.ts +8 -0
- package/lib/ai/modals-chat/starChat.ts +31 -0
- package/lib/ai/modals-chat/yi-ai.ts +40 -0
- package/lib/ai/utils.ts +3 -1
- package/lib/canvas/utils/general functions.ts +1 -1
- package/package.json +5 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export async function typeWriter(channel: any, sentence: string, speed: number, delay: number): Promise<void> {
|
|
2
|
-
|
|
1
|
+
export async function typeWriter(channel: any, sentence: string, speed: number, delay: number, buttons: any[]): Promise<void> {
|
|
2
|
+
|
|
3
|
+
sentence = sentence.trimStart();
|
|
4
|
+
const typingMessage = await channel.send({ content: sentence[0], components: buttons });
|
|
3
5
|
let typedSentence = typingMessage.content;
|
|
4
6
|
let i = 1;
|
|
5
7
|
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
export type ImageModals =
|
|
2
|
+
| "animagineXLV3_v30.safetensors [75f2f05b]"
|
|
3
|
+
| "dreamshaperXL10_alpha2.safetensors [c8afe2ef]"
|
|
4
|
+
| "dynavisionXL_0411.safetensors [c39cc051]"
|
|
5
|
+
| "juggernautXL_v45.safetensors [e75f5471]"
|
|
6
|
+
| "realismEngineSDXL_v10.safetensors [af771c3f]"
|
|
7
|
+
| "realvisxlV40.safetensors [f7fdcb51]"
|
|
8
|
+
| "sd_xl_base_1.0.safetensors [be9edd61]"
|
|
9
|
+
| "sd_xl_base_1.0_inpainting_0.1.safetensors [5679a81a]"
|
|
10
|
+
| "turbovisionXL_v431.safetensors [78890989]"
|
|
11
|
+
| "3Guofeng3_v34.safetensors [50f420de]"
|
|
12
|
+
| "absolutereality_V16.safetensors [37db0fc3]"
|
|
13
|
+
| "absolutereality_v181.safetensors [3d9d4d2b]"
|
|
14
|
+
| "amIReal_V41.safetensors [0a8a2e61]"
|
|
15
|
+
| "analog-diffusion-1.0.ckpt [9ca13f02]"
|
|
16
|
+
| "anythingv3_0-pruned.ckpt [2700c435]"
|
|
17
|
+
| "anything-v4.5-pruned.ckpt [65745d25]"
|
|
18
|
+
| "anythingV5_PrtRE.safetensors [893e49b9]"
|
|
19
|
+
| "AOM3A3_orangemixs.safetensors [9600da17]"
|
|
20
|
+
| "blazing_drive_v10g.safetensors [ca1c1eab]"
|
|
21
|
+
| "cetusMix_Version35.safetensors [de2f2560]"
|
|
22
|
+
| "childrensStories_v13D.safetensors [9dfaabcb]"
|
|
23
|
+
| "childrensStories_v1SemiReal.safetensors [a1c56dbb]"
|
|
24
|
+
| "childrensStories_v1ToonAnime.safetensors [2ec7b88b]"
|
|
25
|
+
| "Counterfeit_v30.safetensors [9e2a8f19]"
|
|
26
|
+
| "cuteyukimixAdorable_midchapter3.safetensors [04bdffe6]"
|
|
27
|
+
| "cyberrealistic_v33.safetensors [82b0d085]"
|
|
28
|
+
| "dalcefo_v4.safetensors [425952fe]"
|
|
29
|
+
| "deliberate_v2.safetensors [10ec4b29]"
|
|
30
|
+
| "deliberate_v3.safetensors [afd9d2d4]"
|
|
31
|
+
| "dreamlike-anime-1.0.safetensors [4520e090]"
|
|
32
|
+
| "dreamlike-diffusion-1.0.safetensors [5c9fd6e0]"
|
|
33
|
+
| "dreamlike-photoreal-2.0.safetensors [fdcf65e7]"
|
|
34
|
+
| "dreamshaper_6BakedVae.safetensors [114c8abb]"
|
|
35
|
+
| "dreamshaper_7.safetensors [5cf5ae06]"
|
|
36
|
+
| "dreamshaper_8.safetensors [9d40847d]"
|
|
37
|
+
| "edgeOfRealism_eorV20.safetensors [3ed5de15]"
|
|
38
|
+
| "EimisAnimeDiffusion_V1.ckpt [4f828a15]"
|
|
39
|
+
| "elldreths-vivid-mix.safetensors [342d9d26]"
|
|
40
|
+
| "epicrealism_naturalSinRC1VAE.safetensors [90a4c676]"
|
|
41
|
+
| "ICantBelieveItsNotPhotography_seco.safetensors [4e7a3dfd]"
|
|
42
|
+
| "juggernaut_aftermath.safetensors [5e20c455]"
|
|
43
|
+
| "lofi_v4.safetensors [ccc204d6]"
|
|
44
|
+
| "lyriel_v16.safetensors [68fceea2]"
|
|
45
|
+
| "majicmixRealistic_v4.safetensors [29d0de58]"
|
|
46
|
+
| "mechamix_v10.safetensors [ee685731]"
|
|
47
|
+
| "meinamix_meinaV9.safetensors [2ec66ab0]"
|
|
48
|
+
| "meinamix_meinaV11.safetensors [b56ce717]"
|
|
49
|
+
| "neverendingDream_v122.safetensors [f964ceeb]"
|
|
50
|
+
| "openjourney_V4.ckpt [ca2f377f]"
|
|
51
|
+
| "pastelMixStylizedAnime_pruned_fp16.safetensors [793a26e8]"
|
|
52
|
+
| "portraitplus_V1.0.safetensors [1400e684]"
|
|
53
|
+
| "protogenx34.safetensors [5896f8d5]"
|
|
54
|
+
| "Realistic_Vision_V1.4-pruned-fp16.safetensors [8d21810b]"
|
|
55
|
+
| "Realistic_Vision_V2.0.safetensors [79587710]"
|
|
56
|
+
| "Realistic_Vision_V4.0.safetensors [29a7afaa]"
|
|
57
|
+
| "Realistic_Vision_V5.0.safetensors [614d1063]"
|
|
58
|
+
| "redshift_diffusion-V10.safetensors [1400e684]"
|
|
59
|
+
| "revAnimated_v122.safetensors [3f4fefd9]"
|
|
60
|
+
| "rundiffusionFX25D_v10.safetensors [cd12b0ee]"
|
|
61
|
+
| "rundiffusionFX_v10.safetensors [cd4e694d]"
|
|
62
|
+
| "sdv1_4.ckpt [7460a6fa]"
|
|
63
|
+
| "v1-5-pruned-emaonly.safetensors [d7049739]"
|
|
64
|
+
| "v1-5-inpainting.safetensors [21c7ab71]"
|
|
65
|
+
| "shoninsBeautiful_v10.safetensors [25d8c546]"
|
|
66
|
+
| "theallys-mix-ii-churned.safetensors [5d9225a4]"
|
|
67
|
+
| "timeless-1.0.ckpt [7c4971d4]"
|
|
68
|
+
| "toonyou_beta6.safetensors [980f6b15]"
|
|
69
|
+
| "v1"
|
|
70
|
+
| "v2"
|
|
71
|
+
| "v2-beta"
|
|
72
|
+
| "v3"
|
|
73
|
+
| "lexica"
|
|
74
|
+
| "prodia"
|
|
75
|
+
| "animefy"
|
|
76
|
+
| "raava"
|
|
77
|
+
| "shonin";
|
|
78
|
+
|
|
79
|
+
export const validOptions = {
|
|
80
|
+
|
|
81
|
+
validHercaiModals: [
|
|
82
|
+
"v1",
|
|
83
|
+
"v2",
|
|
84
|
+
"v2-beta",
|
|
85
|
+
"v3",
|
|
86
|
+
"lexica",
|
|
87
|
+
"prodia",
|
|
88
|
+
"animefy",
|
|
89
|
+
"raava",
|
|
90
|
+
"shonin"
|
|
91
|
+
],
|
|
92
|
+
|
|
93
|
+
validEnhancers: [
|
|
94
|
+
"ESRGAN_4x", "Lanczos", "Nearest", "LDSR", "R-ESRGAN 4x+",
|
|
95
|
+
"R-ESRGAN 4x+ Anime6B", "ScuNET GAN", "ScuNET PSNR", "SwinIR 4x"
|
|
96
|
+
],
|
|
97
|
+
|
|
98
|
+
validSamplers: [
|
|
99
|
+
"DPM++ 2M Karras",
|
|
100
|
+
"DPM++ SDE Karras",
|
|
101
|
+
"DPM++ 2M SDE Exponential",
|
|
102
|
+
"DPM++ 2M SDE Karras",
|
|
103
|
+
"Euler a",
|
|
104
|
+
"Euler",
|
|
105
|
+
"LMS",
|
|
106
|
+
"Heun",
|
|
107
|
+
"DPM2",
|
|
108
|
+
"DPM2 a",
|
|
109
|
+
"DPM++ 2S a",
|
|
110
|
+
"DPM++ 2M",
|
|
111
|
+
"DPM++ SDE",
|
|
112
|
+
"DPM++ 2M SDE",
|
|
113
|
+
"DPM++ 2M SDE Heun",
|
|
114
|
+
"DPM++ 2M SDE Heun Karras",
|
|
115
|
+
"DPM++ 2M SDE Heun Exponential",
|
|
116
|
+
"DPM++ 3M SDE",
|
|
117
|
+
"DPM++ 3M SDE Karras",
|
|
118
|
+
"DPM++ 3M SDE Exponential",
|
|
119
|
+
"DPM fast",
|
|
120
|
+
"DPM adaptive",
|
|
121
|
+
"LMS Karras",
|
|
122
|
+
"DPM2 Karras",
|
|
123
|
+
"DPM2 a Karras",
|
|
124
|
+
"DPM++ 2S a Karras",
|
|
125
|
+
"Restart",
|
|
126
|
+
"DDIM",
|
|
127
|
+
"PLMS",
|
|
128
|
+
"UniPC"
|
|
129
|
+
],
|
|
130
|
+
|
|
131
|
+
validSXDL: [
|
|
132
|
+
"animagineXLV3_v30.safetensors [75f2f05b]",
|
|
133
|
+
"dreamshaperXL10_alpha2.safetensors [c8afe2ef]",
|
|
134
|
+
"dynavisionXL_0411.safetensors [c39cc051]",
|
|
135
|
+
"juggernautXL_v45.safetensors [e75f5471]",
|
|
136
|
+
"realismEngineSDXL_v10.safetensors [af771c3f]",
|
|
137
|
+
"realvisxlV40.safetensors [f7fdcb51]",
|
|
138
|
+
"sd_xl_base_1.0.safetensors [be9edd61]",
|
|
139
|
+
"sd_xl_base_1.0_inpainting_0.1.safetensors [5679a81a]",
|
|
140
|
+
"turbovisionXL_v431.safetensors [78890989]"
|
|
141
|
+
],
|
|
142
|
+
|
|
143
|
+
validImgStyle: [
|
|
144
|
+
"3d-model", "analog-film", "anime", "cinematic", "comic-book",
|
|
145
|
+
"digital-art", "enhance", "isometric", "fantasy-art", "isometric",
|
|
146
|
+
"line-art", "low-poly", "neon-punk", "origami", "photographic",
|
|
147
|
+
"pixel-art", "texture", "craft-clay"
|
|
148
|
+
],
|
|
149
|
+
|
|
150
|
+
validProdiaModals: [
|
|
151
|
+
"3Guofeng3_v34.safetensors [50f420de]",
|
|
152
|
+
"absolutereality_V16.safetensors [37db0fc3]",
|
|
153
|
+
"absolutereality_v181.safetensors [3d9d4d2b]",
|
|
154
|
+
"amIReal_V41.safetensors [0a8a2e61]",
|
|
155
|
+
"analog-diffusion-1.0.ckpt [9ca13f02]",
|
|
156
|
+
"anythingv3_0-pruned.ckpt [2700c435]",
|
|
157
|
+
"anything-v4.5-pruned.ckpt [65745d25]",
|
|
158
|
+
"anythingV5_PrtRE.safetensors [893e49b9]",
|
|
159
|
+
"AOM3A3_orangemixs.safetensors [9600da17]",
|
|
160
|
+
"blazing_drive_v10g.safetensors [ca1c1eab]",
|
|
161
|
+
"cetusMix_Version35.safetensors [de2f2560]",
|
|
162
|
+
"childrensStories_v13D.safetensors [9dfaabcb]",
|
|
163
|
+
"childrensStories_v1SemiReal.safetensors [a1c56dbb]",
|
|
164
|
+
"childrensStories_v1ToonAnime.safetensors [2ec7b88b]",
|
|
165
|
+
"Counterfeit_v30.safetensors [9e2a8f19]",
|
|
166
|
+
"cuteyukimixAdorable_midchapter3.safetensors [04bdffe6]",
|
|
167
|
+
"cyberrealistic_v33.safetensors [82b0d085]",
|
|
168
|
+
"dalcefo_v4.safetensors [425952fe]",
|
|
169
|
+
"deliberate_v2.safetensors [10ec4b29]",
|
|
170
|
+
"deliberate_v3.safetensors [afd9d2d4]",
|
|
171
|
+
"dreamlike-anime-1.0.safetensors [4520e090]",
|
|
172
|
+
"dreamlike-diffusion-1.0.safetensors [5c9fd6e0]",
|
|
173
|
+
"dreamlike-photoreal-2.0.safetensors [fdcf65e7]",
|
|
174
|
+
"dreamshaper_6BakedVae.safetensors [114c8abb]",
|
|
175
|
+
"dreamshaper_7.safetensors [5cf5ae06]",
|
|
176
|
+
"dreamshaper_8.safetensors [9d40847d]",
|
|
177
|
+
"edgeOfRealism_eorV20.safetensors [3ed5de15]",
|
|
178
|
+
"EimisAnimeDiffusion_V1.ckpt [4f828a15]",
|
|
179
|
+
"elldreths-vivid-mix.safetensors [342d9d26]",
|
|
180
|
+
"epicrealism_naturalSinRC1VAE.safetensors [90a4c676]",
|
|
181
|
+
"ICantBelieveItsNotPhotography_seco.safetensors [4e7a3dfd]",
|
|
182
|
+
"juggernaut_aftermath.safetensors [5e20c455]",
|
|
183
|
+
"lofi_v4.safetensors [ccc204d6]",
|
|
184
|
+
"lyriel_v16.safetensors [68fceea2]",
|
|
185
|
+
"majicmixRealistic_v4.safetensors [29d0de58]",
|
|
186
|
+
"mechamix_v10.safetensors [ee685731]",
|
|
187
|
+
"meinamix_meinaV9.safetensors [2ec66ab0]",
|
|
188
|
+
"meinamix_meinaV11.safetensors [b56ce717]",
|
|
189
|
+
"neverendingDream_v122.safetensors [f964ceeb]",
|
|
190
|
+
"openjourney_V4.ckpt [ca2f377f]",
|
|
191
|
+
"pastelMixStylizedAnime_pruned_fp16.safetensors [793a26e8]",
|
|
192
|
+
"portraitplus_V1.0.safetensors [1400e684]",
|
|
193
|
+
"protogenx34.safetensors [5896f8d5]",
|
|
194
|
+
"Realistic_Vision_V1.4-pruned-fp16.safetensors [8d21810b]",
|
|
195
|
+
"Realistic_Vision_V2.0.safetensors [79587710]",
|
|
196
|
+
"Realistic_Vision_V4.0.safetensors [29a7afaa]",
|
|
197
|
+
"Realistic_Vision_V5.0.safetensors [614d1063]",
|
|
198
|
+
"redshift_diffusion-V10.safetensors [1400e684]",
|
|
199
|
+
"revAnimated_v122.safetensors [3f4fefd9]",
|
|
200
|
+
"rundiffusionFX25D_v10.safetensors [cd12b0ee]",
|
|
201
|
+
"rundiffusionFX_v10.safetensors [cd4e694d]",
|
|
202
|
+
"sdv1_4.ckpt [7460a6fa]",
|
|
203
|
+
"v1-5-pruned-emaonly.safetensors [d7049739]",
|
|
204
|
+
"v1-5-inpainting.safetensors [21c7ab71]",
|
|
205
|
+
"shoninsBeautiful_v10.safetensors [25d8c546]",
|
|
206
|
+
"theallys-mix-ii-churned.safetensors [5d9225a4]",
|
|
207
|
+
"timeless-1.0.ckpt [7c4971d4]",
|
|
208
|
+
"toonyou_beta6.safetensors [980f6b15]",
|
|
209
|
+
]
|
|
210
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import config from './config';
|
|
5
|
+
import { converter } from "../../canvas/utils/general functions";
|
|
6
|
+
|
|
7
|
+
let currentApiKeyIndex = 0;
|
|
8
|
+
|
|
9
|
+
export async function geminiFlash(message: any, AI: { AiPersonality: string | null, userMsg: string, API_KEY: string | null }): Promise<any> {
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const genAI = new GoogleGenerativeAI(AI.API_KEY || config.apiKeys[currentApiKeyIndex]);
|
|
13
|
+
|
|
14
|
+
let personalityString: string = '';
|
|
15
|
+
if (AI.AiPersonality) {
|
|
16
|
+
const personalityFilePath = path.join(process.cwd(), AI.AiPersonality);
|
|
17
|
+
const personalityContent = fs.readFileSync(personalityFilePath, 'utf-8');
|
|
18
|
+
personalityString = personalityContent.split('\n').join(' ');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const generationConfig = {
|
|
22
|
+
maxOutputTokens: 750,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const systemInstruction = `You are an ai bot in discord replying to ${message.author.globalName || message.author.username } at ${message.channel.name}.`;
|
|
26
|
+
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest", systemInstruction, generationConfig});
|
|
27
|
+
|
|
28
|
+
const chat = model.startChat({
|
|
29
|
+
history: [
|
|
30
|
+
{
|
|
31
|
+
role: "user",
|
|
32
|
+
parts: [{ text: `${personalityString}\n And working on discord in serverName: ${message.guild.name} at channelName: ${message.channel.name} and responding to the userName: ${message.author.username}` }],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
role: "model",
|
|
36
|
+
parts: [{ text: `I will greet the user with their name: <@${message.author.id}>. Feel feel free to ask me anything! 😊`,
|
|
37
|
+
}],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
role: "model",
|
|
41
|
+
parts: [{ text: `Any question regarding JEDI STUDIO, verse.db, apexify.js or djs-builder, You should reply with to visit documentation online on jedi-studio.com and to know the developers of it are 8 people and their leader name is marco and ceo/founder is kimo`,
|
|
42
|
+
}],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
role: "model",
|
|
46
|
+
parts: [{ text: `Any question regarding how you have been developed or programed you must say u have been made by jedi-studio under the development of jedi.tsx one of the CEO for JEDI STUDIO`,
|
|
47
|
+
}],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
role: "model",
|
|
51
|
+
parts: [{ text: `Any question about verse.db it is a database that enables user to manage data for SQL, JSON, YAML and SQOL whic is made new brand by jedi studion and sool will support more database managament with comperhensive features and secure`,
|
|
52
|
+
}],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
generationConfig
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const attachment = message.attachments?.first();
|
|
59
|
+
const imgURL = attachment?.url || null;
|
|
60
|
+
let result: any;
|
|
61
|
+
|
|
62
|
+
if (imgURL) {
|
|
63
|
+
const imageData = await urlToBase64(imgURL)
|
|
64
|
+
const image = {
|
|
65
|
+
inlineData: {
|
|
66
|
+
data: imageData,
|
|
67
|
+
mimeType: "image/png",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
result = await chat.sendMessage([AI.userMsg, image]);
|
|
71
|
+
} else {
|
|
72
|
+
result = await chat.sendMessage(AI.userMsg);
|
|
73
|
+
}
|
|
74
|
+
const response = result.response;
|
|
75
|
+
|
|
76
|
+
return response.text()
|
|
77
|
+
} catch (e: any) {
|
|
78
|
+
if (e.message) {
|
|
79
|
+
if (e.message === '[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent: [400 Bad Request] User location is not supported for the API use.') {
|
|
80
|
+
return `<${message.author.id}> your location isn't supported by gemini AI.`;
|
|
81
|
+
} else if (e.response && e.response.status === 429) {
|
|
82
|
+
currentApiKeyIndex++;
|
|
83
|
+
if (currentApiKeyIndex < config.apiKeys.length) {
|
|
84
|
+
return geminiFlash(message, { ...AI, API_KEY: config.apiKeys[currentApiKeyIndex] });
|
|
85
|
+
} else {
|
|
86
|
+
return 'Ai is on a cooldown for the rest of the day. Either provide your API key or wait for tomorrow. Check ai.google.dev for apikeys';
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
return `Try again later please... Either API is on a cooldown or an internal server error has occurred. If issue persists please contact the bot developer or owner of the npm package.`;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
console.error(e);
|
|
93
|
+
return 'An unknown error has occurred.';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function urlToBase64(imageURL: string) {
|
|
99
|
+
try {
|
|
100
|
+
const convertedBuffer = await converter(imageURL, 'png');
|
|
101
|
+
|
|
102
|
+
const base64String = convertedBuffer.toString('base64');
|
|
103
|
+
return base64String;
|
|
104
|
+
} catch (error: any) {
|
|
105
|
+
throw new Error(`Failed to fetch and convert the image: ${error.message}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import config from './config';
|
|
5
|
+
import { converter } from "../../canvas/utils/general functions";
|
|
6
|
+
|
|
7
|
+
let currentApiKeyIndex = 0;
|
|
8
|
+
|
|
9
|
+
export async function geminiPro(message: any, AI: { AiPersonality: string | null, userMsg: string, API_KEY: string | null }): Promise<any> {
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const genAI = new GoogleGenerativeAI(AI.API_KEY || config.apiKeys[currentApiKeyIndex]);
|
|
13
|
+
|
|
14
|
+
let personalityString: string = '';
|
|
15
|
+
if (AI.AiPersonality) {
|
|
16
|
+
const personalityFilePath = path.join(process.cwd(), AI.AiPersonality);
|
|
17
|
+
const personalityContent = fs.readFileSync(personalityFilePath, 'utf-8');
|
|
18
|
+
personalityString = personalityContent.split('\n').join(' ');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const generationConfig = {
|
|
23
|
+
maxOutputTokens: 750,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const systemInstruction = `You are an ai bot in discord replying to ${message.author.globalName || message.author.username } at ${message.channel.name}.`;
|
|
27
|
+
const model = genAI.getGenerativeModel({ model: "gemini-pro", systemInstruction, generationConfig});
|
|
28
|
+
|
|
29
|
+
const chat = model.startChat({
|
|
30
|
+
history: [
|
|
31
|
+
{
|
|
32
|
+
role: "user",
|
|
33
|
+
parts: [{ text: `${personalityString}\n And working on discord in serverName: ${message.guild.name} at channelName: ${message.channel.name} and responding to the userName: ${message.author.username}` }],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
role: "model",
|
|
37
|
+
parts: [{ text: `I will greet the user with their name: <@${message.author.id}>. Feel feel free to ask me anything! 😊`,
|
|
38
|
+
}],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
generationConfig
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const attachment = message.attachments?.first();
|
|
45
|
+
const imgURL = attachment?.url || null;
|
|
46
|
+
let result: any;
|
|
47
|
+
|
|
48
|
+
if (imgURL) {
|
|
49
|
+
const imageData = await urlToBase64(imgURL)
|
|
50
|
+
const image = {
|
|
51
|
+
inlineData: {
|
|
52
|
+
data: imageData,
|
|
53
|
+
mimeType: "image/png",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
result = await chat.sendMessage([AI.userMsg, image]);
|
|
57
|
+
} else {
|
|
58
|
+
result = await chat.sendMessage(AI.userMsg);
|
|
59
|
+
}
|
|
60
|
+
const response = result.response;
|
|
61
|
+
|
|
62
|
+
return response.text()
|
|
63
|
+
} catch (e: any) {
|
|
64
|
+
if (e.message) {
|
|
65
|
+
if (e.message === '[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent: [400 Bad Request] User location is not supported for the API use.') {
|
|
66
|
+
return `<${message.author.id}> your location isn't supported by gemini AI.`;
|
|
67
|
+
} else if (e.response && e.response.status === 429) {
|
|
68
|
+
currentApiKeyIndex++;
|
|
69
|
+
if (currentApiKeyIndex < config.apiKeys.length) {
|
|
70
|
+
return geminiPro(message, { ...AI, API_KEY: config.apiKeys[currentApiKeyIndex] });
|
|
71
|
+
} else {
|
|
72
|
+
return 'Ai is on a cooldown for the rest of the day. Either provide your API key or wait for tomorrow. Check ai.google.dev for apikeys';
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
return `Try again later please... Either API is on a cooldown or an internal server error has occurred. If issue persists please contact the bot developer or owner of the npm package.`;
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
console.error(e);
|
|
79
|
+
return 'An unknown error has occurred.';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function urlToBase64(imageURL: string) {
|
|
85
|
+
try {
|
|
86
|
+
const convertedBuffer = await converter(imageURL, 'png');
|
|
87
|
+
|
|
88
|
+
const base64String = convertedBuffer.toString('base64');
|
|
89
|
+
return base64String;
|
|
90
|
+
} catch (error: any) {
|
|
91
|
+
throw new Error(`Failed to fetch and convert the image: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
export async function apexai(prompt: string) {
|
|
4
|
+
try {
|
|
5
|
+
const messages = [
|
|
6
|
+
{"role": "user", "content": `${prompt}`}
|
|
7
|
+
];
|
|
8
|
+
const formattedMessages = messages.map(message => `[${message.role}] ${message.content}`).join('\n');
|
|
9
|
+
|
|
10
|
+
const response = await axios.post(`https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1`, {
|
|
11
|
+
inputs: formattedMessages
|
|
12
|
+
}, {
|
|
13
|
+
headers: {
|
|
14
|
+
'Authorization': `Bearer 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`,
|
|
15
|
+
'Content-Type': 'application/json'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const generatedText = response.data[0].generated_text;
|
|
20
|
+
|
|
21
|
+
const lines = generatedText.split('\n').slice(1);
|
|
22
|
+
|
|
23
|
+
const output = lines.map((line: string) => line.replace(/^\[.*?\]\s*/, '')).join('\n');
|
|
24
|
+
|
|
25
|
+
return output
|
|
26
|
+
} catch (error: any) {
|
|
27
|
+
console.error('Error:', error.response.data);
|
|
28
|
+
return 'Please wait i am on cooldown.'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
apiKeys: [
|
|
3
|
+
"AIzaSyBunhAUzjzXQyVH65XKQQN098m0rn8fWjw",
|
|
4
|
+
"AIzaSyChIxxbCnWz0ZhG49ztATc0bSZI1p66MfA",
|
|
5
|
+
"AIzaSyAss2O1JDDEnPj2rGYfdiOzDeIscnwwPPw",
|
|
6
|
+
"AIzaSyDDLJnrlt_T8_NeYvmAU8XqFK7WXOxeguo",
|
|
7
|
+
"AIzaSyC4K7fWab65-Ol4g13FIdJcKAlBIJLPOgA"
|
|
8
|
+
]
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default config;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
export async function facebook_ai(prompt: string) {
|
|
4
|
+
try {
|
|
5
|
+
const response = await axios.post('https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill', { inputs: prompt }, {
|
|
6
|
+
headers: { 'Authorization': `Bearer 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` }
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
return response.data[0].generated_text;
|
|
10
|
+
} catch (error: any) {
|
|
11
|
+
console.error('Error fetching response:', error.message);
|
|
12
|
+
return 'Please wait i am on cooldown.';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { yi_34b } from "./yi-ai";
|
|
2
|
+
import { starChat } from "./starChat";
|
|
3
|
+
import { apexai } from "./apexChat";
|
|
4
|
+
import { geminiFlash } from "./Gemini-flash";
|
|
5
|
+
import { geminiPro } from "./Gemini-pro";
|
|
6
|
+
import { facebook_ai } from "./facebook-ai";
|
|
7
|
+
|
|
8
|
+
export { geminiFlash, yi_34b, facebook_ai, geminiPro, apexai, starChat };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
export async function starChat(prompt: string) {
|
|
4
|
+
const messages = [{ "role": "assistant", "content": `${prompt}` }];
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios.post('https://api-inference.huggingface.co/models/HuggingFaceH4/starchat2-15b-v0.1', {
|
|
7
|
+
inputs: JSON.stringify(messages),
|
|
8
|
+
}, {
|
|
9
|
+
headers: {
|
|
10
|
+
'Authorization': `Bearer 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`,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const chatbotReply = response.data[0];
|
|
14
|
+
|
|
15
|
+
let chatbotResponseText = chatbotReply.generated_text.replace(/^.*?\n.*?\n/, '');
|
|
16
|
+
|
|
17
|
+
if (chatbotResponseText.startsWith('[' || '{')) {
|
|
18
|
+
chatbotResponseText = JSON.parse(chatbotResponseText);
|
|
19
|
+
|
|
20
|
+
chatbotResponseText = chatbotResponseText.join(' ');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return chatbotResponseText;
|
|
24
|
+
}
|
|
25
|
+
catch (error: any) {
|
|
26
|
+
console.error('Error fetching response:', error.message);
|
|
27
|
+
return 'Please wait i am on cooldown.';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
export async function yi_34b(prompt: string) {
|
|
4
|
+
try {
|
|
5
|
+
const messages = [
|
|
6
|
+
{ "role": "user", "content": prompt }
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
const formattedMessages = messages.map(message => `[${message.role}] ${message.content}`).join('\n');
|
|
10
|
+
|
|
11
|
+
const response = await axios.post(
|
|
12
|
+
`https://api-inference.huggingface.co/models/01-ai/Yi-1.5-34B-Chat`,
|
|
13
|
+
{ inputs: formattedMessages },
|
|
14
|
+
{
|
|
15
|
+
headers: {
|
|
16
|
+
'Authorization': `Bearer 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`,
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const generatedText = response.data[0].generated_text;
|
|
23
|
+
const botIndex = generatedText.indexOf('[bot]', generatedText.indexOf('[user]'));
|
|
24
|
+
|
|
25
|
+
if (botIndex !== -1) {
|
|
26
|
+
let botResponse = generatedText.substring(botIndex);
|
|
27
|
+
const nextBotIndex = botResponse.indexOf('[bot]', 1);
|
|
28
|
+
const nextUserIndex = botResponse.indexOf('[user]', 1);
|
|
29
|
+
const endIndex = Math.min(nextBotIndex !== -1 ? nextBotIndex : botResponse.length, nextUserIndex !== -1 ? nextUserIndex : botResponse.length);
|
|
30
|
+
botResponse = botResponse.substring(0, endIndex);
|
|
31
|
+
botResponse = botResponse.substring(botResponse.indexOf('[bot]') + 5).trim();
|
|
32
|
+
return botResponse;
|
|
33
|
+
} else {
|
|
34
|
+
return generatedText;
|
|
35
|
+
}
|
|
36
|
+
} catch (error: any) {
|
|
37
|
+
console.error('Error:', error.response.data);
|
|
38
|
+
return 'Please wait, I am on cooldown.';
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/ai/utils.ts
CHANGED
|
@@ -4,9 +4,10 @@ import { toDraw } from "./functions/shouldDrawImage";
|
|
|
4
4
|
import { aiVoice } from "./functions/generateVoiceResponse";
|
|
5
5
|
import { aiImagine } from "./functions/draw";
|
|
6
6
|
import { readPdf, readTextFile } from "./functions/readFiles";
|
|
7
|
-
import { ApexChat, ApexImagine } from "./
|
|
7
|
+
import { ApexChat, ApexImagine } from "./direct-use";
|
|
8
8
|
import { typeWriter } from "./functions/typeWriter" ;
|
|
9
9
|
import { readImage } from "./functions/readImagess";
|
|
10
|
+
import { geminiPro } from "./modals-chat/Gemini-pro";
|
|
10
11
|
|
|
11
12
|
export {
|
|
12
13
|
chunkString,
|
|
@@ -20,4 +21,5 @@ export {
|
|
|
20
21
|
ApexChat,
|
|
21
22
|
ApexImagine,
|
|
22
23
|
typeWriter,
|
|
24
|
+
geminiPro,
|
|
23
25
|
};
|
|
@@ -209,7 +209,7 @@ export async function imgEffects(imagePath: string, filters: any[]) {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
const outputMimeType =
|
|
212
|
+
const outputMimeType = Jimp.MIME_PNG;
|
|
213
213
|
|
|
214
214
|
return await jimpImage.getBufferAsync(outputMimeType);
|
|
215
215
|
} catch (error: any) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apexify.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Ai and Canvas library. Supports typescript and javascript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"watch": "tsc -w",
|
|
10
10
|
"start": "node ./dist/index.js",
|
|
11
|
-
"dev": "
|
|
11
|
+
"dev": "ts-node ./lib/index.ts"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"lib",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"keywords": [
|
|
18
18
|
"manipulation",
|
|
19
|
+
"unlimited ai",
|
|
19
20
|
"node-charts",
|
|
20
21
|
"canvas-charts",
|
|
21
22
|
"pixman",
|
|
@@ -142,12 +143,13 @@
|
|
|
142
143
|
"author": "zenith-79",
|
|
143
144
|
"license": "MIT",
|
|
144
145
|
"dependencies": {
|
|
146
|
+
"@google/generative-ai": "^0.11.1",
|
|
145
147
|
"@iamtraction/google-translate": "^2.0.1",
|
|
146
148
|
"@napi-rs/canvas": "^0.1.51",
|
|
147
149
|
"api": "^6.1.1",
|
|
148
150
|
"gifencoder": "^2.0.1",
|
|
149
151
|
"hercai": "^12.2.0",
|
|
150
|
-
"jimp": "^0.
|
|
152
|
+
"jimp": "^0.3.11",
|
|
151
153
|
"pdf-parse": "^1.1.1",
|
|
152
154
|
"sharp": "^0.33.2",
|
|
153
155
|
"tesseract.js": "^5.0.5"
|