GithubHelp home page GithubHelp logo

aandrew-me / tgpt Goto Github PK

View Code? Open in Web Editor NEW
1.7K 32.0 144.0 3.16 MB

AI Chatbots in terminal without needing API keys

License: GNU General Public License v3.0

Go 84.44% Shell 5.38% PowerShell 3.29% JavaScript 6.88%
chatgpt ai chatbot cli go golang gpt3 linux macos terminal windows llama mixtral

tgpt's Introduction

Terminal GPT (tgpt) 🚀

GitHub go.mod Go version GitHub release (latest by date) AUR version

tgpt is a cross-platform command-line interface (CLI) tool that allows you to use AI chatbot in your Terminal without requiring API keys.

Currently available providers:

  • Blackbox AI (Blackbox model)
  • OpenAI (All models, Requires API Key, supports custom endpoints)
  • Groq (Requires a free API Key. LLaMA2-70b & Mixtral-8x7b)
  • Ollama (Supports many models)

Image Generation Model: Craiyon V3

Usage

Usage: tgpt [Flags] [Prompt]

Flags:
-s, --shell                                        Generate and Execute shell commands. (Experimental) 
-c, --code                                         Generate Code. (Experimental)
-q, --quiet                                        Gives response back without loading animation
-w, --whole                                        Gives response back as a whole text
-img, --image                                      Generate images from text
--provider                                         Set Provider. Detailed information has been provided below. (Env: AI_PROVIDER)

Some additional options can be set. However not all options are supported by all providers. Not supported options will just be ignored.
--model                                            Set Model
--key                                              Set API Key
--url                                              Set OpenAI API endpoint url
--temperature                                      Set temperature
--top_p                                            Set top_p
--max_length                                       Set max response length
--log                                              Set filepath to log conversation to (For interactive modes)
-y                                                 Execute shell command without confirmation

Options:
-v, --version                                      Print version 
-h, --help                                         Print help message 
-i, --interactive                                  Start normal interactive mode 
-m, --multiline                                    Start multi-line interactive mode 
-cl, --changelog                                   See changelog of versions 
-u, --update                                       Update program 

Providers:
The default provider is phind. The AI_PROVIDER environment variable can be used to specify a different provider.
Available providers to use: blackboxai, groq, koboldai, ollama, opengpts, openai and phind

Provider: blackboxai
Uses BlackBox model. Great for developers

Provider: groq
Requires a free API Key. Supports LLaMA2-70b & Mixtral-8x7b

Provider: koboldai
Uses koboldcpp/HF_SPACE_Tiefighter-13B only, answers from novels

Provider: ollama
Needs to be run locally. Supports many models

Provider: opengpts
Uses gpt-3.5-turbo only. Do not use with sensitive data

Provider: openai
Needs API key to work and supports various models. Recognizes the OPENAI_API_KEY and OPENAI_MODEL environment variables. Supports custom urls with --url

Provider: phind
Uses Phind Model. Great for developers

Examples:
tgpt "What is internet?"
tgpt -m
tgpt -s "How to update my system?"
tgpt --provider opengpts "What is 1+1"
tgpt --provider openai --key "sk-xxxx" --model "gpt-3.5-turbo" "What is 1+1"
cat install.sh | tgpt "Explain the code"

demo

Installation ⏬

Download for GNU/Linux 🐧 or MacOS 🍎

The default download location is /usr/local/bin, but you can change it in the command to use a different location. However, make sure the location is added to your PATH environment variable for easy accessibility.

You can download it with the following command:

curl -sSL https://raw.githubusercontent.com/aandrew-me/tgpt/main/install | bash -s /usr/local/bin

If you are using Arch Linux, you can install the AUR package with paru:

paru -S tgpt-bin

Or with yay:

yay -S tgpt-bin

FreeBSD 😈

To install the port:

cd /usr/ports/www/tgpt/ && make install clean

To install the package, run one of these commands:

pkg install www/tgpt
pkg install tgpt

Install with Go

You need to add the Go install directory to your system's shell path.

go install github.com/aandrew-me/tgpt/v2@latest

Windows 🪟

  • Scoop: Package installation with Scoop can be done using the following command:

    scoop install https://raw.githubusercontent.com/aandrew-me/tgpt/main/tgpt.json

Updating ⬆️

If you installed the program with the installation script, you may update it with

tgpt -u

It may require admin privileges.

Proxy

Support:

  • Http Proxy [ http://ip:port ]
  • Http Auth [ http://user:pass@ip:port ]
  • Socks5 Proxy [ socks5://ip:port ]
  • Socks5 Auth [ socks5://user:pass@ip:port ]

If you want to use a proxy, create proxy.txt file in the same directory from where you are executing the file and write your proxy configuration there.

Example:

http://127.0.0.1:8080

From Release

You can download the executable for your operating system, rename it to tgpt (or any other desired name), and then execute it by typing ./tgpt while in that directory. Alternatively, you can add it to your PATH environmental variable and then execute it by simply typing tgpt.

Uninstalling

If you installed with the install script, you can execute the following command to remove the tgpt executable

sudo rm $(which tgpt)

Configuration file is usually located in ~/.config/tgpt on GNU/Linux Systems and in "Library/Application Support/tgpt" on MacOS

tgpt's People

Contributors

0axmx-cx avatar 1ray-1 avatar aandrew-me avatar axorax avatar dariodarko avatar eltociear avatar git-aniket avatar graves501 avatar grepsuzette avatar guhitb avatar ibldzn avatar johnd0e avatar muhiris avatar nxjosephofficial avatar orangbilangciperipampam avatar schnz avatar shmilee avatar siuyutpang avatar suxyio avatar vedantwankhade avatar vpsone avatar wildy368 avatar xplshn avatar yinghuo302 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tgpt's Issues

chatbot panic

tgpt panics when asked to help write any program i ask it, and does not complete the program

About updating in windows

Hello, I use this program a lot in my daily life a lot. But why does update function don't work in windows? Some Go binaries don't support it?

Problem with tgpt -u command.

Hi,

If I run the command tgpt -u the script returns this error after asking me my password:

mv: unable to evaluate '/tmp/tgpt': No such file or folder
Failed to update. Error: exit status 1
Successfully updated.

Running it with sudo tgpt -u, it installs but the rights of the /usr/bin/tgpt file are set to 700.
In the install script, you can replace chmod +x with chmod 755 to solve this problem.

Regards.

Bai is stucked to only `ONE prompt`

i dont know why this is happening
image

in image it shows that -->
1st what is austere
2nd explain this with all jargon for 5 year old "Severe or stern in disposition or appearance; somber and grave"
but thsi time tgpt think 1st is the prompt ?? how u can see screenshot
and this goes repeat

[Feature Request] input file contents

Currenlty we can't paste 20 lines of text or code to pass into tgpt. So adding -f for file input mode to pass the contents directly would give more advantage to it.

  • If there is limit to what the server can handle, then we should consider adding limit to file size or lines of code ?

For example : there is a python file with a function

What does someFunction do ?
import os
import sys

def someFunction():
   # Doing something

Directly sending this file as -f and get the output as interactive mode would help developers alot.

introduce word - wrapping

image
see inner words like additionally are breaked up

please introduce ->

  • word wrapping , based on terminal size
  • line break ,
  • very colofull output , being plain text is very plain

panic when running TGPT with -s argument

panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
main.main()
/home/runner/work/tgpt/tgpt/main.go:61 +0x1025

When I ran "tgpt -s" it panicked and spit out this.
But when I use "tgpt -s "update my system" " it works.

Arrow keys dont work in interactive mode

screenshot

Using arrow keys in interactive mode produces these characters. On multiline mode i can navigate with arrow keys properly.

I'm on linux using hyprland wm (wayland). Keyboard layout fi. I tested with alacritty and UXTerm, same happens with both.

%!s(<nil>) error

I was asking random things until it took a long time loading and returned:

%!s(<nil>)

This was also the content of the .config/tgpt/config.txt file. I removed it and that fixed the issue. So far I couldn't reproduce the error again.

Line wrapping

Hello.

Is there any trick or way to use line wrapping (shift + enter)? When you try to send a request with a script, it looks like this:

tgpt 'What does this code do? #!/bin/bash                                                                                                  ~

url=$(xclip -o) 

if [[ $url =~ ^(https?://) ]]; then 
  mpv "$url" --title='${media-title}'
fi
'
What does this code do? #!/bin/bash                                                                                                  ~

url=$(xclip -o) 

if [[ $url =~ ^(https?://) ]]; then 
  mpv \"$url\" --title=title
fi


Error. Your IP is being blocked by the server.
Status Code: 400

[Linux] Please make it so that the update function does not install under /usr/local/bin/

As mentioned in the title, the update function seems to just execute the install script that asks for sudo so as to put it in the /usr/local/bin/ folder. In my case though, tgpt is in ~/bin/ and I would like it to stay there. In plain terminal output

$ which tgpt-linux-amd64 
/home/user/bin//tgpt-linux-amd64

$ tgpt-linux-amd64 --version
tgpt 1.4.2

$ tgpt-linux-amd64 --update
Updating...
[sudo] password for user: 

p.s. I know it is on 1.4.2. I thought the upgrade would bring it to 1.4.3, that's why I used an older version. However, a few minutes earlier I realised that it got a lot of updates in the last 2 days.

`-c` colide

😬
image

this is messed up

also what were you thinking while doing this???

Query returns error 504

I tried to ask something and in return I got this:

Error. Your request is being blocked by the server.
Status Code: 504

Add an interactive mode

Hey , great project I'm personally enjoying it a lot!

I think it should have an interactive mode for entering tgpt with no arguments for just start talking with the IA instead of typing tgpt "<the query>" every time you want to use it. My personal approach would be something like this:

tgpt
> query here
> response here

Probably also consider adding a way to visually differenciate the questions and the answers. Also the program should just wait for an exit command to terminate the interactive session.

Thanks for your effort, I'll try to implement the feature if I have the time.

just wanted to say thank you 😭 ⭐

i can't describe my emotion related to tgpt , it has changed everythign
primaryly changing the way i use internet , i was waster , in searching for info as i often waste time on random website due to search engine and site attraction, which leads me to waste time on useless things,

tgpt is like having a highly experienced BIG brother in EVERY Field
it saves tabs, RAM , performace , FAST AF , my chatgpt takes 50 sec to load my net sucks, no big issue
THANK You so much for creating tgpt

i know tgpt is just bai bot underneath, but the way it never stops you for money/token OpenAI money stealing shit :(
i dont have to care about trial finishing of openAIapi ,

tpgt is just a miracles
also BIG thx to Creater of BAI

here is modified version by tgpt


My emotions towards tgpt have undergone a significant transformation since I started using it. It has completely changed the way I use the
 internet. Previously, I would waste a lot of time searching for information and getting sidetracked by random websites. But now, tgpt has
 become like a highly experienced "big brother" in every field.

The tool is incredibly efficient; it saves tabs, RAM, and improves the performance of my computer. Even when my internet connection is poor,
 tgpt loads quickly, which is impressive. I am grateful for the creation of tgpt because it has made my life so much easier.

Although tgpt is powered by BAI, what sets it apart is that it does not require money or tokens to operate. This is a refreshing change
 from other tools that constantly demand payment. With tgpt, I no longer have to worry about trial periods ending or OpenAI API charges. It
 truly feels miraculous, and I extend my sincere thanks to the creator of BAI for making this innovative tool available.

not work

i told you a command like how do something it not answer nothing.

API Key Error after updating.

API Key Error after updating from Aur. Same problem with older versions. Please, help!
Output: Error: 提供错误的API密钥 | Incorrect API key provided

How to uninstall tgpt

Hello,

I installed TGPT through Powershell this way :

Invoke-WebRequest https://raw.githubusercontent.com/aandrew-me/tgpt/main/install-win.ps1 -OutFile "$PWD\install-win.ps1"; .\install-win.ps1

That completely broke my environment PATH

Can you please tell me how to completely remove TGPT from my computer now ?

tgpt --shell on linux

The -s/--shell argument run the command with exec. This give problems with the core utilities and crash the process.
My suggestion is to use "eval" instate of "exec".

[enhancement] Self Update

Would be great to update tgpt directly from its interface instead of manually installing each time the new release.

An example command for this:

tgpt --update
# or
tgpt -U

jailbreak mode

image
just get the info we want

using external jailbreak prompt is something not good enough which require to open browser, :(
i use tpgt when i dont wnat to open browser

Redirecting stdout not works as intended

When redirecting the output to a file it puts a newline after the end of every single word and it also includes the loading spinner and original question which is not expected.

tgpt "What is the purpose of life" > ans.txt

cat ans.txt

Output:

⣾ Loading
⣽ Loading
⣻ Loading
⢿ Loading
⡿ Loading
⣟ Loading
⣯ Loading
⣷ Loading
⣾ Loading
⣽ Loading
⣻ Loading
⢿ Loading
⡿ Loading
⣟ Loading
⣯ Loading
⣷ Loading
⣾ Loading
⣽ Loading
⣻ Loading
⢿ Loading
⡿ Loading
⣟ Loading
⣯ Loading

What is the purpose of life

The
purpose
of
life
is
a
philosophical
question
that
has
puzzled
humans
for
centuries
.
While
there
is
no
one
"
correct
"
answer
to
this
question
,
some
people
believe
that
the
purpose
of
life
is
to
find
happiness
,
others
believe
that
it
is
to
fulfill
certain
duties
or
obligations
,
and
still
others
believe
that
it
is
to
seek
knowledge
or
spiritual
enlightenment
.
Ultimately
,
the
purpose
of
life
is
a
deeply
personal
and
subjective
matter
that
each
individual
must
explore
and
determine
for
themselves
based
on
their
own
beliefs
,
values
,
and
experiences
.

tgpt knowledge of versions

It would be nice of tgpt could report on version history.

$ tgpt 'what is the difference between tgpt 1.6.4 and tgpt 1.6.5?'
what is the difference between tgpt 1.6.4 and tgpt 1.6.5?

Unfortunately, I'm not aware of any specific product called "TGPT" that corresponds to version numbers 1.6.4 and 1.6.5. Could you please provide more information or context about what you are referring to? That would help me better understand your question and provide a more accurate answer.

Requires GLIBC_2.32 or newer

I am running Debian 11 Stable and it uses GLIBC_2.31.

I installed tgpt via install script. When I try to run tgpt, i get this output below.

$ tgpt
tgpt: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by tgpt)
tgpt: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by tgpt)

[Feature Request] Add an option to inject prompts before asking something

Let me explain, if there was an option for the user to add a prompt before his real prompt, you could have personalities or a custom assistan. For example, whenever I use TGPT I tell it my personal beliefs and political vision so it doesn't generate things I wouldn't believe, other AI projects also use this when they want ChatGPT to do something specific, like generating JSONs, Code, or Shell commands.

PS: Your project is awesome, keep it up. Maybe you can add more back-ends, even Dall-E?

Getting an API key error.

Whenever I enter an input I am getting the following error:

Error: 提供错误的API密钥 | Incorrect API key provided

unable to execute powershell commands in Windows 10

I have installed tgpt in windows 10 to help me with configurations of windows. but when I ask to run a test or a command I'm getting error the command can't be found in path. any help with this? when I run the command by itself it works just fine. This is the case for powershell command. not for DOS commands why is this?
tgpt -s "execute test-netconnection to google.com" Test-NetConnection google.com Execute shell command? [y/n]: y exec: "Test-NetConnection": executable file not found in %PATH%

Option for giving only code

Please add an option to extract only code from result.
Could please also syntax highlighting with bat or some other tool?

Error Launch on Arch Linux, (latest upgrade won't fix)

please fix this, I dont know but it works on my other systems like WSL Ubuntu, and Termux, it fails on my Arch Linux but it used to work before it returns error like this (attached):

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
main.main()
/home/runner/work/tgpt/tgpt/main.go:42 +0xb05
image

[Feature request] Edit prompt with external text editor and log output.

It's nice to use gpt in terminal, but the built-in editor is lacking with essential editing, to not write anything again, like this:

  • move cursor a character (left, right)
  • move cursor a word
  • move to line start
  • move to line end

  • If I press:
    Left Right Up Down Insert Delete Home End PageUp PageDown
    Esc F1-12

  • I get garbage like this:
    ^[[D^[[C^[[A^[[B^[[2~^[[3~^[[1~^[[4~^[[5~^[[6~
    ^[^[OP^[OQ^[OR^[OS^[[15~^[[17~^[[18~^[[19~^[[20~^[[21~^[[23~^[[24~

Some things work, like:

^u: delete all to the left
^w: delete previous word
^i: tab
^d^d: EOF
^j: Enter?
^z: job to background
^c: exit
^v: input literal character
^m: Enter?
  1. Because all of this, maybe you can allow to edit prompts with an external editor (Like: vi, emacs, nano, etc) as an alternative to the built-in editor.

  2. Log output: this useful because, if I copy terminal output (from tmux) to a text editor, lines get hard wrapped to the terminal size, and needs to be fixed.

  3. Maybe there other ways to fix this or has another useful shortcuts, but don't appear at Man, Help, Readme.md or Github at all.


OS: Arch Linux x86_64
Shell: fish 3.6.1
Resolution: 1920x1080
WM: dwm
Terminal: tmux

TTS

Thanks for tgpt, it's amazing!

I briefly searched around but I don't think it's possible right now to plug in some TTS capabilities?

On archlinux for TTS I use package translate-shell (echo this is a test | trans --play) to do TTS, but trying tgpt "Question: Who is Dwight Shrute" speaks hashed words or portion of words.

Anyway, I wonder how we could proceed to have this on tgpt?

Prettier interactive mode

Could you please make interactive mode prettier with colors or symbols like this
image
i have done it using simple bash but i think integrating into "tgpt" would be good

Introduce a command exec mode

Hey, nice project.

I have a very similar one: https://github.com/ekkinox/yo, also in Go.

IMO a big feature for an AI TUI is to offer to run commands from user prompt, I suggest you do the same in your app, it'll bring it a lot more value :)

Also, I suggest you check early how to integrate tests, lint and goreleaser, since you get traction from YouTube, it'll help you in your next iterations ;)

IP Block error

Screenshot from 2023-04-22 19-02-17
It doesn't mention what is the error.
BTW I'm using Fedora Linux 38

Can you use Python to write a simple request for topic

i don't konw why i use python couldn't pass:
url="https://chatbot.theb.ai/api/chat-process"

headers = {
'Content-Length':'93',
'authority':'chatbot.theb.ai',
'Content-Type':'application/json',
"Referer": "https://chatbot.theb.ai/",
"accept": "application/json, text/plain, /",
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
'Cookie':'_ga=''
}
data={
"prompt":"who are you",
"options":{"parentMessageId":"chatcmpl-7Ez7G8eRMBVroyBc7AWxcvr7lzq2U"}
}
data1=json.dumps(data)
resp= requests.post(url,headers=headers,data=data1,timeout=100000)
print(resp)
resp.raise_for_status()
print(resp.status_code, resp.text)

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.