Help Setting Up An SSH Command Line Chat Interface To Google Gemini?
A few days ago I mentioned setting up a command line interface (CLI) to Google Geminii. What I am looking for initially is a chat interface to and from Gemini running on a Debian sid Intel i9-13900 remote server that I can access and use by ssh. Initially, I am not looking for a self-hosted Gemini web interface running on the remote server. The ssh capable interface on the remote server should send queries to Gemini and receive and print Gemini's responses.
I am looking for a chat interface, not just something for single questions. See the discussion of the difference between single queries and chat queries at raymondcamden.com
Before long I might hope for a CLI chat interface to more AIs than just Google Gemini. Ideally there might even be a fully open source interface to fully open source AI implementations.
Eventually I might even want a graphical interface. But for right now, I'm focussing on a four part process: (1) ssh from my Chromebook to command line on the remote server, (2) then from the remote server to Google Gemini, (3) response sent from Gemini back to the remote server, and finally (4) back to me via ssh -- unless I find something which provides more options while still including the ssh CLI to Gemini and back starting option.
The initial step might be to figure out what project I might try to use. Looking around, I found projects written in different languages, including Javascript, Python, and . . . Lua + Ruby and more! I've been looking at the GitHub Topics page for Google Gemini, which lists 149 repositories.
Lua + Ruby
Today I found out about Nano Bots, which the linked repository says consists of Lua 66.1% and Ruby 33.9%. Nano Bots seems to provide a command line interface for Google Gemini as well as other AIs. But, happily, the video on the Nano Bots Github page seems to show exactly what I think I might want (assuming it's a command line interface that I use via ssh and not a web interface providing a command line interface):
LuaJIT
I haven't found a LuaJIT CLI interface to Gemini. I haven't found a LuaJIT interface to any AI.
I had no idea, when I first saw Lua a few days ago while upgrading Apache, that I was going to find out about the existence of the Luajit scripting language that is might be 285.63 times faster than Python3 in at least in one application.
Python
@suh kindly suggested binou (also Python) but I'm unsure whether biniou provides the ssh CLI that I want. biniou's About listing describes itself as "a self-hosted webui for 30+ generative ai"
Go
Looks like the eliben interface does more than than the reugn interface.
Javascript
PHP/Laravel
Rust
This rust project's About actually describes itself as "simple:" "A simple command line wrapper for Google Gemini"
Google Tutorial
I found Tutorial: Get started with the Gemini API | Google for Developers
API Key
I already have a Gemini API key, so that part is taken care of.
Questions
Does anybody know of or use additional projects which provide an ssh CLI interface to Google Gemini?
Am I misunderstanding that the Nano Bots interface is ssh? Is it really a web interface?
Is LuaJIT, without more, incapable of interfacing with Gemini?
I'm tempted to try one interface in Python, one in Go, one in Javascript, one in PHP or Laravel, that one in Rust, and one in Lua/LuaJIT. Might be fun, but that seems like too many. So, which one to try first?
Which would be the most beginner friendly implementation?
I hope everyone gets the servers they want!
Comments
Just for fun, I shared the above OP with Google Gemini. Here is a link to what Gemini had to say:
https://g.co/gemini/share/b83cedc5a61d
Please click the "v" Expand Text link to see the entire prompt sent to Gemini.
I hope everyone gets the servers they want!
A kind person suggested that I try this search on DuckDuckGo:
https://duckduckgo.com/?q=llm+chat+interface+command+line+for+google+gemini&ia=web
Although I already knew about the first two DDG results (which are listed in the OP),
https://github.com/eliben/gemini-cli
and
https://github.com/reugn/gemini-cli
I did not know about the third and fourth results. The third result is a blog post explaining the eliben/gemini-cli project that was the first result. eliben/gemini-cli is programmed in Go. Here is a quote from the blog post that's relevant to my wish for a simple, ssh interface:
The fourth result is new to me. Its about section says, "Straightforward command line chat for the Google gemini-pro LLM including 2 templates for injecting info from wikipedia and howdoi into the prompts." It's programmed in Python.
Thanks to the kind person who provided the above link to the DuckDuckGo search!
I hope everyone gets the servers they want!
ssh access to llm via command line chat tool (without local install) = bliss
blog | exploring visually |
Installing eliben/gemini-cli
After reading gemini-cli: Access Gemini models from the command-line on Eli Bendersky's website I decided to try Eli's eliben/gemini-cli. I cloned the sources off Github so I could take a look. Then I needed to install Go and also to perform the eliben/gemini-cli installation.
Installing Go is a little different with Debian apt than untarring the Go files as recommended on the Go website's Download page. One difference is that Debian apt puts the Go files in /usr/lib/ whereas the Go website recommends /usr/local.
One advantage of the Go website's untar install is that the installed version might be newer than whatever is available in a Linux distribution's repositories. However, Debian unstable/sid offers two Go packages, golang-go and golang-1.22-go. golang-go seems to be 1.22.3 and golang-1.22-go seems to be 1.22.5, which actually corresponds to the current release version offered on the Go website. Since apt's golang-1.22-go package seems to provide the same current release version as offered on the Go website, I decided to use the apt golang-1.22-go package for my install.
The next step is to install eliben/gemini-cli following the one line install instruction which appears both in the blog post and in the Github repository's README.md.
Set the $PATH environment variable, and log out.
Log in again to check that the new PATH and gemini-cli are working.
Next is to add the API key according to the following instructions quoted from the eliben/gemini-cli Github README.md.
I tried accessing Gemini to get a list of available models. Here's what I saw.
eliben/gemini-cli looks like it might work for me! It's getting late here, so more soon! This was fun!
If anyone catches a mistake that I made here or has additional suggestions or comments, I'd be grateful!
I hope everyone gets the servers they want!
that's quite a progress, Sir,
From "How do I" to "How To" in a matter of days!
blog | exploring visually |
@vyas Thanks for your kind words!
When I originally posted this thread, I really didn't know what to do. I've learned a little, but I'm still vastly ignorant clueless!™
For example, I had no idea that the Google Gemini API Free Tier wasn't available in Finland where one of my servers is located!
Happily, the Google Gemini Pay-as-you-go pricing doesn't seem bad, at least at my usage for a few handwritten chats. Am I guessing right -- approximately $1.50 per million tokens?
From my Chromebook, presently visiting in Mexico:
From my server in Finland:
I hope everyone gets the servers they want!
groq seems to have caught the fancy of the volken … speedy, multiple LLM option, decent daily limits too !
Was trying a similar setup as yours with them, so far a bit of struggle.
Gemini is cool
blog | exploring visually |
Thank you @vyas!
My first time hearing about groq!
Are you using https://github.com/sanity-io/groq-cli?
Thanks again!
I hope everyone gets the servers they want!
Above I posted the little
curl
command which Google Gemini presents on its Get API key page. The idea is that you can run thecurl
command as a fast, easy way to confirm whether your API key is working or not.Of course, if you love command line and
curl
and also love getting your results in JSON, you can use Google Gemini's little curl command to talk with Gemini.Here below is using
sed
to substitute "What is a cat?" for the curl command's built-in "Explain how AI works" and then piping the result to bash. Gemini returns its answer as a single long line which extends way out to the right here at LES but which wraps in my terminal interface. I guess one could usejq
or similar and not bother with an interface to Gemini.I hope everyone gets the servers they want!
LLMs via SSH can be done but isn't really a thing due to limited practicality.
It's all either API (openAI format has become industry standard), or via a web UI, or straight into code via a python module etc.
For a webUI I'd suggest:
https://github.com/open-webui/open-webui
You can put a tool like LiteLLM in between...sorta like a API proxy of sorts that can help standardize the various providers implementations
Or you can look at something like openrouter.ai...also proxy like thing but its hosted and they have loads of models so you load say $5 credits and then can play with any
If you're on a GPU server something like text-generation-webui is probably best (or just straight llama.cpp)
Skipping the SSH part would ease the journey significantly.
If you really want a SSH bot, you could build one yourself fairly easily. e.g. the langgraph quickstart tutorial is a basic chatbot
https://langchain-ai.github.io/langgraph/tutorials/introduction/#part-1-build-a-basic-chatbot
Might explain preference for cli + ssh for gemini
https://www.tomshardware.com/tech-industry/artificial-intelligence/gemini-ai-caught-scanning-google-drive-hosted-pdf-files-without-permission-user-complains-feature-cant-be-disabled
blog | exploring visually |
In addition to the reason @vyas mentioned, even more reasons for installing gemini-cli are very well explained in Eli Bendersky's excellent blog post.
I hope everyone gets the servers they want!
As mentioned above, access to the Google Gemini API seems to be free from the location in Mexico where I currently am visiting but not from my server's location in Finland.
Therefore, yesterday, I tried installing Go with
apt-get
and then installing eliben/gemini-cli inside the Crostini Debian 12 Linux container running in my Duet 5 Chromebook. This approach did not work, possibly because eliben/gemini-cli seems to want a newer version of Go than Debian 12'sapt-get
wants to install.The problem seen yesterday on my Chromebook might be similar to Go Issue 61888: cmd/go, x/mod: "invalid go version" message mentions old version format.
On my server, I had used
apt-get
to install Go, because the server's Debian unstable/sid'sapt-get
can install Go's current version, which seems to work fine with eliben/gemini-cli.Go's Download and install page suggests downloading and untarring a binary of the current 1.22.5 version of Go. Installing the official Go binary on my Chromebook seems easy enough, but I haven't tried it yet. Probably it might be a good idea to remove the
apt-get
installed Go before trying the Go official binary install.Another possible fix might be try to get a Debian unstable/sid Crostini container working on my Chromebook. However, I don't want to mess with my default Crostini container, which is my escape portal to my servers. And, by default, Chromebooks apparently do not yet enable creating multiple Crostini containers. There is chrome://flags#crostini-multi-container but it's not clear to me how it all might work out to try a second Crostini container running Debian unstable/sid.
Given the situation it looks like I am going to try removing my Chromebook Crostini container's presently
apt-get
installed Go and replacing it with the official Go binary install from https://go.dev/doc/install.Presumably Debian has a good reason for not making the current Go version available in Debian 12's
apt-get
. Of course, a major concept behind Debian stable is that packages have been out for awhile and are expected to be less likely to cause problems. However, I've not yet seen a discussion -- explicitly with respect to Go -- of this version compatibility issue either from the perspective of the Debian maintainer or from the perspective of the Go Team. Does anybody have a link for me? Thanks!I hope everyone gets the servers they want!
Can't you just do a simple proxy to bypass the geolock?
As a sidenote, Gemma-2-27B will be substantially cheaper (~0.3) than Gemini and ends up about same on leaderboards:
https://chat.lmsys.org/?leaderboard
its not free in Europe because by not paying in NA they are explicitly using the data you give them to train. If you pay in NA they do not train or store the data but if free they store forever and train on as much as you send.
Sure, but only if our friends at Google knew about the proxy and approved in advance.
Thanks for telling me about Gemma-2-27B, which I haven't yet tried. However, for the moment, in allowed locations, gemini-1.5-pro-latest is available for free via the Gemini API. I don't know about Gemma-2-27B since I haven't tried it. However, after some weeks of using the Gemini model which is available on my Chromebook via Google One, the gemini-1.5-pro-latest seems to be a substantial step up.
Thanks also for telling me about https://chat.lmsys.org/?leaderboard, which I haven't seen before. The page says, "We've collected over 1,000,000 human pairwise comparisons to rank LLMs with the Bradley-Terry model and display the model ratings in Elo-scale. You can find more details in our paper."
I appreciate your helpful suggestions! Thanks again!
I hope everyone gets the servers they want!
oh - didn't know pro is currently free on API too (well outside of europe)! Had just assumed its the lower one. Makes sense to use it then
Yeah its probably the most trusted leaderboard since it's blind side by side comparisons rather than synthetic benchmarks. You literally can't game it & no risk of dataset contamination like the synthetics.
Installing Go And eliben/gemini-cli On A Chromebook
eliben/gemini-cli now seems to be working inside the Linux Debian 12 Crostini container on my Lenovo Duet 5 Chromebook.
To get eliben/gemini-cli working I first had to remove the older, incompatible version of Go which had been installed with
apt-get
. As explained above eliben/gemini-cli didn't work with the older version of Go,After removing the old Go, I reinstalled the latest Go release approximately following the official instructions at https://go.dev/doc/install. During the reinstall I made an SHA256SUM file. I like to keep the SHA256 sums handy because I am often backing up or reinstalling elsewhere, so it's good to keep permanently available a convenient way of verifying the file integrity.
Adjusting the Chromebook container's PATH environment variable also was required so that the shell could find the newly installed Go and gemini-cli binaries.
After reinstalling Go, I of course had to install eliben/gemini-cli. I did the eliben/gemini-cli install in my home directory.
Additionally, I set an environment variable so that gemini-cli could get my Google AI Studio API key. You can get your key for free from the same linked API key page.
I did a quick test of everything by asking Google Gemini the example Simple single prompt question, "Why is the sky blue?" shown in the eliben/gemini-cli README.md. It seems like everything might be working okay. Thanks to eliben/gemini-cli, my Chromebook now can talk directly with Google Gemini from the command line.
Below are a few notes I made of the command line output seen during various steps of the install.
The ed and ex editors are great for showing others exactly what happened in the editor.
Tar is really old, and so doesn't need the modern "-" in front of the tvzf and xvf flags.
The lines in Gemini's responses are folded nicely in my terminal, but not here on LES.
I hope everyone gets the servers they want!
Is gemini-1.5-pro-latest Significantly Better?
Just for a fun comparison, here's a reply to "Why is the sky blue?" from gemini-1.5-pro-latest. Please compare this response with the above response given during the eliben/gemini-cli Chromebook install.
Initially I'm pasting the command line output copied from my terminal, but without added Github fences. Therefore, initially, long lines will fold here.
The raw Gemini terminal output is in markdown, so, when pasted here, certain items do display here according to the markdown.
Further below, for comparison, I'm repasting the identical gemini-1.5-pro-latest terminal output, but with Github fences added. Except for the lines not folding, the output looks the same as in my terminal.
chronos@penguin:~$ gemini-cli prompt "why is the sky blue?" --model "gemini-1.5-pro-latest"
The sky appears blue due to a phenomenon called Rayleigh scattering. Here's a breakdown:
1. Sunlight Enters the Atmosphere:
- Sunlight is made up of all the colors of the rainbow.
- When sunlight enters the Earth's atmosphere, it collides with tiny particles of air, like nitrogen and oxygen molecules.
2. Scattering of Light:
- These air molecules are much smaller than the wavelengths of visible light.
- This size difference causes the sunlight to scatter in all directions.
- Rayleigh scattering states that shorter wavelengths of light (blue and violet) are scattered more effectively than longer wavelengths (red and orange).
3. Why We See Blue:
- Since blue and violet light get scattered the most, it reaches our eyes from many directions in the sky.
- Our eyes are more sensitive to blue light than violet.
- The combination of these factors makes the sky appear blue.
Why Not Violet?
You might wonder why the sky isn't violet if it scatters the most. This is because:
Sunsets and Sunrises:
During sunrise and sunset, sunlight travels through more of the atmosphere. The longer path means that more blue light is scattered away, allowing longer wavelengths like red and orange to dominate, resulting in colorful sunrises and sunsets.
chronos@penguin:~$
Here's the same output again, but with Github fences added so as to render here as command line. But, unlike in my terminal, long lines are not folded here.
Is gemini-1.5-pro-latest significantly better on organizing and on analytical depth? The default in the previous post, above, as shown in the help output, is gemini-1.0-pro. I have been using Gemini for a few weeks. According to the benefits page shown to me at one.google.com, the Gemini version is gemini-1.5-pro.
gemini-1.5-pro-latest is my favorite so far! And it's free with eliben/gemini-cli and the Gemini API, at least for now, and at least from some countries.
I hope everyone gets the servers they want!
Compare Google Gemini 1.5 Pro And 1.5 Pro Latest Answers To Questions About
sed
SyntaxI enjoyed investing some time this afternoon trying Google AI Studio. Really nice! The AI Studio Quickstart describes Google AI Studio as "a browser-based IDE for prototyping with generative models. Google AI Studio lets you quickly try out models and experiment with different prompts. When you've built something you're happy with, you can export it to code in your preferred programming language and use the Gemini API with it."
If you want to compare the latest version of Gemini 1.5 Pro with the "regular" version, head over to Google AI Studio, select Gemini 1.5 Pro in the upper right hand corner under Model, and paste one of the questions below into the prompt box.
Isn't it cool that Google Gemini can do this?
Here is me trying Gemini's suggestions.
I hope everyone gets the servers they want!
https://x.com/GoogleCloudTech/status/1813589479644393932
Gemini and Gemma
( though some still prefer Emma)
blog | exploring visually |
I hope everyone gets the servers they want!
Multiline Prompts With eliben/gemini-cli ?
What happens if I want to use eliben/gemini-cli to send Google Gemini a multiline "prompt" or "chat" message -- for example a question about code together with the relevant multiline program code or code snippet?
eliben/gemini-cli has separate commands which include "prompt" for one-off, single prompts and "chat" for continuing chats. The basic "prompt" syntax is
gemini-cli prompt "text of prompt goes here" <--flags>
and the basic "chat" syntax is
gemini-cli chat <--flags>
.Also, at least for "prompt," eliben/gemini-cli syntax uses a dash "-" to represent standard input. As shown below, the dash and standard input seem to work for one-off initial, aggregated, multiline prompts.
However, the dash seems possibly ineffective to send a multiline initial prompt at the beginning of a hopefully continuing back and forth chat with Gemini. Moreover, I do not yet understand how to send a multiline prompt from within the continuing chat interface at a time subsequent to the initial prompt of the continuing chat.
sed
to reduce the multiline hello.c to a single line. Then I copied and pasted that single line into my Chromebook's hterm to send a single line prompt to Gemini and perhaps reduce the number of requests. However, Error 500, Internal Server Error, happened repeatedly.sed
. This time, it worked. Gemini answered, discussed the code, and a new ">" appeared so the chat probably could continue.I don't understand exactly what the 500 errors were. Even though the 500 error isn't supposed to be caised by my input, maybe it somehow was. And I don't understand why telling Gemini in advance that I was going to send code might be or whether it actually was helpful.
I see some unusual line breaks in Gemini's responses. What I posted here was copied and pasted directly from my Chromebook hterm interface. Maybe there is some issue between eliben/gemini-cli and my Chromebook's hterm? Maybe I should try a different terminal interface on my end?
Using eliben/gemini-cli, standard input seems to work fine in "prompt" mode. In "chat" mode, I also seem to be able to send Gemini multiline prompts by using
sed
to reduce the multiline prompts to a single line and then using copy and paste after telling Gemini what to expect.But, how can eliben/gemini-cli get a multiline, initial "chat" mode prompt or a multiline subsequent "chat" mode prompt to Gemini via some method which looks like traditional shell-fu: standard input plus a pipe, ":r" to read a file, "!" to escape temporarily to shell magic, or something else other than copy and paste? Thanks!
I hope everyone gets the servers they want!
https://github.com/karthink/gptel
Happy Monday morning !
blog | exploring visually |
Wow! I took a quick look and it looks great! Right in the spirit of emacs with everything included!
Every few years I do try emacs again. I wish I could enjoy the Ctrl-this, Ctrl-that sequences more. I guess I've never been a Ctrl freak.
:-)
Or a Meta freak.:-)
Recently I have been looking at a bit of Lisp stuff. It's so scary! But quite a few of the people involved with Lisp actually talk about having fun. Really!
:-?
I know that there are vi-like key bindings for emacs. I wonder if someone has written ed key bindings for emacs. That would be fun! I could use ed-ified emacs and feel right at home.
:-)
I bet somebody has done it!Happy Monday morning to you too!
I hope everyone gets the servers they want!
Greetings,
I thought you might like the post, the project certainly seems to be well thought out. I like that they offer How Tos for specific LLMs... PerplexityAi and groq for e.g. Many other (non OSS) projects seem to limit themselves to "here's how to configure openAI key".. almost an equivalent of "Here's how you install this software on Windows".
I recall watching these two videos on "How to use ed" a while back.. They were.... informative.
Links to Youtube videos below
and
And of course I had to ask Perplexity/ Sonar (they use llama at back end) the very question you posed..
here is the result..
Click to expand
(global-set-key (kbd "C-P") 'previous-line) (global-set-key (kbd "C-N") 'next-line) (global-set-key (kbd "C-A") 'beginning-of-line) (global-set-key (kbd "C-E") 'end-of-line) (global-set-key (kbd "C-D") 'delete-char) (global-set-key (kbd "C-K") 'kill-line) (global-set-key (kbd "C-C") 'save-buffer) In this example, the keybindings C-P, C-N, C-A, C-E, C-D, C-K, and C-C are mapped to the Emacs commands for moving to the previous line, next line, beginning of line, end of line, deleting a character, killing the rest of the line, and saving the buffer, respectively. You can add or modify these keybindings to match the ED editor's behavior as closely as you like. Keep in mind that this is just a basic example, and you may need to define additional keybindings or customize Emacs's behavior further to more closely emulate ED.blog | exploring visually |
I love Perplexity's example ed key bindings for emacs!
Thanks for posting!
I hope everyone gets the servers they want!
There is https://github.com/ryanprior/ed-mode
Super fantabulous! Thank you SO MUCH!
I hope everyone gets the servers they want!
I like to read About pages. So, when I look at projects on Github, as I did just now, thanks again to @cmeerw, besides sometimes looking at the code, I often look at the websites of the developers and read those sites' About pages.
This morning's About harvest was great! Starting from https://github.com/ryanprior/ed-mode, there are two developers, Ryan and Brian, so two developer websites with About pages.
Then I found Michael Rose's About page because of the link to the MadeMistakes Jekyll theme on Brian's About page.
Here's the summary for my notes:
https://github.com/ryanprior/ed-mode
https://www.ryanprior.com/ --> https://www.ryanprior.com/about/ -- > https://www.ryanprior.com/posts/
https://github.com/echosa --> https://echosa.net/about/
--> https://mademistakes.com/work/jekyll-themes/minimal-mistakes/ -- > https://mademistakes.com/about/
Here's an appreciative quote from Brian's About page:
I hope everyone gets the servers they want!