apexify.js 3.2.5 → 3.3.1

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.
Files changed (75) hide show
  1. package/.tsbuildinfo +1 -1
  2. package/README.md +4 -806
  3. package/change logs.md +19 -0
  4. package/dist/ai/ApexAI.d.ts +15 -6
  5. package/dist/ai/ApexAI.d.ts.map +1 -1
  6. package/dist/ai/ApexAI.js +102 -29
  7. package/dist/ai/ApexAI.js.map +1 -1
  8. package/dist/ai/buttons/tools.d.ts.map +1 -1
  9. package/dist/ai/buttons/tools.js +1 -1
  10. package/dist/ai/buttons/tools.js.map +1 -1
  11. package/dist/ai/functions/aivoice.d.ts +1 -0
  12. package/dist/ai/functions/aivoice.d.ts.map +1 -0
  13. package/dist/ai/functions/aivoice.js +2 -0
  14. package/dist/ai/functions/aivoice.js.map +1 -0
  15. package/dist/ai/functions/draw.d.ts +1 -1
  16. package/dist/ai/functions/draw.d.ts.map +1 -1
  17. package/dist/ai/functions/draw.js +12 -1
  18. package/dist/ai/functions/draw.js.map +1 -1
  19. package/dist/ai/functions/generateVoiceResponse.d.ts +1 -1
  20. package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -1
  21. package/dist/ai/functions/generateVoiceResponse.js +3 -3
  22. package/dist/ai/functions/generateVoiceResponse.js.map +1 -1
  23. package/dist/ai/models.d.ts +1 -1
  24. package/dist/ai/models.d.ts.map +1 -1
  25. package/dist/ai/models.js +46 -28
  26. package/dist/ai/models.js.map +1 -1
  27. package/dist/ai/utils.d.ts.map +1 -1
  28. package/dist/ai/utils.js.map +1 -1
  29. package/dist/canvas/ApexPainter.d.ts +10 -10
  30. package/dist/canvas/ApexPainter.d.ts.map +1 -1
  31. package/dist/canvas/ApexPainter.js +21 -26
  32. package/dist/canvas/ApexPainter.js.map +1 -1
  33. package/dist/canvas/utils/bg.d.ts +1 -2
  34. package/dist/canvas/utils/bg.d.ts.map +1 -1
  35. package/dist/canvas/utils/bg.js +2 -5
  36. package/dist/canvas/utils/bg.js.map +1 -1
  37. package/dist/canvas/utils/charts.js +26 -26
  38. package/dist/canvas/utils/charts.js.map +1 -1
  39. package/dist/canvas/utils/general functions.d.ts +7 -7
  40. package/dist/canvas/utils/general functions.d.ts.map +1 -1
  41. package/dist/canvas/utils/general functions.js +47 -52
  42. package/dist/canvas/utils/general functions.js.map +1 -1
  43. package/dist/canvas/utils/types.d.ts +1 -3
  44. package/dist/canvas/utils/types.d.ts.map +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +45 -1
  47. package/dist/index.js.map +1 -1
  48. package/lib/ai/ApexAI.ts +550 -0
  49. package/lib/ai/buttons/drawMenu.ts +361 -0
  50. package/lib/ai/buttons/tools.ts +550 -0
  51. package/lib/ai/functions/chunkString.ts +3 -0
  52. package/lib/ai/functions/draw.ts +440 -0
  53. package/lib/ai/functions/generateVoiceResponse.ts +177 -0
  54. package/lib/ai/functions/imageReader.ts +24 -0
  55. package/lib/ai/functions/readFiles.ts +34 -0
  56. package/lib/ai/functions/readImagess.ts +41 -0
  57. package/lib/ai/functions/shouldDrawImage.ts +7 -0
  58. package/lib/ai/functions/typeWriter.ts +24 -0
  59. package/lib/ai/models.ts +589 -0
  60. package/lib/ai/utils.ts +23 -0
  61. package/lib/canvas/ApexPainter.ts +572 -0
  62. package/lib/canvas/utils/bg.ts +79 -0
  63. package/lib/canvas/utils/charts.ts +524 -0
  64. package/lib/canvas/utils/circular.ts +17 -0
  65. package/lib/canvas/utils/customLines.ts +49 -0
  66. package/lib/canvas/utils/general functions.ts +434 -0
  67. package/lib/canvas/utils/imageProperties.ts +403 -0
  68. package/lib/canvas/utils/radius.ts +26 -0
  69. package/lib/canvas/utils/textProperties.ts +68 -0
  70. package/lib/canvas/utils/types.ts +417 -0
  71. package/lib/canvas/utils/utils.ts +59 -0
  72. package/lib/index.ts +38 -0
  73. package/lib/utils.ts +8 -0
  74. package/package.json +15 -2
  75. package/tsconfig.json +21 -0
@@ -0,0 +1,41 @@
1
+ import axios from "axios";
2
+
3
+ export async function readImage(imageUrl: string) {
4
+ try {
5
+ let retryCount = 0;
6
+ const maxRetries = 3;
7
+
8
+ const fetchData = async () => {
9
+ try {
10
+ const response = await axios.post("https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large", { image: imageUrl }, {
11
+ headers: {
12
+ "Content-Type": "application/json",
13
+ Authorization: "Bearer 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",
14
+ },
15
+ });
16
+
17
+ if (response.status === 200) {
18
+ return response.data[0].generated_text;
19
+ } else {
20
+ return null;
21
+ }
22
+ } catch (error: any) {
23
+ throw error.message;
24
+ }
25
+ };
26
+
27
+ while (retryCount < maxRetries) {
28
+ try {
29
+ return await fetchData();
30
+ } catch (error: any) {
31
+ retryCount++;
32
+ console.error(`Error fetching data (Retry ${retryCount}): ${error}`);
33
+ }
34
+ }
35
+
36
+ return null;
37
+ } catch (error: any) {
38
+ console.error(`Error in readImages: ${error.message}`);
39
+ return null;
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ export function toDraw(content: string, drawTrigger?: string[]): boolean {
2
+ if (!drawTrigger) {
3
+ return true;
4
+ }
5
+ const lowerContent = content.toLowerCase();
6
+ return drawTrigger.some(trigger => lowerContent.startsWith(trigger));
7
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ export async function typeWriter(channel: any, sentence: string, speed: number, delay: number): Promise<void> {
4
+ const typingMessage = await channel.send(sentence[0]);
5
+ let typedSentence = typingMessage.content;
6
+ let i = 1;
7
+
8
+ while (i < sentence.length) {
9
+ typedSentence += sentence.slice(i, i + getStepCount(speed));
10
+ await sleep(delay);
11
+ await typingMessage.edit(typedSentence);
12
+ i += getStepCount(speed);
13
+ }
14
+ }
15
+
16
+ function getStepCount(speed: number): number {
17
+ const maxSteps = 120;
18
+ const steps = Math.min(Math.ceil(speed), maxSteps);
19
+ return steps > 0 ? steps : 1;
20
+ }
21
+
22
+ function sleep(ms: number): Promise<void> {
23
+ return new Promise<void>(resolve => setTimeout(resolve, ms));
24
+ }
@@ -0,0 +1,589 @@
1
+ import { Hercai } from 'hercai';
2
+ import axios from 'axios';
3
+ import api from "api";
4
+ const sdk = api("@prodia/v1.3.0#be019b2kls0gqss3");
5
+ sdk.auth("43435e1c-cab1-493f-a224-f51e4b97ce8d");
6
+ const herc = new Hercai();
7
+ import { apexai, starChat, gemmaAi_3, gemmaAi_4, zephyr_beta } from './ApexAI';
8
+ interface ApexImagineOptions {
9
+ negative?: string;
10
+ number?: number;
11
+ nsfw?: boolean;
12
+ }
13
+ type ChatModelOption = "v3" | "v3-32k" | "turbo" | "turbo-16k" | "gemini" ;
14
+ type ImagineModelOption = "v1" | "v2" | "v2-beta" | "lexica" | "prodia" | "animefy" | "raava" | "shonin" | "v3" | "simurg";
15
+
16
+ async function ApexImagine(model: string, prompt: string, options: ApexImagineOptions): Promise<any> {
17
+ try {
18
+ const { negative = '', number, nsfw } = options;
19
+ let neg = '';
20
+ let count = 1;
21
+
22
+ if (prompt.length >= 2000) {
23
+ throw new Error('Prompt can\t be longer than 2000 characters');
24
+ }
25
+
26
+ if (negative) {
27
+ neg = `${negative}`;
28
+ }
29
+
30
+ if (number && Number.isInteger(number) && number >= 1 && number <= 4) {
31
+ count = number;
32
+ } else {
33
+ throw new Error('Invalid number parameter. It must be an integer between 1 and 4.');
34
+ }
35
+
36
+ let resultUrls: string[] = [];
37
+
38
+ const allowedModelsH = ['v1', 'v2', 'v2-beta', 'lexica', 'prodia', 'animefy', 'raava', 'shonin'];
39
+ const validProdiaModalsP = [
40
+ "3Guofeng3_v34.safetensors [50f420de]",
41
+ "absolutereality_V16.safetensors [37db0fc3]",
42
+ "absolutereality_v181.safetensors [3d9d4d2b]",
43
+ "amIReal_V41.safetensors [0a8a2e61]",
44
+ "analog-diffusion-1.0.ckpt [9ca13f02]",
45
+ "anythingv3_0-pruned.ckpt [2700c435]",
46
+ "anything-v4.5-pruned.ckpt [65745d25]",
47
+ "anythingV5_PrtRE.safetensors [893e49b9]",
48
+ "AOM3A3_orangemixs.safetensors [9600da17]",
49
+ "blazing_drive_v10g.safetensors [ca1c1eab]",
50
+ "cetusMix_Version35.safetensors [de2f2560]",
51
+ "childrensStories_v13D.safetensors [9dfaabcb]",
52
+ "childrensStories_v1SemiReal.safetensors [a1c56dbb]",
53
+ "childrensStories_v1ToonAnime.safetensors [2ec7b88b]",
54
+ "Counterfeit_v30.safetensors [9e2a8f19]",
55
+ "cuteyukimixAdorable_midchapter3.safetensors [04bdffe6]",
56
+ "cyberrealistic_v33.safetensors [82b0d085]",
57
+ "dalcefo_v4.safetensors [425952fe]",
58
+ "deliberate_v2.safetensors [10ec4b29]",
59
+ "deliberate_v3.safetensors [afd9d2d4]",
60
+ "dreamlike-anime-1.0.safetensors [4520e090]",
61
+ "dreamlike-diffusion-1.0.safetensors [5c9fd6e0]",
62
+ "dreamlike-photoreal-2.0.safetensors [fdcf65e7]",
63
+ "dreamshaper_6BakedVae.safetensors [114c8abb]",
64
+ "dreamshaper_7.safetensors [5cf5ae06]",
65
+ "dreamshaper_8.safetensors [9d40847d]",
66
+ "edgeOfRealism_eorV20.safetensors [3ed5de15]",
67
+ "EimisAnimeDiffusion_V1.ckpt [4f828a15]",
68
+ "elldreths-vivid-mix.safetensors [342d9d26]",
69
+ "epicrealism_naturalSinRC1VAE.safetensors [90a4c676]",
70
+ "ICantBelieveItsNotPhotography_seco.safetensors [4e7a3dfd]",
71
+ "juggernaut_aftermath.safetensors [5e20c455]",
72
+ "lofi_v4.safetensors [ccc204d6]",
73
+ "lyriel_v16.safetensors [68fceea2]",
74
+ "majicmixRealistic_v4.safetensors [29d0de58]",
75
+ "mechamix_v10.safetensors [ee685731]",
76
+ "meinamix_meinaV9.safetensors [2ec66ab0]",
77
+ "meinamix_meinaV11.safetensors [b56ce717]",
78
+ "neverendingDream_v122.safetensors [f964ceeb]",
79
+ "openjourney_V4.ckpt [ca2f377f]",
80
+ "pastelMixStylizedAnime_pruned_fp16.safetensors [793a26e8]",
81
+ "portraitplus_V1.0.safetensors [1400e684]",
82
+ "protogenx34.safetensors [5896f8d5]",
83
+ "Realistic_Vision_V1.4-pruned-fp16.safetensors [8d21810b]",
84
+ "Realistic_Vision_V2.0.safetensors [79587710]",
85
+ "Realistic_Vision_V4.0.safetensors [29a7afaa]",
86
+ "Realistic_Vision_V5.0.safetensors [614d1063]",
87
+ "redshift_diffusion-V10.safetensors [1400e684]",
88
+ "revAnimated_v122.safetensors [3f4fefd9]",
89
+ "rundiffusionFX25D_v10.safetensors [cd12b0ee]",
90
+ "rundiffusionFX_v10.safetensors [cd4e694d]",
91
+ "sdv1_4.ckpt [7460a6fa]",
92
+ "v1-5-pruned-emaonly.safetensors [d7049739]",
93
+ "v1-5-inpainting.safetensors [21c7ab71]",
94
+ "shoninsBeautiful_v10.safetensors [25d8c546]",
95
+ "theallys-mix-ii-churned.safetensors [5d9225a4]",
96
+ "timeless-1.0.ckpt [7c4971d4]",
97
+ "toonyou_beta6.safetensors [980f6b15]",
98
+ ];
99
+
100
+ if (allowedModelsH.includes(model)) {
101
+ for (let i = 0; i < count; i++) {
102
+ try {
103
+ const result = await herc.drawImage({ model: model as ImagineModelOption, prompt: prompt, negative_prompt: neg });
104
+ resultUrls.push(result.url);
105
+ } catch (error) {
106
+ console.error("Failed to draw image with Hercai. Retrying...", error);
107
+ }
108
+ }
109
+ } else if (validProdiaModalsP.includes(model)) {
110
+ for (let i = 0; i < count; i++) {
111
+ const generateResponse = await sdk.generate({
112
+ model: model,
113
+ prompt: prompt,
114
+ });
115
+
116
+ const generatedJobId = generateResponse.data.job;
117
+ const result = await checkJobStatus(generatedJobId);
118
+
119
+ if (result) {
120
+ resultUrls.push(result);
121
+ } else {
122
+ console.error('Invalid result format. Expected a URL.');
123
+ }
124
+ }
125
+ }
126
+
127
+ if (nsfw) {
128
+ const checkedURLs = await apexChecker(resultUrls)
129
+ const nsfwWords = [
130
+ "porn",
131
+ "sex",
132
+ "nude",
133
+ "nsfw",
134
+ "xxx",
135
+ "adult",
136
+ "vagina",
137
+ "penis",
138
+ "boobs",
139
+ "fuck",
140
+ "orgasm",
141
+ "erotic",
142
+ "naughty",
143
+ "kinky",
144
+ "sensual",
145
+ "horny",
146
+ "lust",
147
+ "sperm",
148
+ "ejaculate",
149
+ "busty",
150
+ "booty",
151
+ "striptease",
152
+ "dildo",
153
+ "vibrator",
154
+ "fetish",
155
+ "bondage",
156
+ "anal",
157
+ "oral",
158
+ "blowjob",
159
+ "cumshot",
160
+ "gangbang",
161
+ "threesome",
162
+ "orgy",
163
+ "deepthroat",
164
+ "naked",
165
+ "undress",
166
+ "cum",
167
+ "suck",
168
+ "lick",
169
+ "spank",
170
+ "masturbate",
171
+ "clitoris",
172
+ "penetration",
173
+ "swinger",
174
+ "hooker",
175
+ "prostitute",
176
+ "escort",
177
+ "cumswap",
178
+ "creampie",
179
+ "rimjob",
180
+ "squirt",
181
+ "butt",
182
+ "ass",
183
+ "slut",
184
+ "whore",
185
+ "cumming",
186
+ "rimming",
187
+ "cunnilingus",
188
+ "fellatio",
189
+ "crotch",
190
+ "groin",
191
+ "erogenous",
192
+ "labia",
193
+ "testicles",
194
+ "climax",
195
+ "thrust",
196
+ "missionary",
197
+ "doggy",
198
+ "69",
199
+ "tits",
200
+ "pussy",
201
+ "cock",
202
+ "boobies",
203
+ "boner",
204
+ "cherry",
205
+ "virgin",
206
+ "cumming",
207
+ "anal beads",
208
+ "nipple",
209
+ "stripper",
210
+ "g-string",
211
+ "thong",
212
+ "fingering",
213
+ "handjob",
214
+ "voyeur",
215
+ "orgasmic",
216
+ "nudity",
217
+ "sexting",
218
+ "seduction",
219
+ "lustful",
220
+ "wet",
221
+ "hardcore",
222
+ "seduce",
223
+ "dirty",
224
+ "naughty",
225
+ "erotic",
226
+ "pleasure",
227
+ "aroused",
228
+ "intimate",
229
+ "eroticism",
230
+ "foreplay",
231
+ "dominate",
232
+ "submissive",
233
+ "bdsm",
234
+ "s&m",
235
+ "masochism",
236
+ "sadism",
237
+ "bukkake",
238
+ "gangbang",
239
+ "fetish",
240
+ "orgy",
241
+ "bondage",
242
+ "golden shower",
243
+ "dirty talk",
244
+ "pillow talk",
245
+ "sex slave",
246
+ "dirty dancing",
247
+ "striptease",
248
+ "pornographic",
249
+ "adult entertainment",
250
+ "sexual intercourse",
251
+ "titillating",
252
+ "sexy",
253
+ "hot",
254
+ "erotic",
255
+ "raunchy",
256
+ "stimulation",
257
+ "climax",
258
+ "horny",
259
+ "turn-on",
260
+ "kinky",
261
+ "lustful",
262
+ "sensual",
263
+ "passionate",
264
+ "intimate",
265
+ "provocative",
266
+ "tease",
267
+ "foreplay",
268
+ "satisfy",
269
+ "pleasure",
270
+ "erogenous",
271
+ "arousal",
272
+ "lust",
273
+ "desire",
274
+ "attraction",
275
+ "libido",
276
+ "orgasm",
277
+ "bedroom",
278
+ "undress",
279
+ "naked",
280
+ "kiss",
281
+ "touch",
282
+ "petting",
283
+ "cuddle",
284
+ "spooning",
285
+ "naughty",
286
+ "dirty",
287
+ "taboo",
288
+ "forbidden",
289
+ "sinful",
290
+ "sultry",
291
+ "risqué",
292
+ "racy",
293
+ "flirt",
294
+ "seduce",
295
+ "titillate",
296
+ "arouse",
297
+ "tempt",
298
+ "stimulate",
299
+ "seduction",
300
+ "pleasure",
301
+ "ecstasy",
302
+ "passion",
303
+ "intimacy",
304
+ "sensuality",
305
+ "eroticism",
306
+ "fetish",
307
+ "fantasy",
308
+ "kink",
309
+ "role-play",
310
+ "dominance",
311
+ "submission",
312
+ "bondage",
313
+ "masochism",
314
+ "sadism",
315
+ "orgy",
316
+ "swinging",
317
+ "voyeurism",
318
+ "exhibitionism",
319
+ "cunnilingus",
320
+ "fellatio",
321
+ "69",
322
+ "blowjob",
323
+ "anal",
324
+ "doggy style",
325
+ "missionary",
326
+ "cowgirl",
327
+ "reverse cowgirl",
328
+ "threesome",
329
+ "foursome",
330
+ "gangbang",
331
+ "rimming",
332
+ "golden shower",
333
+ "facial",
334
+ "creampie",
335
+ "cumshot",
336
+ "squirting",
337
+ "masturbation",
338
+ "orgasm",
339
+ "erect",
340
+ "nipple",
341
+ "pubic",
342
+ "erection",
343
+ "ejaculation",
344
+ "clitoris",
345
+ "penetration",
346
+ "vibrator",
347
+ "dildo",
348
+ "strap-on",
349
+ "butt plug",
350
+ "anal beads",
351
+ "crotchless",
352
+ "lingerie",
353
+ "corset",
354
+ "stockings",
355
+ "garter",
356
+ "bra",
357
+ "panties",
358
+ "thong",
359
+ "G-string",
360
+ "bikini",
361
+ "lingerie",
362
+ "boudoir",
363
+ "stripper",
364
+ "exotic dancer",
365
+ "burlesque",
366
+ "pole dance",
367
+ "erotic dance",
368
+ "nude",
369
+ "topless",
370
+ "lap dance",
371
+ "strip tease",
372
+ "private dance",
373
+ "camgirl",
374
+ "porn star",
375
+ "sex worker",
376
+ "escort",
377
+ "prostitute",
378
+ "whore",
379
+ "call girl",
380
+ "hooker",
381
+ "streetwalker",
382
+ "courtesan",
383
+ "madam",
384
+ "mistress",
385
+ "dominatrix",
386
+ "submissive",
387
+ "slave",
388
+ "master",
389
+ "mistress",
390
+ "sir",
391
+ "madame",
392
+ "domina",
393
+ "domme",
394
+ "sissy",
395
+ "bottom",
396
+ "top",
397
+ "fetish",
398
+ "kink",
399
+ "leather",
400
+ "latex",
401
+ "rubber",
402
+ "bondage",
403
+ "rope",
404
+ "chain",
405
+ "spanking",
406
+ "whipping",
407
+ "caning",
408
+ "flogging",
409
+ "paddling",
410
+ "torture",
411
+ "humiliation",
412
+ "degradation",
413
+ "submission",
414
+ "dominance",
415
+ "sadism",
416
+ "masochism",
417
+ "bukkake",
418
+ "facial",
419
+ "creampie",
420
+ "cum swap",
421
+ "cum play",
422
+ "cum shot",
423
+ "gang bang",
424
+ "double penetration",
425
+ "anal sex",
426
+ "oral sex",
427
+ "rimming",
428
+ "fingering",
429
+ "gay",
430
+ "lesbian",
431
+ "niga",
432
+ "underage",
433
+ "xnxx",
434
+ "xxx",
435
+ "pornhub",
436
+ ];
437
+ for (const text of checkedURLs) {
438
+ if (nsfwWords.some(word => text.includes(word))) {
439
+ return "The generated text contains NSFW content.";
440
+ }
441
+ }
442
+
443
+ }
444
+ return resultUrls;
445
+ } catch (e: any) {
446
+ if (e.response && e.response.status === 429) {
447
+ console.error("Too many requests. Please try again later.");
448
+ return `Please wait i am in a cool down for a minute`;
449
+ } else if (e.response && e.response.status === 500) {
450
+ console.error("Internal server error. Please try again later.");
451
+ return `Please wait i am in a cool down for a minute`;
452
+ } else {
453
+ console.error(`Please wait i am in a cool down for a minute`);
454
+ return `Please wait i am in a cool down for a minute`;
455
+ }
456
+ }
457
+ }
458
+
459
+ async function checkJobStatus(jobId: string, retryCount = 3): Promise<string | null> {
460
+ try {
461
+ const getJobResponse = await sdk.getJob({ jobId: jobId });
462
+ const jobData = getJobResponse.data;
463
+
464
+ if (jobData.status === "generating" || jobData.status === "queued") {
465
+ if (retryCount > 0) {
466
+ await new Promise(resolve => setTimeout(resolve, 3000));
467
+ return checkJobStatus(jobId, retryCount - 1);
468
+ } else {
469
+ console.error("Job failed after multiple retries:", jobData);
470
+ return null;
471
+ }
472
+ } else if (jobData.status === "succeeded") {
473
+ return jobData.imageUrl;
474
+ } else {
475
+ console.error("Job failed:", jobData);
476
+ return null;
477
+ }
478
+ } catch (error) {
479
+ console.error(error);
480
+ return null;
481
+ }
482
+ }
483
+
484
+ async function ApexChat(model: string, prompt: string): Promise<string> { // Specify the return type as string
485
+ try {
486
+ if (prompt.length >= 2000) {
487
+ const chunks = [];
488
+ while (prompt.length > 0) {
489
+ chunks.push(prompt.substring(0, 2000));
490
+ prompt = prompt.substring(2000);
491
+ }
492
+
493
+ const responses = await Promise.all(chunks.map(async (chunk) => {
494
+ return await processChunk(model, chunk);
495
+ }));
496
+
497
+ return responses.join('');
498
+ } else {
499
+ return await processChunk(model, prompt);
500
+ }
501
+ } catch (error: any) {
502
+ console.error(error.message);
503
+ return '';
504
+ }
505
+ }
506
+
507
+ async function processChunk(model: string, prompt: string): Promise<string> {
508
+ let response: string;
509
+
510
+ switch (model) {
511
+ case 'v3':
512
+ case 'v3-32k':
513
+ case 'turbo':
514
+ case 'turbo-16k':
515
+ case 'gemini':
516
+ response = (await herc.question({ model: model as ChatModelOption, content: prompt })).reply;
517
+ break;
518
+ case 'apexChat':
519
+ response = await apexai(prompt);
520
+ break;
521
+ case 'gemma-v3':
522
+ response = await gemmaAi_3(prompt);
523
+ break;
524
+ case 'gemma-v4':
525
+ response = await gemmaAi_4(prompt);
526
+ break;
527
+ case 'starChat':
528
+ response = await starChat(prompt);
529
+ break;
530
+ case 'zephyr-beta':
531
+ response = await zephyr_beta(prompt);
532
+ break;
533
+ default:
534
+ throw new Error('Invalid model.');
535
+ }
536
+ return response;
537
+ }
538
+
539
+ async function apexChecker(urls: any) {
540
+ try {
541
+ let retryCount = 0;
542
+ const maxRetries = 3;
543
+
544
+ const fetchData = async () => {
545
+ try {
546
+ const response = await axios.post(
547
+ `https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-base`,
548
+ { image: urls },
549
+ {
550
+ headers: {
551
+ "Content-Type": "application/json",
552
+ Authorization: `Bearer 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`,
553
+ },
554
+ },
555
+ );
556
+
557
+ if (response.status === 200) {
558
+ return response.data[0].generated_text;
559
+ } else {
560
+ console.error(
561
+ `Failed to fetch image captioning API: ${response.statusText}`,
562
+ );
563
+ return null;
564
+ }
565
+ } catch (e: any) {
566
+ console.error(`Error fetching data: ${e.message}`);
567
+ throw e;
568
+ }
569
+ };
570
+
571
+ while (retryCount < maxRetries) {
572
+ try {
573
+ return await fetchData();
574
+ } catch (e: any) {
575
+ console.error(
576
+ `Error fetching data (Retry ${retryCount + 1}): ${e.message}`,
577
+ );
578
+ retryCount++;
579
+ }
580
+ }
581
+
582
+ return null;
583
+ } catch (e: any) {
584
+ console.error(`Error in attemptImageCaptioning: ${e.message}`);
585
+ return null;
586
+ }
587
+ }
588
+
589
+ export { ApexImagine, ApexChat };
@@ -0,0 +1,23 @@
1
+ import { imageReader } from "./functions/imageReader";
2
+ import { chunkString } from "./functions/chunkString";
3
+ import { toDraw } from "./functions/shouldDrawImage";
4
+ import { aiVoice } from "./functions/generateVoiceResponse";
5
+ import { aiImagine } from "./functions/draw";
6
+ import { readPdf, readTextFile } from "./functions/readFiles";
7
+ import { ApexChat, ApexImagine } from "./models";
8
+ import { typeWriter } from "./functions/typeWriter" ;
9
+ import { readImage } from "./functions/readImagess";
10
+
11
+ export {
12
+ chunkString,
13
+ imageReader,
14
+ readImage,
15
+ toDraw,
16
+ aiVoice,
17
+ aiImagine,
18
+ readPdf,
19
+ readTextFile,
20
+ ApexChat,
21
+ ApexImagine,
22
+ typeWriter,
23
+ };