apexify.js 4.4.36 → 4.5.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.
- package/README.md +26 -199
- package/dist/ai/ApexAI.d.ts +30 -18
- package/dist/ai/ApexAI.d.ts.map +1 -1
- package/dist/ai/ApexAI.js +34 -171
- package/dist/ai/ApexAI.js.map +1 -1
- package/dist/ai/ApexModules.d.ts.map +1 -1
- package/dist/ai/ApexModules.js +42 -127
- package/dist/ai/ApexModules.js.map +1 -1
- package/dist/ai/functions/draw.d.ts +6 -1
- package/dist/ai/functions/draw.d.ts.map +1 -1
- package/dist/ai/functions/draw.js +550 -722
- package/dist/ai/functions/draw.js.map +1 -1
- package/dist/ai/functions/generateVoiceResponse.d.ts +6 -1
- package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -1
- package/dist/ai/functions/generateVoiceResponse.js +2 -2
- package/dist/ai/functions/generateVoiceResponse.js.map +1 -1
- package/dist/ai/functions/validOptions.d.ts +14 -7
- package/dist/ai/functions/validOptions.d.ts.map +1 -1
- package/dist/ai/functions/validOptions.js +23 -22
- package/dist/ai/functions/validOptions.js.map +1 -1
- package/dist/ai/modals-chat/electronHub/imageModels.d.ts +7 -0
- package/dist/ai/modals-chat/electronHub/imageModels.d.ts.map +1 -0
- package/dist/ai/modals-chat/electronHub/imageModels.js +28 -0
- package/dist/ai/modals-chat/electronHub/imageModels.js.map +1 -0
- package/dist/ai/modals-chat/freesedgpt/cartoon.d.ts +2 -0
- package/dist/ai/modals-chat/freesedgpt/cartoon.d.ts.map +1 -0
- package/dist/ai/modals-chat/freesedgpt/cartoon.js +26 -0
- package/dist/ai/modals-chat/freesedgpt/cartoon.js.map +1 -0
- package/dist/ai/modals-chat/freesedgpt/chat.d.ts +5 -0
- package/dist/ai/modals-chat/freesedgpt/chat.d.ts.map +1 -0
- package/dist/ai/modals-chat/freesedgpt/chat.js +30 -0
- package/dist/ai/modals-chat/freesedgpt/chat.js.map +1 -0
- package/dist/ai/modals-chat/freesedgpt/flux.d.ts +2 -0
- package/dist/ai/modals-chat/freesedgpt/flux.d.ts.map +1 -0
- package/dist/ai/modals-chat/freesedgpt/flux.js +26 -0
- package/dist/ai/modals-chat/freesedgpt/flux.js.map +1 -0
- package/dist/ai/modals-chat/gemini/Gemini-flash.d.ts.map +1 -0
- package/dist/ai/modals-chat/{Gemini-flash.js → gemini/Gemini-flash.js} +2 -2
- package/dist/ai/modals-chat/gemini/Gemini-flash.js.map +1 -0
- package/dist/ai/modals-chat/gemini/Gemini-pro.d.ts.map +1 -0
- package/dist/ai/modals-chat/{Gemini-pro.js → gemini/Gemini-pro.js} +2 -2
- package/dist/ai/modals-chat/gemini/Gemini-pro.js.map +1 -0
- package/dist/ai/modals-chat/gemini/config.d.ts.map +1 -0
- package/dist/ai/modals-chat/gemini/config.js.map +1 -0
- package/dist/ai/modals-chat/gemini/geminiFast.d.ts.map +1 -0
- package/dist/ai/modals-chat/gemini/geminiFast.js.map +1 -0
- package/dist/ai/modals-chat/groq/chatgroq.d.ts +9 -0
- package/dist/ai/modals-chat/groq/chatgroq.d.ts.map +1 -0
- package/dist/ai/modals-chat/groq/chatgroq.js +58 -0
- package/dist/ai/modals-chat/groq/chatgroq.js.map +1 -0
- package/dist/ai/modals-chat/groq/imageAnalyzer.d.ts +8 -0
- package/dist/ai/modals-chat/groq/imageAnalyzer.d.ts.map +1 -0
- package/dist/ai/modals-chat/groq/imageAnalyzer.js +64 -0
- package/dist/ai/modals-chat/groq/imageAnalyzer.js.map +1 -0
- package/dist/ai/modals-chat/groq/whisper.d.ts.map +1 -0
- package/dist/ai/modals-chat/{whisper.js → groq/whisper.js} +2 -2
- package/dist/ai/modals-chat/groq/whisper.js.map +1 -0
- package/dist/ai/modals-chat/hercai/chatModals.d.ts +7 -0
- package/dist/ai/modals-chat/hercai/chatModals.d.ts.map +1 -0
- package/dist/ai/modals-chat/hercai/chatModals.js +23 -0
- package/dist/ai/modals-chat/hercai/chatModals.js.map +1 -0
- package/dist/ai/modals-chat/hercai/chatModels.d.ts +7 -0
- package/dist/ai/modals-chat/hercai/chatModels.d.ts.map +1 -0
- package/dist/ai/modals-chat/hercai/chatModels.js +23 -0
- package/dist/ai/modals-chat/hercai/chatModels.js.map +1 -0
- package/dist/ai/modals-chat/others/otherModels.d.ts +7 -0
- package/dist/ai/modals-chat/others/otherModels.d.ts.map +1 -0
- package/dist/ai/modals-chat/others/otherModels.js +88 -0
- package/dist/ai/modals-chat/others/otherModels.js.map +1 -0
- package/dist/ai/modals-chat/rsn/rsnChat.d.ts +8 -0
- package/dist/ai/modals-chat/rsn/rsnChat.d.ts.map +1 -0
- package/dist/ai/modals-chat/{bing.js → rsn/rsnChat.js} +29 -8
- package/dist/ai/modals-chat/rsn/rsnChat.js.map +1 -0
- package/dist/ai/modals-images/cartoon.js +1 -1
- package/dist/ai/modals-images/cartoon.js.map +1 -1
- package/dist/ai/modals-images/flux.js +1 -1
- package/dist/ai/modals-images/flux.js.map +1 -1
- package/dist/ai/utils.d.ts +4 -7
- package/dist/ai/utils.d.ts.map +1 -1
- package/dist/ai/utils.js +6 -12
- package/dist/ai/utils.js.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/lib/ai/ApexAI.ts +90 -191
- package/lib/ai/ApexModules.ts +45 -135
- package/lib/ai/functions/draw.ts +572 -788
- package/lib/ai/functions/generateVoiceResponse.ts +2 -2
- package/lib/ai/functions/validOptions.ts +24 -23
- package/lib/ai/modals-chat/electronHub/imageModels.ts +26 -0
- package/lib/ai/{modals-images → modals-chat/freesedgpt}/cartoon.ts +3 -3
- package/lib/ai/modals-chat/freesedgpt/chat.ts +31 -0
- package/lib/ai/{modals-images → modals-chat/freesedgpt}/flux.ts +3 -3
- package/lib/ai/modals-chat/{Gemini-flash.ts → gemini/Gemini-flash.ts} +2 -2
- package/lib/ai/modals-chat/{Gemini-pro.ts → gemini/Gemini-pro.ts} +2 -2
- package/lib/ai/modals-chat/groq/chatgroq.ts +68 -0
- package/lib/ai/modals-chat/groq/imageAnalyzer.ts +68 -0
- package/lib/ai/modals-chat/{whisper.ts → groq/whisper.ts} +2 -2
- package/lib/ai/modals-chat/hercai/chatModels.ts +20 -0
- package/lib/ai/modals-chat/others/otherModels.ts +99 -0
- package/lib/ai/modals-chat/rsn/rsnChat.ts +74 -0
- package/lib/ai/utils.ts +7 -12
- package/lib/index.ts +5 -3
- package/package.json +1 -1
- package/dist/ai/functions/imageAnalysis.d.ts +0 -2
- package/dist/ai/functions/imageAnalysis.d.ts.map +0 -1
- package/dist/ai/functions/imageAnalysis.js +0 -45
- package/dist/ai/functions/imageAnalysis.js.map +0 -1
- package/dist/ai/functions/readImagess.d.ts +0 -2
- package/dist/ai/functions/readImagess.d.ts.map +0 -1
- package/dist/ai/functions/readImagess.js +0 -45
- package/dist/ai/functions/readImagess.js.map +0 -1
- package/dist/ai/modals-chat/Gemini-flash.d.ts.map +0 -1
- package/dist/ai/modals-chat/Gemini-flash.js.map +0 -1
- package/dist/ai/modals-chat/Gemini-pro.d.ts.map +0 -1
- package/dist/ai/modals-chat/Gemini-pro.js.map +0 -1
- package/dist/ai/modals-chat/apexChat.d.ts +0 -2
- package/dist/ai/modals-chat/apexChat.d.ts.map +0 -1
- package/dist/ai/modals-chat/apexChat.js +0 -32
- package/dist/ai/modals-chat/apexChat.js.map +0 -1
- package/dist/ai/modals-chat/bard.d.ts +0 -7
- package/dist/ai/modals-chat/bard.d.ts.map +0 -1
- package/dist/ai/modals-chat/bard.js +0 -48
- package/dist/ai/modals-chat/bard.js.map +0 -1
- package/dist/ai/modals-chat/bing.d.ts +0 -7
- package/dist/ai/modals-chat/bing.d.ts.map +0 -1
- package/dist/ai/modals-chat/bing.js.map +0 -1
- package/dist/ai/modals-chat/codellama.d.ts +0 -7
- package/dist/ai/modals-chat/codellama.d.ts.map +0 -1
- package/dist/ai/modals-chat/codellama.js +0 -48
- package/dist/ai/modals-chat/codellama.js.map +0 -1
- package/dist/ai/modals-chat/config.d.ts.map +0 -1
- package/dist/ai/modals-chat/config.js.map +0 -1
- package/dist/ai/modals-chat/facebook-ai.d.ts +0 -2
- package/dist/ai/modals-chat/facebook-ai.d.ts.map +0 -1
- package/dist/ai/modals-chat/facebook-ai.js +0 -20
- package/dist/ai/modals-chat/facebook-ai.js.map +0 -1
- package/dist/ai/modals-chat/geminiFast.d.ts.map +0 -1
- package/dist/ai/modals-chat/geminiFast.js.map +0 -1
- package/dist/ai/modals-chat/geminiV2.d.ts +0 -7
- package/dist/ai/modals-chat/geminiV2.d.ts.map +0 -1
- package/dist/ai/modals-chat/geminiV2.js +0 -48
- package/dist/ai/modals-chat/geminiV2.js.map +0 -1
- package/dist/ai/modals-chat/gemma.d.ts +0 -2
- package/dist/ai/modals-chat/gemma.d.ts.map +0 -1
- package/dist/ai/modals-chat/gemma.js +0 -43
- package/dist/ai/modals-chat/gemma.js.map +0 -1
- package/dist/ai/modals-chat/llama.d.ts +0 -7
- package/dist/ai/modals-chat/llama.d.ts.map +0 -1
- package/dist/ai/modals-chat/llama.js +0 -48
- package/dist/ai/modals-chat/llama.js.map +0 -1
- package/dist/ai/modals-chat/llamav2.d.ts +0 -2
- package/dist/ai/modals-chat/llamav2.d.ts.map +0 -1
- package/dist/ai/modals-chat/llamav2.js +0 -43
- package/dist/ai/modals-chat/llamav2.js.map +0 -1
- package/dist/ai/modals-chat/llamav3.d.ts +0 -2
- package/dist/ai/modals-chat/llamav3.d.ts.map +0 -1
- package/dist/ai/modals-chat/llamav3.js +0 -43
- package/dist/ai/modals-chat/llamav3.js.map +0 -1
- package/dist/ai/modals-chat/mixtral.d.ts +0 -7
- package/dist/ai/modals-chat/mixtral.d.ts.map +0 -1
- package/dist/ai/modals-chat/mixtral.js +0 -48
- package/dist/ai/modals-chat/mixtral.js.map +0 -1
- package/dist/ai/modals-chat/mixtralv2.d.ts +0 -2
- package/dist/ai/modals-chat/mixtralv2.d.ts.map +0 -1
- package/dist/ai/modals-chat/mixtralv2.js +0 -43
- package/dist/ai/modals-chat/mixtralv2.js.map +0 -1
- package/dist/ai/modals-chat/modals.d.ts +0 -8
- package/dist/ai/modals-chat/modals.d.ts.map +0 -1
- package/dist/ai/modals-chat/modals.js +0 -16
- package/dist/ai/modals-chat/modals.js.map +0 -1
- package/dist/ai/modals-chat/openChat.d.ts +0 -7
- package/dist/ai/modals-chat/openChat.d.ts.map +0 -1
- package/dist/ai/modals-chat/openChat.js +0 -48
- package/dist/ai/modals-chat/openChat.js.map +0 -1
- package/dist/ai/modals-chat/starChat.d.ts +0 -2
- package/dist/ai/modals-chat/starChat.d.ts.map +0 -1
- package/dist/ai/modals-chat/starChat.js +0 -31
- package/dist/ai/modals-chat/starChat.js.map +0 -1
- package/dist/ai/modals-chat/v4.d.ts +0 -7
- package/dist/ai/modals-chat/v4.d.ts.map +0 -1
- package/dist/ai/modals-chat/v4.js +0 -48
- package/dist/ai/modals-chat/v4.js.map +0 -1
- package/dist/ai/modals-chat/whisper.d.ts.map +0 -1
- package/dist/ai/modals-chat/whisper.js.map +0 -1
- package/dist/ai/modals-chat/yi-ai.d.ts +0 -2
- package/dist/ai/modals-chat/yi-ai.d.ts.map +0 -1
- package/dist/ai/modals-chat/yi-ai.js +0 -40
- package/dist/ai/modals-chat/yi-ai.js.map +0 -1
- package/lib/ai/functions/imageAnalysis.ts +0 -41
- package/lib/ai/modals-chat/apexChat.ts +0 -31
- package/lib/ai/modals-chat/bard.ts +0 -44
- package/lib/ai/modals-chat/bing.ts +0 -44
- package/lib/ai/modals-chat/codellama.ts +0 -44
- package/lib/ai/modals-chat/facebook-ai.ts +0 -14
- package/lib/ai/modals-chat/geminiV2.ts +0 -44
- package/lib/ai/modals-chat/gemma.ts +0 -35
- package/lib/ai/modals-chat/llama.ts +0 -44
- package/lib/ai/modals-chat/llamav2.ts +0 -35
- package/lib/ai/modals-chat/llamav3.ts +0 -35
- package/lib/ai/modals-chat/mixtral.ts +0 -45
- package/lib/ai/modals-chat/mixtralv2.ts +0 -35
- package/lib/ai/modals-chat/modals.ts +0 -8
- package/lib/ai/modals-chat/openChat.ts +0 -44
- package/lib/ai/modals-chat/starChat.ts +0 -31
- package/lib/ai/modals-chat/v4.ts +0 -44
- package/lib/ai/modals-chat/yi-ai.ts +0 -40
- /package/dist/ai/modals-chat/{Gemini-flash.d.ts → gemini/Gemini-flash.d.ts} +0 -0
- /package/dist/ai/modals-chat/{Gemini-pro.d.ts → gemini/Gemini-pro.d.ts} +0 -0
- /package/dist/ai/modals-chat/{config.d.ts → gemini/config.d.ts} +0 -0
- /package/dist/ai/modals-chat/{config.js → gemini/config.js} +0 -0
- /package/dist/ai/modals-chat/{geminiFast.d.ts → gemini/geminiFast.d.ts} +0 -0
- /package/dist/ai/modals-chat/{geminiFast.js → gemini/geminiFast.js} +0 -0
- /package/dist/ai/modals-chat/{whisper.d.ts → groq/whisper.d.ts} +0 -0
- /package/lib/ai/modals-chat/{config.ts → gemini/config.ts} +0 -0
- /package/lib/ai/modals-chat/{geminiFast.ts → gemini/geminiFast.ts} +0 -0
package/lib/ai/ApexModules.ts
CHANGED
|
@@ -3,22 +3,18 @@ import axios from 'axios';
|
|
|
3
3
|
import api from "api";
|
|
4
4
|
import translate from "@iamtraction/google-translate";
|
|
5
5
|
const sdk = api("@prodia/v1.3.0#be019b2kls0gqss3");
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { llamaChat, mixtral, openChat, v4 } from './utils';
|
|
9
|
-
import { codellama } from './modals-chat/codellama';
|
|
10
|
-
import { bard } from './modals-chat/bard';
|
|
11
|
-
import { bing } from './modals-chat/bing';
|
|
12
|
-
import { gemini_v2 } from './modals-chat/geminiV2';
|
|
13
|
-
import { whisper } from './modals-chat/whisper';
|
|
14
|
-
import { llama2 } from './modals-chat/llamav2';
|
|
15
|
-
import { llama3 } from './modals-chat/llamav3';
|
|
16
|
-
import { gemma } from './modals-chat/gemma';
|
|
17
|
-
import { mixtral2 } from './modals-chat/mixtralv2';
|
|
6
|
+
import { groqChatModels, hercChatModels, otherChatModel, rsnChatModels, validateModels } from "./functions/validOptions";
|
|
7
|
+
import { whisper } from './modals-chat/groq/whisper';
|
|
18
8
|
import { connect } from 'verse.db';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
9
|
+
import { otherChatModels } from './modals-chat/others/otherModels';
|
|
10
|
+
import { rsnAPI } from './modals-chat/rsn/rsnChat';
|
|
11
|
+
import { chatGroq } from './modals-chat/groq/chatgroq';
|
|
12
|
+
import { geminiFast } from './modals-chat/gemini/geminiFast';
|
|
13
|
+
import { cartoon } from './modals-chat/freesedgpt/cartoon';
|
|
14
|
+
import { flux } from './modals-chat/freesedgpt/flux';
|
|
15
|
+
import { gpt4o } from './modals-chat/freesedgpt/chat';
|
|
16
|
+
import { groqAnalyzer } from './utils';
|
|
17
|
+
|
|
22
18
|
|
|
23
19
|
const dbConfig = {
|
|
24
20
|
adapter: 'json',
|
|
@@ -50,21 +46,19 @@ type hercmodals = "v1" | "v2" | "v2-beta" | "v3" | "lexica" | "prodia" | "animef
|
|
|
50
46
|
async function ApexImagine(model: string, prompt: string, options: ApexImagineOptions): Promise<string[] | undefined> {
|
|
51
47
|
let imageURL: string | null = '';
|
|
52
48
|
let response: string[] = [];
|
|
53
|
-
const imageType = await
|
|
54
|
-
const { nsfw = false, deepCheck = false, nsfwWords = [], count = 2, negative_prompt = "", sampler = "DPM++ 2M Karras", height = 512, width = 512, cfg_scale = 9, steps = 20, seed = -1, image_style = "cinematic" } = options;
|
|
55
|
-
|
|
56
|
-
sdk.auth(options.Api_Key || 'eaebff6e-c7b2-477c-8edd-9aa91becf1e3');
|
|
49
|
+
const imageType = await validateModels;
|
|
50
|
+
const { Api_Key = 'eaebff6e-c7b2-477c-8edd-9aa91becf1e3', nsfw = false, deepCheck = false, nsfwWords = [], count = 2, negative_prompt = "", sampler = "DPM++ 2M Karras", height = 512, width = 512, cfg_scale = 9, steps = 20, seed = -1, image_style = "cinematic" } = options;
|
|
57
51
|
|
|
58
52
|
const translatedText = await translate(prompt, {
|
|
59
53
|
from: "auto",
|
|
60
|
-
to: "en"
|
|
61
|
-
|
|
54
|
+
to: "en"
|
|
55
|
+
});
|
|
62
56
|
|
|
63
57
|
if (count > 4 || count <= 0) throw new Error("Inavlid usage. Count can't be less than 0 or more than 4.");
|
|
64
|
-
if ((width || height)
|
|
58
|
+
if ((width || height) <= 0) throw new Error("Inavlid usage. Image width/height can't be less than 0 or more than 1024.");
|
|
65
59
|
|
|
66
60
|
for (let i = 0; i < count; i++) {
|
|
67
|
-
if (imageType.
|
|
61
|
+
if (imageType.validHercaiModels.includes(model)) {
|
|
68
62
|
if (model === 'prodia-v2') {
|
|
69
63
|
imageURL = (await hercai.betaDrawImage({
|
|
70
64
|
prompt: translatedText.text,
|
|
@@ -83,7 +77,8 @@ async function ApexImagine(model: string, prompt: string, options: ApexImagineOp
|
|
|
83
77
|
negative_prompt: negative_prompt
|
|
84
78
|
})).url;
|
|
85
79
|
}
|
|
86
|
-
} else if (imageType.
|
|
80
|
+
} else if (imageType.validProdiaModels.includes(model)) {
|
|
81
|
+
sdk.auth(Api_Key);
|
|
87
82
|
const generating = await sdk.generate({
|
|
88
83
|
model: model,
|
|
89
84
|
prompt: translatedText.text,
|
|
@@ -100,6 +95,7 @@ async function ApexImagine(model: string, prompt: string, options: ApexImagineOp
|
|
|
100
95
|
const generatedJobId = generating.data.job;
|
|
101
96
|
imageURL = await checkJobStatus(generatedJobId);
|
|
102
97
|
} else if (imageType.validSXDL.includes(model)) {
|
|
98
|
+
sdk.auth(Api_Key);
|
|
103
99
|
const generating = await sdk.sdxlGenerate({
|
|
104
100
|
model: model,
|
|
105
101
|
prompt: translatedText.text,
|
|
@@ -115,15 +111,18 @@ async function ApexImagine(model: string, prompt: string, options: ApexImagineOp
|
|
|
115
111
|
|
|
116
112
|
const generatedJobId = generating.data.job;
|
|
117
113
|
imageURL = await checkJobStatus(generatedJobId);
|
|
118
|
-
} else if (model === 'flux') {
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
|
|
114
|
+
} else if (model === 'flux-schnell') {
|
|
115
|
+
const gen = await flux(translatedText.text, options.Api_Key as string);
|
|
116
|
+
if (gen === null) throw new Error('this model reached rate limit. Provide your own api key from: "https://discord.gg/94qUZWhwFE"');
|
|
117
|
+
imageURL = gen
|
|
118
|
+
|
|
119
|
+
} else if (model === 'real-cartoon-xl-v6') {
|
|
120
|
+
const gen = await cartoon(translatedText.text, options.Api_Key as string);
|
|
121
|
+
if (gen === null) throw new Error('this model reached rate limit. Provide your own api key from: "https://discord.gg/94qUZWhwFE"');
|
|
122
|
+
imageURL = gen
|
|
123
|
+
} else if (model === 'dalle') {
|
|
124
|
+
imageURL = await rsnAPI({ API_KEY: Api_Key, prompt: translatedText.text, apiName: 'dalle' });
|
|
125
|
+
} else {
|
|
127
126
|
throw new Error("Invalid model provided. Please check docs/npm page for valid models.");
|
|
128
127
|
}
|
|
129
128
|
|
|
@@ -618,7 +617,7 @@ async function ApexImagine(model: string, prompt: string, options: ApexImagineOp
|
|
|
618
617
|
let shouldExclude = false;
|
|
619
618
|
|
|
620
619
|
if (nsfw === true) {
|
|
621
|
-
const caption = await
|
|
620
|
+
const caption = await groqAnalyzer({ imgURL: imageURL, prompt });
|
|
622
621
|
if (!caption) return;
|
|
623
622
|
shouldExclude = NSFWWORDS.some(word => caption.includes(word));
|
|
624
623
|
shouldExclude = nsfwWords.some(word => caption.includes(word));
|
|
@@ -678,7 +677,7 @@ async function ApexChat(model: string, prompt: string, { userId, memory, limit,
|
|
|
678
677
|
}
|
|
679
678
|
|
|
680
679
|
const responses = await Promise.all(chunks.map(async (chunk) => {
|
|
681
|
-
return await processChunk(model, chunk, {});
|
|
680
|
+
return await processChunk(model, chunk, { ApiKey: Api_key, personality: instruction });
|
|
682
681
|
}));
|
|
683
682
|
|
|
684
683
|
response = responses.join('');
|
|
@@ -699,116 +698,27 @@ async function ApexChat(model: string, prompt: string, { userId, memory, limit,
|
|
|
699
698
|
|
|
700
699
|
async function processChunk(model: string, prompt: string, { ApiKey, personality }: { ApiKey?: string, personality?: string }): Promise<string> {
|
|
701
700
|
let response: string;
|
|
702
|
-
switch (
|
|
703
|
-
case
|
|
704
|
-
case 'v3-32k':
|
|
705
|
-
case 'turbo':
|
|
706
|
-
case 'turbo-16k':
|
|
707
|
-
case 'gemini':
|
|
701
|
+
switch (true) {
|
|
702
|
+
case hercChatModels.includes(model):
|
|
708
703
|
response = (await hercai.question({ model: model as ChatModelOption, content: prompt, personality })).reply;
|
|
709
704
|
break;
|
|
710
|
-
case
|
|
711
|
-
response = await
|
|
712
|
-
break;
|
|
713
|
-
case 'starChat':
|
|
714
|
-
response = await starChat(prompt);
|
|
715
|
-
break;
|
|
716
|
-
case 'facebook-ai':
|
|
717
|
-
response = await facebook_ai(prompt);
|
|
718
|
-
break;
|
|
719
|
-
case 'yi-ai':
|
|
720
|
-
response = await yi_34b(prompt);
|
|
721
|
-
break;
|
|
722
|
-
case 'v4':
|
|
723
|
-
response = await v4({ API_KEY: ApiKey, prompt });
|
|
724
|
-
break;
|
|
725
|
-
case 'openChat':
|
|
726
|
-
response = await openChat({ API_KEY: ApiKey, prompt });
|
|
727
|
-
break;
|
|
728
|
-
case 'mixtral':
|
|
729
|
-
response = await mixtral({ API_KEY: ApiKey, prompt });
|
|
730
|
-
break;
|
|
731
|
-
case 'llama':
|
|
732
|
-
response = await llamaChat({ API_KEY: ApiKey, prompt });
|
|
733
|
-
break;
|
|
734
|
-
case 'llama-v2':
|
|
735
|
-
response = await llama2(prompt, ApiKey);
|
|
736
|
-
break;
|
|
737
|
-
case 'llama-v3':
|
|
738
|
-
response = await llama3(prompt, ApiKey);
|
|
739
|
-
break;
|
|
740
|
-
case 'gemma':
|
|
741
|
-
response = await gemma(prompt, ApiKey);
|
|
742
|
-
break;
|
|
743
|
-
case 'mixtral-v2':
|
|
744
|
-
response = await mixtral2(prompt, ApiKey);
|
|
705
|
+
case otherChatModel.includes(model):
|
|
706
|
+
response = await otherChatModels({ modelName: model as any, prompt });
|
|
745
707
|
break;
|
|
746
|
-
case
|
|
747
|
-
response = await
|
|
708
|
+
case rsnChatModels.includes(model):
|
|
709
|
+
response = await rsnAPI({ API_KEY: ApiKey, apiName: model, prompt });
|
|
748
710
|
break;
|
|
749
|
-
case
|
|
750
|
-
response = await
|
|
751
|
-
break;
|
|
752
|
-
case 'bing':
|
|
753
|
-
response = await bing({ API_KEY: ApiKey, prompt });
|
|
754
|
-
break;
|
|
755
|
-
case 'gemini-v2':
|
|
756
|
-
response = await gemini_v2({ API_KEY: ApiKey, prompt });
|
|
711
|
+
case groqChatModels.includes(model):
|
|
712
|
+
response = await chatGroq({ API_KEY: ApiKey, apiName: model, prompt, instruction: personality });
|
|
757
713
|
break;
|
|
714
|
+
case model === 'gpt-4o':
|
|
715
|
+
response = await gpt4o({ ApiKey, prompt });
|
|
716
|
+
break;
|
|
758
717
|
default:
|
|
759
718
|
throw new Error('Invalid model.');
|
|
760
719
|
}
|
|
761
720
|
return response;
|
|
762
721
|
}
|
|
763
|
-
async function apexChecker(urls: any) {
|
|
764
|
-
try {
|
|
765
|
-
let retryCount = 0;
|
|
766
|
-
const maxRetries = 3;
|
|
767
|
-
|
|
768
|
-
const fetchData = async () => {
|
|
769
|
-
try {
|
|
770
|
-
const response = await axios.post(
|
|
771
|
-
`https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-base`,
|
|
772
|
-
{ image: urls },
|
|
773
|
-
{
|
|
774
|
-
headers: {
|
|
775
|
-
"Content-Type": "application/json",
|
|
776
|
-
Authorization: `Bearer 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`,
|
|
777
|
-
},
|
|
778
|
-
},
|
|
779
|
-
);
|
|
780
|
-
|
|
781
|
-
if (response.status === 200) {
|
|
782
|
-
return response.data[0].generated_text;
|
|
783
|
-
} else {
|
|
784
|
-
console.error(
|
|
785
|
-
`Failed to fetch image captioning API: ${response.statusText}`,
|
|
786
|
-
);
|
|
787
|
-
return null;
|
|
788
|
-
}
|
|
789
|
-
} catch (e: any) {
|
|
790
|
-
console.error(`Error fetching data: ${e.message}`);
|
|
791
|
-
throw e;
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
|
|
795
|
-
while (retryCount < maxRetries) {
|
|
796
|
-
try {
|
|
797
|
-
return await fetchData();
|
|
798
|
-
} catch (e: any) {
|
|
799
|
-
console.error(
|
|
800
|
-
`Error fetching data (Retry ${retryCount + 1}): ${e.message}`,
|
|
801
|
-
);
|
|
802
|
-
retryCount++;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
return null;
|
|
807
|
-
} catch (e: any) {
|
|
808
|
-
console.error(`Error in attemptImageCaptioning: ${e.message}`);
|
|
809
|
-
return null;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
722
|
|
|
813
723
|
async function checkJobStatus(jobId: string): Promise<string | null> {
|
|
814
724
|
try {
|