From 250de2a82862b3f70b2760d2a77fc04872609e90 Mon Sep 17 00:00:00 2001 From: zachey <63107653+zachey01@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:37:32 +0500 Subject: [PATCH] Remove GUI --- README.md | 11 ---- src/GUI/index.html | 161 --------------------------------------------- src/bin/main.js | 88 ------------------------- 3 files changed, 260 deletions(-) delete mode 100644 src/GUI/index.html delete mode 100644 src/bin/main.js diff --git a/README.md b/README.md index b8b0973..59e2356 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ This package can be used in Node.js or Browser environments. - [🧠 Google Chrome AI](#google-chrome-ai) - [Setting Browser](#setting-browser) - [Simple Usage](#simple-usage) -- [⌨️ CLI](#cli) - [🧪 Testing](#testing) - [🚧 Building](#building) - [Webpack](#webpack) @@ -301,16 +300,6 @@ const options = { })(); ``` - - -# ⌨️ CLI - -Running GUI: `npx gpt4js --gui --port ` - -![output-onlinetools](https://github.com/zachey01/gpt4free.js/assets/63107653/daa66f93-e32c-4bc7-8157-b4e41815ad5d) - -Usage: `npx gpt4js --model --provider --prompt ` - # 🧪 Testing diff --git a/src/GUI/index.html b/src/GUI/index.html deleted file mode 100644 index 76acd29..0000000 --- a/src/GUI/index.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - GPT4js GUI - - - - - - -
-
- - -
- -
- - -
- -
- - -
-
- - -
- -
- -
- - -
-
- - - - diff --git a/src/bin/main.js b/src/bin/main.js deleted file mode 100644 index 37805ea..0000000 --- a/src/bin/main.js +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env node - -import process from "process"; -import http from "http"; -import fs from "fs"; -import GPT4js from "../../index.js"; - -const args = process.argv.slice(2); - -function parseArgs(args) { - const parsedArgs = {}; - let guiEncountered = false; - - for (let i = 0; i < args.length; i++) { - const arg = args[i]; - - if (arg === "g") { - parsedArgs["gui"] = true; - guiEncountered = true; - - if (args[i + 1] && !args[i + 1].startsWith("--") && !isNaN(args[i + 1])) { - parsedArgs["port"] = args[i + 1]; - i++; - } - } else if (guiEncountered && !parsedArgs["port"] && !isNaN(arg)) { - parsedArgs["port"] = arg; - } else if (arg.startsWith("--")) { - const key = arg.slice(2); - const nextArg = args[i + 1]; - - if (nextArg && !nextArg.startsWith("--")) { - parsedArgs[key] = nextArg; - i++; - } else { - parsedArgs[key] = true; - } - } - } - - return parsedArgs; -} - -const parsedArgs = parseArgs(args); - -if (parsedArgs["gui"]) { - const port = parsedArgs["port"] || 3000; - - const server = http.createServer((req, res) => { - if (req.url === "/") { - const indexPath = "./src/GUI/index.html"; - const indexHtml = fs.readFileSync(indexPath, "utf-8"); - res.writeHead(200, { "Content-Type": "text/html" }); - res.end(indexHtml); - } else { - res.writeHead(404); - res.end(); - } - }); - - server.listen(port, () => { - console.log( - `\x1b[32m✓\x1b[0m Server listening on port \x1b[30;47m${port}\x1b[0m` - ); - }); -} else { - if ((parsedArgs["m"] || parsedArgs["p"]) && !parsedArgs["prompt"]) { - console.error( - "Error: 'prompt' argument is required when 'model' and 'provider' is specified." - ); - process.exit(1); - } - - const messages = [{ role: "user", content: parsedArgs.prompt }]; - const options = { - provider: parsedArgs.provider, - model: parsedArgs.model, - }; - - (async () => { - const provider = GPT4js.createProvider(options.provider); - try { - const text = await provider.chatCompletion(messages, options); - console.log("🤖: " + text); - } catch (error) { - console.error("Error:", error); - } - })(); -}