apexify.js 4.0.12 → 4.1.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 (53) hide show
  1. package/dist/ai/ApexAI.d.ts +1 -2
  2. package/dist/ai/ApexAI.d.ts.map +1 -1
  3. package/dist/ai/ApexAI.js.map +1 -1
  4. package/dist/ai/ApexModules.d.ts +17 -0
  5. package/dist/ai/ApexModules.d.ts.map +1 -0
  6. package/dist/ai/ApexModules.js +704 -0
  7. package/dist/ai/ApexModules.js.map +1 -0
  8. package/dist/ai/functions/draw.d.ts +1 -2
  9. package/dist/ai/functions/draw.d.ts.map +1 -1
  10. package/dist/ai/functions/draw.js +505 -504
  11. package/dist/ai/functions/draw.js.map +1 -1
  12. package/dist/ai/functions/generateVoiceResponse.d.ts +1 -2
  13. package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -1
  14. package/dist/ai/functions/generateVoiceResponse.js.map +1 -1
  15. package/dist/ai/functions/shouldDrawImage.js +2 -3
  16. package/dist/ai/functions/shouldDrawImage.js.map +1 -1
  17. package/dist/ai/functions/validOptions.d.ts +3 -3
  18. package/dist/ai/functions/validOptions.d.ts.map +1 -1
  19. package/dist/ai/functions/validOptions.js +44 -117
  20. package/dist/ai/functions/validOptions.js.map +1 -1
  21. package/dist/ai/modals-chat/Gemini-flash.js +2 -26
  22. package/dist/ai/modals-chat/Gemini-pro.d.ts.map +1 -1
  23. package/dist/ai/modals-chat/Gemini-pro.js +6 -3
  24. package/dist/ai/modals-chat/Gemini-pro.js.map +1 -1
  25. package/dist/ai/utils.d.ts +1 -1
  26. package/dist/ai/utils.d.ts.map +1 -1
  27. package/dist/ai/utils.js +3 -3
  28. package/dist/ai/utils.js.map +1 -1
  29. package/lib/ai/ApexAI.ts +1 -2
  30. package/lib/ai/ApexModules.ts +733 -0
  31. package/lib/ai/functions/draw.ts +33 -25
  32. package/lib/ai/functions/generateVoiceResponse.ts +1 -2
  33. package/lib/ai/functions/validOptions.ts +44 -194
  34. package/lib/ai/modals-chat/Gemini-pro.ts +18 -16
  35. package/lib/ai/utils.ts +1 -1
  36. package/package.json +9 -1
  37. package/dist/ai/direct-use.d.ts +0 -9
  38. package/dist/ai/direct-use.d.ts.map +0 -1
  39. package/dist/ai/direct-use.js +0 -572
  40. package/dist/ai/direct-use.js.map +0 -1
  41. package/dist/ai/functions/Gemini.d.ts +0 -6
  42. package/dist/ai/functions/Gemini.d.ts.map +0 -1
  43. package/dist/ai/functions/Gemini.js +0 -103
  44. package/dist/ai/functions/Gemini.js.map +0 -1
  45. package/dist/ai/functions/aivoice.d.ts +0 -1
  46. package/dist/ai/functions/aivoice.d.ts.map +0 -1
  47. package/dist/ai/functions/aivoice.js +0 -2
  48. package/dist/ai/functions/aivoice.js.map +0 -1
  49. package/dist/ai/models.d.ts +0 -9
  50. package/dist/ai/models.d.ts.map +0 -1
  51. package/dist/ai/models.js +0 -575
  52. package/dist/ai/models.js.map +0 -1
  53. package/lib/ai/direct-use.ts +0 -586
@@ -1,103 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.geminiPro = void 0;
7
- const generative_ai_1 = require("@google/generative-ai");
8
- const path_1 = __importDefault(require("path"));
9
- const fs_1 = __importDefault(require("fs"));
10
- async function geminiPro(message, AI) {
11
- var _a;
12
- try {
13
- const genAI = new generative_ai_1.GoogleGenerativeAI(AI.API_KEY || 'AIzaSyBunhAUzjzXQyVH65XKQQN098m0rn8fWjw');
14
- let personalityLines = [];
15
- if (AI.AiPersonality) {
16
- const personalityFilePath = path_1.default.join(process.cwd(), AI.AiPersonality);
17
- const personalityContent = fs_1.default.readFileSync(personalityFilePath, 'utf-8');
18
- personalityLines = personalityContent.split('\n');
19
- }
20
- const generationConfig = {
21
- maxOutputTokens: 750,
22
- };
23
- const systemInstruction = `You are an ai bot in discord replying to ${message.author.globalName || message.author.username} at ${message.channel.name}.`;
24
- const model = genAI.getGenerativeModel({ model: "gemini-pro", systemInstruction, generationConfig });
25
- const chat = model.startChat({
26
- history: [
27
- {
28
- role: "user",
29
- parts: [{ text: `${personalityLines}\n And working on discord in serverName: ${message.guild.name} at channelName: ${message.channel.name} and responding to the userName: ${message.author.username}` }],
30
- },
31
- {
32
- role: "model",
33
- parts: [{ text: `I will greet the user with their name: <@${message.author.id}>. Feel feel free to ask me anything! 😊`,
34
- }],
35
- },
36
- ],
37
- generationConfig
38
- });
39
- const attachment = (_a = message.attachments) === null || _a === void 0 ? void 0 : _a.first();
40
- const imgURL = (attachment === null || attachment === void 0 ? void 0 : attachment.url) || null;
41
- let result;
42
- if (imgURL) {
43
- const imageData = await urlToBase64(imgURL);
44
- const image = {
45
- inlineData: {
46
- data: imageData,
47
- mimeType: "image/png",
48
- },
49
- };
50
- result = await chat.sendMessage([AI.userMsg, image]);
51
- }
52
- else {
53
- result = await chat.sendMessage(AI.userMsg);
54
- }
55
- const response = result.response;
56
- return response.text();
57
- }
58
- catch (e) {
59
- if (e.message) {
60
- 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.') {
61
- return `<${message.author.id}> your location isn't support by gemini AI.`;
62
- }
63
- else {
64
- return `Trye again later please... Either API is on a cooldown or an internal erro has occurred. If issue persists please contact the bot developer or owner of the npm package.`;
65
- }
66
- }
67
- else {
68
- console.error(e);
69
- return 'An unkown error has occurred.';
70
- }
71
- }
72
- }
73
- exports.geminiPro = geminiPro;
74
- function urlToBase64(imageURL) {
75
- return new Promise((resolve, reject) => {
76
- const xhr = new XMLHttpRequest();
77
- xhr.responseType = 'blob';
78
- xhr.onload = () => {
79
- if (xhr.status === 200) {
80
- const reader = new FileReader();
81
- reader.onloadend = () => {
82
- const base64String = reader.result;
83
- if (base64String) {
84
- resolve(base64String.split(',')[1]);
85
- }
86
- else {
87
- reject("Failed to convert the image to base64.");
88
- }
89
- };
90
- reader.readAsDataURL(xhr.response);
91
- }
92
- else {
93
- reject(`Failed to fetch the image. Status code: ${xhr.status}`);
94
- }
95
- };
96
- xhr.onerror = () => {
97
- reject("An error occurred while fetching the image.");
98
- };
99
- xhr.open('GET', imageURL);
100
- xhr.send();
101
- });
102
- }
103
- //# sourceMappingURL=Gemini.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Gemini.js","sourceRoot":"","sources":["../../../lib/ai/functions/Gemini.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA2D;AAC3D,gDAAwB;AACxB,4CAAoB;AAEb,KAAK,UAAU,SAAS,CAAC,OAAY,EAAE,EAA6E;;IAEzH,IAAI,CAAC;QACL,MAAM,KAAK,GAAG,IAAI,kCAAkB,CAAC,EAAE,CAAC,OAAO,IAAI,yCAAyC,CAAC,CAAC;QAE5F,IAAI,gBAAgB,GAAa,EAAE,CAAC;QACpC,IAAI,EAAE,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC;YACvE,MAAM,kBAAkB,GAAG,YAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YACzE,gBAAgB,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,gBAAgB,GAAG;YACrB,eAAe,EAAE,GAAG;SACvB,CAAC;QAEF,MAAM,iBAAiB,GAAG,4CAA4C,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,QAAS,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;QAC1J,MAAM,KAAK,GAAG,KAAK,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAC,CA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MAAM,CAAC,6CAA6C,CAAC,CAAC;QAC1D,CAAC,CAAC;QAEF,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1B,GAAG,CAAC,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=aivoice.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aivoice.d.ts","sourceRoot":"","sources":["../../../lib/ai/functions/aivoice.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=aivoice.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aivoice.js","sourceRoot":"","sources":["../../../lib/ai/functions/aivoice.ts"],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
1
- interface ApexImagineOptions {
2
- negative?: string;
3
- number?: number;
4
- nsfw?: boolean;
5
- }
6
- declare function ApexImagine(model: string, prompt: string, options: ApexImagineOptions): Promise<any>;
7
- declare function ApexChat(model: string, prompt: string): Promise<string>;
8
- export { ApexImagine, ApexChat };
9
- //# sourceMappingURL=models.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../lib/ai/models.ts"],"names":[],"mappings":"AAOA,UAAU,kBAAkB;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CACd;AAID,iBAAe,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,CAybnG;AA2BD,iBAAe,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBtE;AAoFD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}