Sage is an AI copilot designed to enhance developer productivity and streamline onboarding processes. By suggesting and autocompleting terminal commands, it significantly reduces the time developers spend on routine tasks.
Many companies have specific commands for their teams and projects. With Sage, developers no longer need to waste time searching through documentation or asking colleagues for help with these commands.
Sage stores historical commands used by team members, allowing it to provide relevant suggestions based on context. It features an extension that records successfully executed commands in real-time, with built-in data redaction through Hugging Face for privacy protection. These commands are stored in a vector database, enabling hybrid search and reranking retrieval. Additionally, Sage offers RAG-based code completion for command-line suggestions, further enhancing its usability.
sage.demo.mov
![Screenshot 2024-04-07 at 2 24 02 PM](https://private-user-images.githubusercontent.com/5252587/320302852-744cf49a-d598-49ec-a7bb-05a46b224ef3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4ODI0OTIsIm5iZiI6MTcyNDg4MjE5MiwicGF0aCI6Ii81MjUyNTg3LzMyMDMwMjg1Mi03NDRjZjQ5YS1kNTk4LTQ5ZWMtYTdiYi0wNWE0NmIyMjRlZjMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjhUMjE1NjMyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzBmMGI1YThiOGYwY2U2YjM5MWQzZmY4OTRkNDI2MjljNTkyYjc0OGEwYmMwM2YyYzgwOTk0YWEzMDAzNTUyNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.NbRmF7xsJ3gUBbPf0ds3NNTPG0b7AsjoIizhet2ptPk)
Note, this was a 10-hour hackathon project and we didn't invest time into building a great developer experience, so try this at your own risk. This is also not currently deployed, so local dev is the easiest way to test it for yourself. There are 3 components:
oh-my-zsh plugin
This plugin captures commands as you run them. It's located in shell/
. To install this, from the root of the repo:
- Run the
shell/install.sh
script. This creates a copy of your~/.zshrc
config intoshell/zsh-with-plugin.zshrc
. - Update the
shell/zsh-with-plugin.zshrc
and extend yourplugins
to includetbd
. We made this first, before we decided on a name 🙂. Your plugins should then look something like this:plugins=(git z zsh-syntax-highlighting zsh-autosuggestions tbd)
. - Use the
shell/zsh-with-plugin.zshrc
as your new shell by runningsource shell/zsh-with-plugin.zshrc
.
This should update your shell to include the plugin. Now, whenever you run commands, they'll be sent to the local server.
There's a Python FastAPI server that powers ingestion and retrieval. It authenticates to a few different services from a .env
file. Create the .env
at server/.env
and populate the following:
MONGO_URL=
HF_INFERENCE_URL=
HF_TOKEN=
OPENAI_API_KEY=
NOMIC_API_KEY=
COHERE_API_KEY=
Then, install the requirements from the requirements.txt
file. You can run the server with python main.py
.
We use StarPII from Hugging Face to flag PII, and Hugging Face inference to host the model. You need to deploy this model, as-is, to an Inference Endpoint on HF.
The MongoDB setup should be fairly straightforward. You need to create a deployment (we called our database command
and our collection recorded_commands
) and add two indices in Atlas Search:
- A vector search index with the following config:
{
"fields": [
{
"numDimensions": 512,
"path": "summary_embeddings",
"similarity": "cosine",
"type": "vector"
}
]
}
- A search index with the following config:
{
"mappings": {
"dynamic": false,
"fields": {
"command_summary": [
{
"type": "string"
}
]
}
}
}
You can then bulk ingest some sample data with mongo_bulk_ingest.py
.
The CLI lives in the cli/
directory and is packaged with Poetry. You can run poetry install
in the directory, which should drop you into a shell where you have access to the sage
CLI.
You can then ask the CLI questions with sage ask "list files"
.