Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chatgptk

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chatgptk - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

dist/chain/ask.js

51

dist/index.js
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const readline_1 = require("readline");
const chat_gpt_1 = require("./chat-gpt");
const fs_1 = __importDefault(require("fs"));
const dotenv_1 = __importDefault(require("dotenv"));
const path_1 = require("path");
dotenv_1.default.config({ path: (0, path_1.join)(__dirname, '..', '.env') });
let chatGPT;
if (!process.env.API_KEY) {
console.log('\x1b[90m%s\x1b[0m', 'Please enter your OpenAI API key:');
const readline = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
readline.setPrompt('');
readline.on('line', (line) => {
process.env.API_KEY = line.replace(/\n/g, '').replace(/ /g, '');
readline.close();
});
readline.on('close', async () => {
console.log('\x1b[90m%s\x1b[0m', 'API key set.\n');
fs_1.default.writeFileSync((0, path_1.join)(__dirname, '..', '.env'), `API_KEY=${process.env.API_KEY}`);
chatGPT = new chat_gpt_1.ChatGPT(process.env.API_KEY);
cycle();
});
}
else {
chatGPT = new chat_gpt_1.ChatGPT(process.env.API_KEY);
cycle();
}
function cycle() {
const readline = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
readline.setPrompt('');
let input = '';
console.log('\x1b[33m%s\x1b[0m', 'You:');
readline.on('line', (line) => {
input += line;
readline.close();
});
readline.on('close', async () => {
if (input.length === 0)
process.exit(0);
console.log();
console.log('\x1b[36m%s\x1b[0m', 'ChatGPT:');
await chatGPT.ask(input);
console.log('\n');
cycle();
});
}
const terminal_1 = require("./core/terminal");
const terminal = new terminal_1.Terminal();
terminal.listen();
{
"name": "chatgptk",
"version": "1.0.7",
"version": "1.0.8",
"author": "rhea-so <jeonghyeon.rhea@gmail.com>",

@@ -14,5 +14,7 @@ "license": "MIT",

"dependencies": {
"@creatrip/env-safe": "0.2.4",
"chatgptk": "1.0.0",
"dotenv": "16.0.3",
"eventsource-parser": "0.1.0",
"langchain": "0.0.54",
"lru-cache": "8.0.4",

@@ -26,3 +28,8 @@ "openai": "3.2.1",

"@types/node": "18.15.5"
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"printWidth": 150
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc