Comparing version 1.0.9 to 1.1.0
@@ -0,0 +0,0 @@ |
@@ -17,2 +17,4 @@ module.exports = { | ||
Import: require("./lib/import/main.js"), | ||
Collection: require("./lib/collection/main.js"), | ||
}; |
@@ -0,0 +0,0 @@ class Embed { |
@@ -0,0 +0,0 @@ const Embed = require("./embed.js"); |
@@ -0,0 +0,0 @@ class Executor { |
@@ -0,0 +0,0 @@ async function Import(module) { |
const Buffer = require('node:buffer').Buffer; | ||
class NextChat { | ||
constructor() { | ||
this.cache = new Map(); | ||
} | ||
static #chatModels = ["gpt4o", "claude", "gemini", "llama-vision", "gemma2-9b", "gemma-7b", "groq-70b", "groq-8b", "llama3-70b", "llama3-8b", "llama3-1b", "llama3-3b", "llama3-11b", "llama3-90b", "llama-guard"]; | ||
static #chatModels = ["gpt4o", "gemini", "llama-vision", "gemma2-9b", "gemma-7b", "groq-70b", "groq-8b", "llama3-70b", "llama3-8b", "llama3-1b", "llama3-3b", "llama3-11b", "llama3-90b", "llama-guard"]; | ||
static #imgModels = ["animagen", "prodia", "mageai", "xl3"]; | ||
static cache = new Map(); | ||
@@ -16,14 +13,14 @@ static async ask(prompt, options = {}) { | ||
if (options.cache && this.cache.has(cacheKey)) { | ||
return this.cache.get(cacheKey); | ||
if (options.cache && NextChat.cache.has(cacheKey)) { | ||
return NextChat.cache.get(cacheKey); | ||
} | ||
try { | ||
const resp = await NextChat.#fetchData(prompt, options.model, options.imgUrl = ""); | ||
const response = await NextChat.#fetchData(prompt, options.model); | ||
if (options.cache) { | ||
this.cache.set(cacheKey, resp); | ||
NextChat.cache.set(cacheKey, response); | ||
} | ||
return resp.answer; | ||
return response.answer; | ||
} catch (err) { | ||
@@ -39,4 +36,8 @@ throw new Error("NextChat error: " + err); | ||
const blob = await NextChat.#fetchData(prompt, options.model); | ||
const arrayBuffer = await blob.arrayBuffer(); // Convert Blob to ArrayBuffer | ||
return Buffer.from(new Uint8Array(arrayBuffer)).toString('base64'); // Convert to base64 | ||
if (options.model === "prodia") { | ||
return blob; | ||
} | ||
return Buffer.from(new Uint8Array(await blob.arrayBuffer())).toString('base64'); | ||
} catch (err) { | ||
@@ -50,4 +51,4 @@ throw new Error("NextChat error: " + err); | ||
const blob = await NextChat.#fetchData(url, "upscale"); | ||
const arrayBuffer = await blob.arrayBuffer(); // Convert Blob to ArrayBuffer | ||
return Buffer.from(new Uint8Array(arrayBuffer)).toString('base64'); // Convert to base64 | ||
return Buffer.from(new Uint8Array(await blob.arrayBuffer())).toString('base64'); | ||
} catch (err) { | ||
@@ -61,4 +62,4 @@ throw new Error("NextChat error: " + err); | ||
const blob = await NextChat.#fetchData(txt, "tts"); | ||
const arrayBuffer = await blob.arrayBuffer(); // Convert Blob to ArrayBuffer | ||
return Buffer.from(new Uint8Array(arrayBuffer)).toString('base64'); // Convert to base64 | ||
return Buffer.from(new Uint8Array(await blob.arrayBuffer())).toString('base64'); | ||
} catch (err) { | ||
@@ -79,31 +80,30 @@ throw new Error("NextChat error: " + err); | ||
static async #fetchData(prompt, model, imgUrl = "") { | ||
const apiUrl = "https://aryanchauhanapi2.onrender.com/"; | ||
if (NextChat.#chatModels.includes(model)) { | ||
if (model === "gemini") { | ||
return await (await fetch(`${api}gemini?prompt=${prompt}`)).json(); | ||
return await (await fetch(`${apiUrl}gemini?prompt=${prompt}`)).json(); | ||
} | ||
if (model === "llama-vision") { | ||
return await (await fetch(`${api}api/llama-vision?prompt=${prompt}&imageUrl=${imgUrl}`)).json(); | ||
return await (await fetch(`${apiUrl}api/llama-vision?prompt=${prompt}&imageUrl=${imgUrl}`)).json(); | ||
} | ||
if (model === "claude") { | ||
return await fetch(`${api}api/cloud3?prompt=${prompt}`); | ||
} | ||
return await (await fetch(`${api}api/${model}?prompt=${prompt}`)).json(); | ||
return await (await fetch(`${apiUrl}api/${model}?prompt=${prompt}`)).json(); | ||
} else if (NextChat.#imgModels.includes(model)) { | ||
if (model === "animagen") { | ||
return await (await fetch(`${api}api/animagen?prompt=${prompt}`)).blob(); | ||
return await (await fetch(`${apiUrl}api/animagen?prompt=${prompt}`)).blob(); | ||
} | ||
if (model === "prodia") { | ||
return await (await fetch(`${api}v1/generate?prompt=${prompt}`)).json(); | ||
return await (await fetch(`${apiUrl}v1/generate?prompt=${prompt}`)).json(); | ||
} | ||
if (model === "mageai") { | ||
return await (await fetch(`${api}api/mageai?prompt=${prompt}`)).blob(); | ||
return await (await fetch(`${apiUrl}api/mageai?prompt=${prompt}`)).blob(); | ||
} | ||
if (model === "xl3") { | ||
return await (await fetch(`${api}/xl3?prompt=${prompt}`)).blob(); | ||
return await (await fetch(`${apiUrl}/xl3?prompt=${prompt}`)).blob(); | ||
} | ||
} else if (model === "upscale") { | ||
return await (await fetch(`${api}/api/4k?url=${prompt}`)).blob(); | ||
return await (await fetch(`${apiUrl}/api/4k?url=${prompt}`)).blob(); | ||
} else if (model === "tts") { | ||
return await (await fetch(`${api}tts?text=${prompt}`)).blob(); | ||
return await (await fetch(`${apiUrl}tts?text=${prompt}`)).blob(); | ||
} else { | ||
@@ -115,4 +115,2 @@ throw new Error(`NextChat Error: Invalid model: ${model}`); | ||
const api = "https://aryanchauhanapi.onrender.com/"; | ||
module.exports = NextChat; | ||
module.exports = NextChat; |
@@ -36,3 +36,3 @@ class Random { | ||
static async #fetchByType(type, query) { | ||
const API_URL = "https://aryanchauhanapi.onrender.com/api/"; | ||
const API_URL = "https://aryanchauhanapi2.onrender.com/api/"; | ||
const url = `${API_URL}${type}${query ? `?name=${query}` : ""}`; | ||
@@ -39,0 +39,0 @@ |
@@ -0,0 +0,0 @@ const http = require("node:http"); |
@@ -0,0 +0,0 @@ class Middleware { |
@@ -0,0 +0,0 @@ class Request { |
@@ -0,0 +0,0 @@ class Response { |
@@ -0,0 +0,0 @@ class Route { |
@@ -0,0 +0,0 @@ class Search { |
@@ -0,0 +0,0 @@ class Xio { |
{ | ||
"name": "enplex.js", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "Enplex is a versatile JavaScript library. providing a unified interface for multiple APIs and services, Enplex empowers developers to build innovative solutions efficiently.", | ||
@@ -66,11 +66,8 @@ "main": "compiler.js", | ||
"type": "git", | ||
"url": "https://github.com/iscordian/Enplexjs" | ||
"url": "https://github.com/OpenDevsFlow/Enplexjs.git" | ||
}, | ||
"homepage": "https://github.com/iscordian/Enplexjs", | ||
"homepage": "https://github.com/OpenDevsFlow/Enplexjs", | ||
"devDependencies": { | ||
"@types/node": "^22.9.0" | ||
}, | ||
"dependencies": { | ||
"enplex.js": "^1.0.7" | ||
} | ||
} | ||
} |
@@ -0,0 +0,0 @@ <p align = "center"> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
25
483
18
34575
- Removedenplex.js@^1.0.7