Giter VIP home page Giter VIP logo

terminalgpt's Introduction

TerminalGPT logo

TerminalGPT logo TerminalGPT logo TerminalGPT logo TerminalGPT logo

Get GPT-like chatGPT on your terminal

TerminalGPT logo

terminalGPT - Use OpenAi like chatGPT, on your terminal | Product Hunt

Stats

TerminalGPT logo

Prerequisites

You'll need to have your own OpenAi apikey to operate this package.

  1. Go to https://platform.openai.com
  2. Select your profile menu and go to View API Keys
  3. Select + Create new secret key
  4. Copy generated key

Installation

Install terminalGPT globally:

npm -g install terminalgpt

or

yarn global add terminalgpt

Start chat

tgpt chat

PS: If it is your first time running it, it will ask for open AI key, paste generated key from pre-requisite steps.

Options

Change engine and temperature

tgpt chat --engine "gpt-4" --temperature 0.7

Note this library uses Chat Completions API. The engine parameter is the same as the model parameter in the API. The default value is gpt-3.5-turbo.

Use markdown

tgpt chat --markdown

Change or delete api key

It you are not satisfied or added a wrong api key, run

tgpt delete

Using with npx

npx terminalgpt
npx terminalgpt <command>

Note npx terminalgpt doesn't install the terminalgpt package, instead it downloads the package to your computer and directly executes it from the cache.

You can find the package using

ls ~/.npm/_npx/*/node_modules

To delete the package, you can use

rm -r ~/.npm/_npx/*/node_modules/terminalgpt

Contributing

Refer to CONTRIBUTING.md 😎

✨ Contributors

terminalgpt's People

Contributors

alsey89 avatar gianpaj avatar glydric avatar jucasoliveira avatar luish avatar nicolello-dev avatar petrgazarov avatar qtnx avatar s4mu3lbk avatar snyk-bot avatar thanhsonng avatar tommy-quitt avatar yaduttam95 avatar zerodotnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terminalgpt's Issues

Can the tgpt show the word in once?

instead showing line by line, can I disable this animation and show the text in once until it finish processing? Moreover Can I disable all the animation include the "Thinking state bar" and the introduction when run tgpt chat in terminal?

TODO 4

  • Allow the CLI read the current project files
  • Refactor code
  • Code Analysis

When running npx terminalgpt chat command in

When running npx terminalgpt chat command in command prompt or PowerShell terminals, get "Something went wrong!! error: request failed with status code 401 Something went wrong!" after entering API key

BUG

*omething went wrong!! Error: Something went wrong!
1 Something went wrong!! Error: Something went wrong!
? Try again? › - Use arrow-keys. Return to submit.
❯ Yes
No - exit

error

[email protected] chat
node bin/index.js chat --engine text-davinci-002 --temperature 0.7

/home/meet/Projects/terminalGPT/bin/utils.js:36
if (request == undefined || !request.data?.choices?.[0].text) {
^

SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/home/meet/Projects/terminalGPT/bin/index.js:9:44)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

TODO 3 : CI/CD

  • Add CI/CD
  • When a user creates PR for the main, GitHub actions will run the test, if any error, block the PR
  • When a PR is merged, bump the package JSON version, create a tag for the version and npm publish
    • Configure GitHub secrets, with npm keys

can't install on Windows for git bash or powershell

fails to install with this output:

npm ERR! code 1
npm ERR! path C:\Users\my_username\AppData\Roaming\npm\node_modules\terminalgpt
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c tsc
npm ERR! 'tsc' is not recognized as an internal or external command,
npm ERR! operable program or batch file.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\my_username\AppData\Local\npm-cache_logs\2023-09-23T20_45_34_003Z-debug-0.log

To Reproduce
inside git bash or cmd or powershell, run this command:
npm -g install terminalgpt

Desktop (please complete the following information):
Windows 10
Using git bash or powershell

Create unit test

  • add test package
  • create the directory structure
  • develop unit tests

using the quickstart method running into an obstacle

deusopus@ancient-rome:~/terminalGPT$ npm run
Lifecycle scripts included in [email protected]:
  test
    jest --ci --coverage --verbose

available via `npm run-script`:
  tgpt
    node bin/index.js
  dev
    node bin/index.js chat --engine text-davinci-002 --temperature 0.7
  tunne
    node bin/index.js chat --engine text-davinci-003 --temperature 0.7 --finetunning true --limit 1
  dev:delete
    node bin/index.js delete

Weird outputs on Mac & Windows

Describe the bug
Terminalgpt is currently returning some weird outputs. I know this is something new because I made a video about this library on the 18th and it was running perfectly. However, today I noticed I couldn't run it from root anymore (as I show in my Youtube video) and had to reinstall in a new folder. Ok... Reinstall.. New API Key, no problem. But still.. the answers I'm getting are really weird and not like before.

I just tested both on Mac and Windows. Had to reinstall on mac too, but I was able to install directly in root. On Mac it doesn't give you random sentences before the answer, but they are nonsense, worse than on windows.

To Reproduce
Steps to reproduce the behavior:

  1. Reinstalled
  2. Add token
  3. Ask anything. After 2 questions, the problems start.

Expected behavior
Well.. I expected to work nicely as it was working earlier :D Specially now that I made a video about this tool.

Screenshots
The whole conversation on windows:
Screenshot 2023-01-24 133255

The whole conversation on mac:
Bildschirmfoto 2023-01-24 um 13 40 55

Desktop (please complete the following information):

  • OS: Windows & macOS Monterey
  • Terminnal : powershell / Terminal

Additional context
I'm a big fan of this library and I hope we can figure this out! :) I wanted to make more videos about it today, and that's when I faced this current issue. Is it just me?

TODO 2

  • Save chat
  • Add ability to send the context of the conversation and receive a better response

npm -g install terminalgpt failed on Mac

% npm -g install terminalgpt
npm ERR! code 2
npm ERR! path /opt/homebrew/lib/node_modules/terminalgpt
npm ERR! command failed
npm ERR! command sh -c tsc
npm ERR! src/utils.ts(17,5): error TS2322: Type 'TerminalRenderer' is not assignable to type 'Renderer'.
npm ERR! The types of 'options.renderer' are incompatible between these types.
npm ERR! Type 'Omit<_Renderer, "constructor"> | null | undefined' is not assignable to type 'Renderer | undefined'.
npm ERR! Type 'null' is not assignable to type 'Renderer | undefined'.

npm ERR! A complete log of this run can be found in: /Users/zhaojianyin/.npm/_logs/2023-11-09T13_20_38_483Z-debug-0.log[
installlog.log
](url)

Error adding api key

Hi there, when after I install and enter my API key, I get this response:

Running on mac m1 chip

__

<(o )___
( ._> /
`---'

usage:
TerminalGPT will ask you to add your OpenAI API key. Don't worry, it's saves on your machine locally.

Terminal will prompt you to enter a message. Type your message and press enter.
Terminal will then prompt you to enter a response. Type your response and press enter.

To exit, type "exit" and press enter.

# Commands

node:internal/crypto/cipher:122
this[kHandle].initiv(cipher, credential, iv, authTagLength);
^

TypeError: Invalid initialization vector
at Decipheriv.createCipherBase (node:internal/crypto/cipher:122:19)
at Decipheriv.createCipherWithIV (node:internal/crypto/cipher:141:3)
at new Decipheriv (node:internal/crypto/cipher:295:3)
at Object.createDecipheriv (node:crypto:149:10)
at decrypt (/usr/local/lib/node_modules/terminalgpt/bin/encrypt.js:23:27)
at getApiKey (/usr/local/lib/node_modules/terminalgpt/bin/encrypt.js:43:29)
at apiKeyPrompt (/usr/local/lib/node_modules/terminalgpt/bin/utils.js:9:16)
at Command. (/usr/local/lib/node_modules/terminalgpt/bin/index.js:24:5)
at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/terminalgpt/node_modules/commander/lib/command.js:482:17)
at /usr/local/lib/node_modules/terminalgpt/node_modules/commander/lib/command.js:1283:65 {
code: 'ERR_CRYPTO_INVALID_IV'
}

Node.js v18.14.0

Any help is appreciated thank you!

CRITICAL: ReferenceError: options is not defined. terminalgpt/bin/utils.js:100:42

Describe the bug
ReferenceError: options is not defined. (terminalgpt/bin/utils.js:100:42)

To Reproduce
Steps to reproduce the behavior:

  1. npx terminalgpt chat
  2. Try Again (Yes)

Expected behavior
Should try Again.

Screenshots

/home/.../.npm/_npx/0e1ec426b0185841/node_modules/terminalgpt/bin/utils.js:100
        generateResponse(apiKey, prompt, options, response);
                                         ^

ReferenceError: options is not defined
    at generateResponse (/home/joseito/.npm/_npx/0e1ec426b0185841/node_modules/terminalgpt/bin/utils.js:100:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Desktop (please complete the following information):

  • OS: ubuntu
  • Terminnal : zsh

TODO

  • Encrypt file to allow only nodejs to read the apiKey
  • Add loader for the async request to openAi
  • Save chat
  • add ability to send the context of the conversation and receive a better response
  • create NPM package of the project

Formatting of Returned Text

When you request a sample python script newlines and formatting does not return correctly-- entire flask script could be on one line.

Updare README

Describe the bug
Create a better readme description for the product

Error

I installed terminalGPT and started using it but when iIask a question I get this output:

why am i getting this error "******************** Welcome to terminalGPT ************************

** ,----------------, ,---------, ** ** ,-----------------------, ," ,"| ** ** ," ,"| ," ," | ** ** +-----------------------+ | ," ," | ** ** | .-----------------. | | +---------+ | ** ** | | | | | | -==----'| | ** ** | | W a r p y . | | | | | | ** ** | | Bad command or | | |/----|'---= | | ** ** | | tgpt:>_ | | | ,/|==== ooo | ; ** ** | | | | | // |(((( [33]| ," ** ** | '-----------------' |,' .;'| |(((( | ," ** ** +-----------------------+ ;; | | |," ** ** /)______________(/ //' | +---------+ ** ** ________/ , ** ** / oooooooooooooooo .o. oooo /, ,'----------- ,' ** ** / ==ooooooooooooooo==.o. ooo= // ,'-{)B ,' ** ** /==============ooo__ooo=/' /,' ** ** '-----------------------------' **

Created by @jucasoliveira: https://github.com/jucasoliveira

TerminalGPT will be maintained by Warpi as Jan 2024. You can check other OS initiavies at:

https://github.com/warpy-ai

usage: TerminalGPT will ask you to add your OpenAI API key. Don't worry, it will be saved(encrypted) on your machine locally.

Terminal will prompt you to enter a message. Type your message and press enter.
Terminal will then prompt you to enter a response. Type your response and press enter.

To exit, type "exit" and press enter.

Commands

exit - Exit the program
delete - Delete the saved API key
chat - Start a chat
--markdown - Show the response in markdown
CopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopyCopy
(node:2952) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) ✔ You: … show me a bat file to generate a text file ■■▶ Thinking...NotFoundError: 404 The model gpt-4-1106-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4. at APIError.generate (/home/shiva/terminalGPT/node_modules/openai/error.js:52:20) at OpenAI.makeStatusError (/home//terminalGPT/node_modules/openai/core.js:251:33) at OpenAI.makeRequest (/home/terminalGPT/node_modules/openai/core.js:290:30) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async exports.default (/home/terminalGPT/lib/gpt.js:19:21) at async generateResponse (/home/terminalGPT/lib/utils.js:98:25) { status: 404, headers: { 'alt-svc': 'h3=":443"; ma=86400', 'cf-cache-status': 'DYNAMIC', 'cf-ray': '844572146dc34895-LIS', connection: 'keep-alive', 'content-encoding': 'gzip', 'content-type': 'application/json; charset=utf-8', date: 'Fri, 12 Jan 2024 12:36:32 GMT', server: 'cloudflare', 'set-cookie': '__cf_bm=fY.Id04XDroOHbHI4CcjV2CaiPKSoXc50k7fZyUFz88-1705062992-1-AdP8Zg4MyMbQ/lRmLel7dRVnm6IQNz8VeIFfgTvfwgcAZ/VHGvqDalReSUCGf520AlWqMvcxNZfXO6Pp4RN5SqU=; path=/; expires=Fri, 12-Jan-24 13:06:32 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=fF3FGV.FopNWrS2t5m9.0PzNfQb34qDPtBacvUX6HYE-1705062992210-0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None', 'strict-transport-security': 'max-age=15724800; includeSubDomains', 'transfer-encoding': 'chunked', vary: 'Origin', 'x-request-id': '5fe2c22a00ea400dac634b8e2ac22ba0' }, error: { message: 'The model gpt-4-1106-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.', type: 'invalid_request_error', param: null, code: 'model_not_found' }, code: 'model_not_found', param: null, type: 'invalid_request_error' }"

Am I missing something? Do i have to install additional stuff or do I have to get anything from OpenAI?

Thanks

Error code 429

I tried the various methods to install, all installed seemingly without issue, but upon running in each on my MacOS 13.2 it gave me the error:

Thinking...Something went wrong!!! Error: Request failed with status code 429
Something went wrong!! Error: Something went wrong!
1 Something went wrong!! Error: Something went wrong!

TypeError: Cannot read properties of undefined (reading 'status')

C:>tgpt chat

**************** Welcome to terminalGPT ****************

 __

<(o )___
( ._> /
`---'

usage:
TerminalGPT will ask you to add your OpenAI API key. Don't worry, it will be saved on your machine locally.

Terminal will prompt you to enter a message. Type your message and press enter.
Terminal will then prompt you to enter a response. Type your response and press enter.

To exit, type "exit" and press enter.

# Commands

√ You: ... hi
Something went wrong!! TypeError: Cannot read properties of undefined (reading 'status')
? Try again? » - Use arrow-keys. Return to submit.

Yes
No - exit

" I'm sorry, I don't understand the question. "

Describe the bug
I'm sorry, I don't understand the question.

To Reproduce
For most of the questions I asked, it always answers the same thing:
" I'm sorry, I don't understand the question. ".

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Desktop (please complete the following information):

  • OS: wsl2 ubuntu on win10
  • Terminnal : [zsh] and tmux

Additional context
I just installed this app and trying it for the first time.

Can't interact with gpt

Hi! Whenever I run

sudo tgpt chat

and try to enter a command, I get this error

■■▶ Thinking...Something went wrong!!! Error: Request failed with status code 429
Something went wrong!! Error: Something went wrong!
1 Something went wrong!! Error: Something went wrong!
? Try again? › - Use arrow-keys. Return to submit.
❯ Yes
No - exit

Any ideas? Thanks!

ReferenceError: options is not defined

Describe the bug
when the utils ask to try again or not it calls the "generateResponse" and pass four parametes instead of three. Also the passed parameter "options" isn't defined.

generateResponse(apiKey, prompt, options, response);

To Reproduce
Steps to reproduce the behavior:

  1. use a large prompt and wait fot the terminal to asks you to try again
  2. choose Yes
  3. See the error

Expected behavior
Regenerate the respone in case choosed "yes" or wai for another prompt for user incase choosed "No".

Screenshots
Screenshot from 2023-04-06 14-35-01

Desktop (please complete the following information):

  • OS: ubuntu 22.04
  • Terminnal : sh

Chat context proposal

  • save and add chat into a JSONL txt file
    • file have to follow the structure: {"prompt": "${context}", "response": "${response.value}"}\n
  • when saved, upload the file to OpenAi
  • store file key(locally)
  • use file as context, sending the file key when requesting a new completion

Feature Request: allow multiline input or one-shot with input from argument or stdin

Feature request

It would be great it it's possible to provide a multiline input to the terminalGTP.

Scenario includes analyzing code snippet but there's probably more.

Expected behavior
One of those would be great but I'm open to other propositions:

  • provide one-shot command like in https://github.com/adamyodinsky/TerminalGPT#one-shot
  • provide cli argument to switch from sending input with Enter to Shift-Enter
    • with this I should be able to start a new line by pressing Enter but to send input to the model I'd have to press Shift-Enter
  • provide functionality to accept input from stdin

Command 'tgpt' not found

Per the readme, I've installed using the yarn option. No errors are indicated during the installation. However, when I run tgpt chat or tgpt at the command line, I get the error Command 'tgpt' not found.

This behavior is the same when installing on Windows as well as WSL (Ubuntu 22.x).

Yarn list shows [email protected] installed.

Hopefully just user error on my part.

On the contrary of the online interface, multilanguage doesnt work

On the contrary of the online interface, multilanguage doesnt work

To Reproduce
Steps to reproduce the behavior:

  1. try give me a sample of EULA for a website selling internet services
  2. try the same in french: donne moi un exemple de CLUF pour un site qui vend des services en ligne

You get both answers in english.

Expected behavior
An answer in english, another in french

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.