Inspiration

Our team was inspired to create a shell assistant after struggling with complex terminal commands and searching for solutions online. We wanted to create a more intuitive experience that would allow anyone, regardless of their technical expertise, to interface with their terminal without an immense knowledge of bash tools. A few GitHub repositories use Large Language Models (LLMs) such as GPT-3 for generating bash commands, but these tools are extremely limited in what they can help the user with.

We wanted to build a terminal assistant who could learn facts and details about the user's workflow and environment and use these facts to generate code snippets for extremely vague commands such as "activate my research conda environment, and run my most recent set of experiments" or "download a Wikipedia article about my favorite animal into my school directory."

What it does

Our shell tool, called LangShell, is a GPT-3 based assistant. Much like other LLM-based terminal assistants, it's cracked at generating bash scripts. Unlike other assistants, though, LangShell has a memory. You can tell LangShell facts about yourself, and you will never forget them (unless you want it to). Are you working on a new project directory? Tell LangShell about it so that you can mention your project while using LangShell (e.g., "navigate to my research directory and run main.py", "take all the .mp4 files from my project directory"). A new person named John joined your software development team. Tell LangShell about this person's UNI, linux_id, etc. so you can quickly ask LangShell to execute commands such as "give John access to my project directory." LangShell will always understand what you're talking about ;)

How we built it

We built LangShell using Python, the OpenAI GPT-3 API, and the Huggingface MiniLM-L6-v sentence similarity API. It is based on a fork of Shell GPT, and we plan to release it as a Pull request on the original repo.

Challenges we ran into

One of the biggest challenges LangShell faced was GPT-3's context length limitations. The naive implementation of LangShell took all of LangShell's "memorized facts" and tried to fit them in a GPT-3 prompt so that GPT-3 could come up with answers based on these facts. If one were to use LangShell over an extended period, these memories would quickly fill up GPT-3's prompt length. We needed an efficient, flexible, and accurate way to retrieve parts of LangShell's memory. This is when we had an idea – we could use small language models to compute the similarity of a user's query with all the facts in LangShell's memory, choose the set facts with the highest similarity, and then make a query to our large language model GPT-3 using this small subset. We found that this was far more accurate and flexible than heuristic methods while being significantly faster and cheaper than using a large language model to filter.

Accomplishments that we're proud of

We're also proud of the level of accuracy and relevance in the generated code snippets and explanations, which we believe will be very helpful to users. We can't wait to do a PR on the ShellGPT repo (although we doubt they'll accept it as we've added so many features that our repo is over twice the size of the original repo).

Built With

Share this project:

Updates