apexify.js 3.3.10 → 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.
Files changed (89) hide show
  1. package/README.md +183 -0
  2. package/dist/ai/ApexAI.d.ts +88 -8
  3. package/dist/ai/ApexAI.d.ts.map +1 -1
  4. package/dist/ai/ApexAI.js +61 -161
  5. package/dist/ai/ApexAI.js.map +1 -1
  6. package/dist/ai/direct-use.d.ts +9 -0
  7. package/dist/ai/direct-use.d.ts.map +1 -0
  8. package/dist/ai/direct-use.js +572 -0
  9. package/dist/ai/direct-use.js.map +1 -0
  10. package/dist/ai/functions/Gemini.d.ts +6 -0
  11. package/dist/ai/functions/Gemini.d.ts.map +1 -0
  12. package/dist/ai/functions/Gemini.js +103 -0
  13. package/dist/ai/functions/Gemini.js.map +1 -0
  14. package/dist/ai/functions/draw.d.ts +2 -1
  15. package/dist/ai/functions/draw.d.ts.map +1 -1
  16. package/dist/ai/functions/draw.js +476 -102
  17. package/dist/ai/functions/draw.js.map +1 -1
  18. package/dist/ai/functions/generateVoiceResponse.d.ts +3 -1
  19. package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -1
  20. package/dist/ai/functions/generateVoiceResponse.js +29 -18
  21. package/dist/ai/functions/generateVoiceResponse.js.map +1 -1
  22. package/dist/ai/functions/typeWriter.d.ts +1 -1
  23. package/dist/ai/functions/typeWriter.d.ts.map +1 -1
  24. package/dist/ai/functions/typeWriter.js +3 -2
  25. package/dist/ai/functions/typeWriter.js.map +1 -1
  26. package/dist/ai/functions/validOptions.d.ts +10 -0
  27. package/dist/ai/functions/validOptions.d.ts.map +1 -0
  28. package/dist/ai/functions/validOptions.js +130 -0
  29. package/dist/ai/functions/validOptions.js.map +1 -0
  30. package/dist/ai/modals-chat/Gemini-flash.d.ts +6 -0
  31. package/dist/ai/modals-chat/Gemini-flash.d.ts.map +1 -0
  32. package/dist/ai/modals-chat/Gemini-flash.js +111 -0
  33. package/dist/ai/modals-chat/Gemini-flash.js.map +1 -0
  34. package/dist/ai/modals-chat/Gemini-pro.d.ts +6 -0
  35. package/dist/ai/modals-chat/Gemini-pro.d.ts.map +1 -0
  36. package/dist/ai/modals-chat/Gemini-pro.js +96 -0
  37. package/dist/ai/modals-chat/Gemini-pro.js.map +1 -0
  38. package/dist/ai/modals-chat/apexChat.d.ts +2 -0
  39. package/dist/ai/modals-chat/apexChat.d.ts.map +1 -0
  40. package/dist/ai/modals-chat/apexChat.js +33 -0
  41. package/dist/ai/modals-chat/apexChat.js.map +1 -0
  42. package/dist/ai/modals-chat/config.d.ts +5 -0
  43. package/dist/ai/modals-chat/config.d.ts.map +1 -0
  44. package/dist/ai/modals-chat/config.js +13 -0
  45. package/dist/ai/modals-chat/config.js.map +1 -0
  46. package/dist/ai/modals-chat/facebook-ai.d.ts +2 -0
  47. package/dist/ai/modals-chat/facebook-ai.d.ts.map +1 -0
  48. package/dist/ai/modals-chat/facebook-ai.js +21 -0
  49. package/dist/ai/modals-chat/facebook-ai.js.map +1 -0
  50. package/dist/ai/modals-chat/gemma.d.ts +3 -0
  51. package/dist/ai/modals-chat/gemma.d.ts.map +1 -0
  52. package/dist/ai/modals-chat/gemma.js +54 -0
  53. package/dist/ai/modals-chat/gemma.js.map +1 -0
  54. package/dist/ai/modals-chat/modals.d.ts +8 -0
  55. package/dist/ai/modals-chat/modals.d.ts.map +1 -0
  56. package/dist/ai/modals-chat/modals.js +16 -0
  57. package/dist/ai/modals-chat/modals.js.map +1 -0
  58. package/dist/ai/modals-chat/starChat.d.ts +2 -0
  59. package/dist/ai/modals-chat/starChat.d.ts.map +1 -0
  60. package/dist/ai/modals-chat/starChat.js +32 -0
  61. package/dist/ai/modals-chat/starChat.js.map +1 -0
  62. package/dist/ai/modals-chat/yi-ai.d.ts +2 -0
  63. package/dist/ai/modals-chat/yi-ai.d.ts.map +1 -0
  64. package/dist/ai/modals-chat/yi-ai.js +41 -0
  65. package/dist/ai/modals-chat/yi-ai.js.map +1 -0
  66. package/dist/ai/utils.d.ts +3 -2
  67. package/dist/ai/utils.d.ts.map +1 -1
  68. package/dist/ai/utils.js +6 -4
  69. package/dist/ai/utils.js.map +1 -1
  70. package/dist/canvas/utils/general functions.js +1 -1
  71. package/dist/canvas/utils/general functions.js.map +1 -1
  72. package/lib/ai/ApexAI.ts +214 -224
  73. package/lib/ai/{models.ts → direct-use.ts} +9 -12
  74. package/lib/ai/functions/draw.ts +547 -149
  75. package/lib/ai/functions/generateVoiceResponse.ts +37 -22
  76. package/lib/ai/functions/typeWriter.ts +4 -2
  77. package/lib/ai/functions/validOptions.ts +210 -0
  78. package/lib/ai/modals-chat/Gemini-flash.ts +108 -0
  79. package/lib/ai/modals-chat/Gemini-pro.ts +93 -0
  80. package/lib/ai/modals-chat/apexChat.ts +31 -0
  81. package/lib/ai/modals-chat/config.ts +11 -0
  82. package/lib/ai/modals-chat/facebook-ai.ts +14 -0
  83. package/lib/ai/modals-chat/modals.ts +8 -0
  84. package/lib/ai/modals-chat/starChat.ts +31 -0
  85. package/lib/ai/modals-chat/yi-ai.ts +40 -0
  86. package/lib/ai/utils.ts +3 -1
  87. package/lib/canvas/utils/general functions.ts +1 -1
  88. package/package.json +5 -3
  89. package/lib/ai/functions/aivoice.ts +0 -0
@@ -1,13 +1,15 @@
1
1
  import { Hercai } from "hercai";
2
- import translate from "@iamtraction/google-translate";
2
+ import translate from "@iamtraction/google-translate";
3
+ import axios from "axios";
3
4
  import { createWorker, recognize } from "tesseract.js";
4
5
  import { chunkString } from "./chunkString";
5
6
  import { aiImagine } from "./draw";
7
+ import { ImageModals } from './validOptions';
6
8
  import fs from "fs";
7
9
 
8
- const herc = new Hercai();
10
+ const hercai = new Hercai('6eZZOdDwm6Epdzn8mnhcX9SBDkxvoNYcNj9ILS0P44=');
9
11
  let isProcessing = false;
10
- type ChatModelOption = "v3" | "v3-32k" | "turbo" | "turbo-16k" | "gemini";
12
+ type ChatModelOption = any | "v3" | "v3-32k" | "turbo" | "turbo-16k" | "gemini" ;
11
13
 
12
14
  async function aiVoice(
13
15
  message: any,
@@ -15,14 +17,17 @@ async function aiVoice(
15
17
  finalText: string,
16
18
  hercai: any,
17
19
  drawValid: any,
18
- imageModal: string,
19
- chatModal: string | "v3" | "v3-32k" | "turbo" | "turbo-16k" | "gemini" | "starChat" | "apexChat" | 'gemma-v3' | 'gemma-v4' | 'zephyr-beta' | undefined,
20
+ imageModal: ImageModals,
21
+ chatModal: ChatModelOption,
20
22
  voiceModal: string,
21
23
  voice_code: string,
22
24
  type: string,
23
25
  apiKey: string,
24
26
  nsfw: boolean,
25
- nsfwKeyWords: string[]
27
+ nsfwKeyWords: string[],
28
+ deepCheck: boolean,
29
+ enhancer: any,
30
+ buttons: any[]
26
31
  ) {
27
32
  if (message.author.bot || isProcessing || !message.guild) {
28
33
  return;
@@ -34,7 +39,7 @@ async function aiVoice(
34
39
  let msg = message.content;
35
40
 
36
41
  if (drawValid) {
37
- return await aiImagine(message, numOfImages, finalText, hercai, imageModal, nsfw, nsfwKeyWords);
42
+ return await aiImagine(message, numOfImages, finalText, hercai, imageModal, nsfw, nsfwKeyWords, deepCheck, enhancer, buttons);
38
43
  }
39
44
 
40
45
  if (message.attachments.size > 0) {
@@ -46,7 +51,7 @@ async function aiVoice(
46
51
  msg += "\n" + text;
47
52
  }
48
53
 
49
- msg = (await herc.question({
54
+ msg = (await hercai.betaQuestion({
50
55
  model: chatModal as ChatModelOption,
51
56
  content: msg,
52
57
  })).reply.replace(/\n/g, " ");
@@ -67,16 +72,21 @@ async function aiVoice(
67
72
  setTimeout(async () => {
68
73
  const encodedChunk = encodeURIComponent(chunk);
69
74
  const url = `https://translate.google.com/translate_tts?ie=UTF-8&tl=en&client=tw-ob&q=${encodedChunk}`;
70
- const response = await fetch(url, {
75
+ const mp3Stream = await axios.get(url, {
76
+ responseType: "stream",
71
77
  headers: {
72
78
  Referer: "http://translate.google.com/",
73
79
  "User-Agent": "stagefright/1.2 (Linux;Android 5.0)",
74
80
  },
75
81
  });
76
- const blob = await response.blob();
77
- const file = new File([blob], "respond.mp3");
78
82
  await message.reply({
79
- files: [file],
83
+ components: buttons,
84
+ files: [
85
+ {
86
+ attachment: mp3Stream.data,
87
+ name: "respond.mp3",
88
+ },
89
+ ],
80
90
  allowedMentions: { repliedUser: false },
81
91
  });
82
92
  }, delay);
@@ -89,12 +99,13 @@ async function aiVoice(
89
99
 
90
100
  const options = {
91
101
  method: "POST",
102
+ url: "https://text-to-speech-neural-google.p.rapidapi.com/generateAudioFiles",
92
103
  headers: {
93
104
  "content-type": "application/json",
94
105
  "X-RapidAPI-Key": apiKey,
95
106
  "X-RapidAPI-Host": "text-to-speech-neural-google.p.rapidapi.com",
96
107
  },
97
- body: JSON.stringify({
108
+ data: {
98
109
  audioFormat: "ogg",
99
110
  paragraphChunks: [msg],
100
111
  voiceParams: {
@@ -102,14 +113,15 @@ async function aiVoice(
102
113
  engine: "google",
103
114
  languageCode: "en-US",
104
115
  },
105
- }),
116
+ },
106
117
  };
107
118
 
108
119
  try {
109
- const response = await fetch("https://text-to-speech-neural-google.p.rapidapi.com/generateAudioFiles", options);
110
- const audioData = await response.json();
111
- fs.writeFileSync("output.ogg", Buffer.from(audioData.audioStream, "base64"));
120
+ const response = await axios.request(options);
121
+ const audioData = response.data.audioStream;
122
+ fs.writeFileSync("output.ogg", Buffer.from(audioData, "base64"));
112
123
  await message.reply({
124
+ components: buttons,
113
125
  files: [
114
126
  {
115
127
  attachment: "output.ogg",
@@ -122,7 +134,7 @@ async function aiVoice(
122
134
  console.error(error);
123
135
  throw new Error('Error generating audio file.');
124
136
  }
125
- } else if (imageModal === "zenithAi") {
137
+ } else if (voiceModal === "zenithAI") {
126
138
  if (!apiKey) {
127
139
  throw new Error('Error: The zenithAi model requires a premium account for generation. Please visit our support server at https://discord.gg/4uhpr7w8wW for assistance.');
128
140
  }
@@ -136,18 +148,21 @@ async function aiVoice(
136
148
 
137
149
  const options = {
138
150
  method: "POST",
151
+ url: "https://cloudlabs-text-to-speech.p.rapidapi.com/synthesize",
139
152
  headers: {
140
153
  "content-type": "application/x-www-form-urlencoded",
141
154
  "X-RapidAPI-Key": apiKey,
142
155
  "X-RapidAPI-Host": "cloudlabs-text-to-speech.p.rapidapi.com",
143
156
  },
144
- body: encodedParams.toString(),
157
+ data: encodedParams,
145
158
  };
146
159
 
147
160
  try {
148
- const response = await fetch("https://cloudlabs-text-to-speech.p.rapidapi.com/synthesize", options);
149
- const { result: { audio_url } } = await response.json();
150
- await message.reply(audio_url, {
161
+ const response = await axios.request(options);
162
+ const audioUrl = response.data.result.audio_url;
163
+ await message.reply({
164
+ content: audioUrl,
165
+ components: buttons,
151
166
  allowedMentions: { repliedUser: false },
152
167
  });
153
168
  } catch (error) {
@@ -1,5 +1,7 @@
1
- export async function typeWriter(channel: any, sentence: string, speed: number, delay: number): Promise<void> {
2
- const typingMessage = await channel.send(sentence[0]);
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
+