apexify.js 4.1.7 → 4.1.8
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/dist/ai/modals-chat/llama.d.ts.map +1 -1
- package/dist/ai/modals-chat/llama.js +10 -2
- package/dist/ai/modals-chat/llama.js.map +1 -1
- package/dist/ai/modals-chat/mixtral.d.ts.map +1 -1
- package/dist/ai/modals-chat/mixtral.js +10 -2
- package/dist/ai/modals-chat/mixtral.js.map +1 -1
- package/dist/ai/modals-chat/openChat.d.ts.map +1 -1
- package/dist/ai/modals-chat/openChat.js +11 -3
- package/dist/ai/modals-chat/openChat.js.map +1 -1
- package/dist/ai/modals-chat/v4.d.ts.map +1 -1
- package/dist/ai/modals-chat/v4.js +10 -2
- package/dist/ai/modals-chat/v4.js.map +1 -1
- package/lib/ai/modals-chat/llama.ts +11 -6
- package/lib/ai/modals-chat/mixtral.ts +12 -7
- package/lib/ai/modals-chat/openChat.ts +11 -6
- package/lib/ai/modals-chat/v4.ts +11 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llama.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/llama.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"llama.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/llama.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB/E"}
|
|
@@ -14,8 +14,16 @@ async function llamaChat({ API_KEY, prompt }) {
|
|
|
14
14
|
});
|
|
15
15
|
return response.data.message;
|
|
16
16
|
}
|
|
17
|
-
catch (
|
|
18
|
-
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
19
|
+
const defaultResponse = await axios_1.default.post(`https://api.rsnai.org/api/v1/user/codellama`, { prompt }, {
|
|
20
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
21
|
+
});
|
|
22
|
+
return defaultResponse.data.message;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
exports.llamaChat = llamaChat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llama.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/llama.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"llama.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/llama.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AAOlD,KAAK,UAAU,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAa;IAC5D,MAAM,MAAM,GAAW,OAAO,IAAI,gCAAgC,CAAC;IAEnE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAkB,MAAM,eAAK,CAAC,IAAI,CAAC,6CAA6C,EAAE,OAAO,EAAE;YACvG,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE;SAC/C,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,KAAK,kBAAkB,EAAE,CAAC;YACjE,MAAM,eAAe,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,6CAA6C,EAAE,EAAE,MAAM,EAAE,EAAE;gBAClG,OAAO,EAAE,EAAE,aAAa,EAAE,uCAAuC,EAAE;aACpE,CAAC,CAAC;YACH,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,wCAAwC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AApBD,8BAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixtral.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/mixtral.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"mixtral.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/mixtral.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB7E"}
|
|
@@ -14,8 +14,16 @@ async function mixtral({ API_KEY, prompt }) {
|
|
|
14
14
|
});
|
|
15
15
|
return response.data.message;
|
|
16
16
|
}
|
|
17
|
-
catch (
|
|
18
|
-
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
19
|
+
const defaultResponse = await axios_1.default.post(`https://api.rsnai.org/api/v1/user/mixtral`, { prompt }, {
|
|
20
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
21
|
+
});
|
|
22
|
+
return defaultResponse.data.message;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
exports.mixtral = mixtral;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixtral.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/mixtral.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"mixtral.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/mixtral.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AAOlD,KAAK,UAAU,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAa;IAC1D,MAAM,MAAM,GAAW,OAAO,IAAI,gCAAgC,CAAC;IAEnE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAkB,MAAM,eAAK,CAAC,IAAI,CAAC,2CAA2C,EAAE,OAAO,EAAE;YACrG,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE;SAC/C,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,KAAK,kBAAkB,EAAE,CAAC;YACjE,MAAM,eAAe,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,2CAA2C,EAAE,EAAE,MAAM,EAAE,EAAE;gBAChG,OAAO,EAAE,EAAE,aAAa,EAAE,uCAAuC,EAAE;aACpE,CAAC,CAAC;YACH,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,wCAAwC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AApBD,0BAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openChat.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/openChat.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"openChat.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/openChat.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB9E"}
|
|
@@ -9,13 +9,21 @@ async function openChat({ API_KEY, prompt }) {
|
|
|
9
9
|
const apiKey = API_KEY || 'rsnai_SbLbFcwdT2h2KoYet2LS0F34';
|
|
10
10
|
try {
|
|
11
11
|
const payload = { prompt: prompt };
|
|
12
|
-
const response = await axios_1.default.post(`https://api.rsnai.org/api/v1/user/
|
|
12
|
+
const response = await axios_1.default.post(`https://api.rsnai.org/api/v1/user/openChat`, payload, {
|
|
13
13
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
14
14
|
});
|
|
15
15
|
return response.data.message;
|
|
16
16
|
}
|
|
17
|
-
catch (
|
|
18
|
-
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
19
|
+
const defaultResponse = await axios_1.default.post(`https://api.rsnai.org/api/v1/user/openChat`, { prompt }, {
|
|
20
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
21
|
+
});
|
|
22
|
+
return defaultResponse.data.message;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
exports.openChat = openChat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openChat.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/openChat.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"openChat.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/openChat.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AAOlD,KAAK,UAAU,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAa;IAC3D,MAAM,MAAM,GAAW,OAAO,IAAI,gCAAgC,CAAC;IAEnE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAkB,MAAM,eAAK,CAAC,IAAI,CAAC,4CAA4C,EAAE,OAAO,EAAE;YACtG,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE;SAC/C,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,KAAK,kBAAkB,EAAE,CAAC;YACjE,MAAM,eAAe,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,4CAA4C,EAAE,EAAE,MAAM,EAAE,EAAE;gBACjG,OAAO,EAAE,EAAE,aAAa,EAAE,uCAAuC,EAAE;aACpE,CAAC,CAAC;YACH,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,wCAAwC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AApBD,4BAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/v4.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../../../lib/ai/modals-chat/v4.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBxE"}
|
|
@@ -14,8 +14,16 @@ async function v4({ API_KEY, prompt }) {
|
|
|
14
14
|
});
|
|
15
15
|
return response.data.message;
|
|
16
16
|
}
|
|
17
|
-
catch (
|
|
18
|
-
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
19
|
+
const defaultResponse = await axios_1.default.post(`https://api.rsnai.org/api/v1/user/gpt4`, { prompt }, {
|
|
20
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
21
|
+
});
|
|
22
|
+
return defaultResponse.data.message;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
exports.v4 = v4;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v4.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/v4.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"v4.js","sourceRoot":"","sources":["../../../lib/ai/modals-chat/v4.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AAOlD,KAAK,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAa;IACrD,MAAM,MAAM,GAAW,OAAO,IAAI,gCAAgC,CAAC;IAEnE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAkB,MAAM,eAAK,CAAC,IAAI,CAAC,wCAAwC,EAAE,OAAO,EAAE;YAClG,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE;SAC/C,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,KAAK,kBAAkB,EAAE,CAAC;YACjE,MAAM,eAAe,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,wCAAwC,EAAE,EAAE,MAAM,EAAE,EAAE;gBAC7F,OAAO,EAAE,EAAE,aAAa,EAAE,uCAAuC,EAAE;aACpE,CAAC,CAAC;YACH,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,wCAAwC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AApBD,gBAoBC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosResponse } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
2
|
|
|
3
3
|
interface aiOptions {
|
|
4
4
|
API_KEY?: string | null;
|
|
@@ -10,14 +10,19 @@ export async function llamaChat({ API_KEY, prompt }: aiOptions): Promise<string>
|
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
const payload = { prompt: prompt };
|
|
13
|
-
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/codellama`,
|
|
14
|
-
payload,
|
|
15
|
-
{
|
|
13
|
+
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/codellama`, payload, {
|
|
16
14
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
return response.data.message;
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
18
|
+
} catch (e: any) {
|
|
19
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
20
|
+
const defaultResponse = await axios.post(`https://api.rsnai.org/api/v1/user/codellama`, { prompt }, {
|
|
21
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
22
|
+
});
|
|
23
|
+
return defaultResponse.data.message;
|
|
24
|
+
} else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosResponse } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
2
|
|
|
3
3
|
interface aiOptions {
|
|
4
4
|
API_KEY?: string | null;
|
|
@@ -10,14 +10,19 @@ export async function mixtral({ API_KEY, prompt }: aiOptions): Promise<string> {
|
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
const payload = { prompt: prompt };
|
|
13
|
-
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/mixtral`,
|
|
14
|
-
payload,
|
|
15
|
-
{
|
|
13
|
+
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/mixtral`, payload, {
|
|
16
14
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
17
15
|
});
|
|
18
|
-
|
|
16
|
+
|
|
19
17
|
return response.data.message;
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
18
|
+
} catch (e: any) {
|
|
19
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
20
|
+
const defaultResponse = await axios.post(`https://api.rsnai.org/api/v1/user/mixtral`, { prompt }, {
|
|
21
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
22
|
+
});
|
|
23
|
+
return defaultResponse.data.message;
|
|
24
|
+
} else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosResponse } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
2
|
|
|
3
3
|
interface aiOptions {
|
|
4
4
|
API_KEY?: string | null;
|
|
@@ -10,14 +10,19 @@ export async function openChat({ API_KEY, prompt }: aiOptions): Promise<string>
|
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
const payload = { prompt: prompt };
|
|
13
|
-
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/
|
|
14
|
-
payload,
|
|
15
|
-
{
|
|
13
|
+
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/openChat`, payload, {
|
|
16
14
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
return response.data.message;
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
18
|
+
} catch (e: any) {
|
|
19
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
20
|
+
const defaultResponse = await axios.post(`https://api.rsnai.org/api/v1/user/openChat`, { prompt }, {
|
|
21
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
22
|
+
});
|
|
23
|
+
return defaultResponse.data.message;
|
|
24
|
+
} else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
}
|
package/lib/ai/modals-chat/v4.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosResponse } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
2
|
|
|
3
3
|
interface aiOptions {
|
|
4
4
|
API_KEY?: string | null;
|
|
@@ -10,14 +10,19 @@ export async function v4({ API_KEY, prompt }: aiOptions): Promise<string> {
|
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
const payload = { prompt: prompt };
|
|
13
|
-
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/gpt4`,
|
|
14
|
-
payload,
|
|
15
|
-
{
|
|
13
|
+
const response: AxiosResponse = await axios.post(`https://api.rsnai.org/api/v1/user/gpt4`, payload, {
|
|
16
14
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
return response.data.message;
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
18
|
+
} catch (e: any) {
|
|
19
|
+
if (e.response && e.response.data.message === 'Invalid API key.') {
|
|
20
|
+
const defaultResponse = await axios.post(`https://api.rsnai.org/api/v1/user/gpt4`, { prompt }, {
|
|
21
|
+
headers: { Authorization: `Bearer rsnai_SbLbFcwdT2h2KoYet2LS0F34` },
|
|
22
|
+
});
|
|
23
|
+
return defaultResponse.data.message;
|
|
24
|
+
} else {
|
|
25
|
+
return 'The API is on cooldown for 50 seconds.';
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
}
|