This is an on-going development of an upgraded version of the original Shell GPT. The main purpose is to support task automation on your own device. In addition to executing basic shell commands as Shell GPT already supports, with GPT-SHell, you can directly load the content of text files from your device and process them with ChatGPT.
>>> DO: load the file "/Users/timowang/Developer/gpt-sh/main.py"
/Users/timowang/Developer/gpt-sh/main.py loaded.
>>> DO: show vars
FILE_CONTENT_VAR_1 = import argparse
import json
import os
import readl...
>>> THINK: Explain in 100 words what the following code does. FILE_CONTENT_VAR_1
This code defines a Python program that allows users to interact with OpenAI's GPT models in a command-line interface. The program reads history files and environment variables from the user's system, and provides functionality for saving and retrieving command history. Users can input various commands to interact with the GPT models, such as generating text responses, executing shell commands, and handling custom think actions. The program uses the Typer library to write responses to the command line and provides functionality for animating text output. Additionally, the program can handle scripts to run in GPT and passes command line arguments to the script. The program terminates when the user inputs the "exit" command.
SGPT2-DEMO.mov
gpt-sh-demo.mov
pip install gpt-sh
When you first uses gpt-sh
, you will be prompt to enter your OpenAI API key.
You can also set the following variable in ~/.config/shell_gpt/.sgptrc
.
OPENAI_API_KEY=[YourAPIKey]
shell_gpt
First type in the terminal gpt-sh
. This will start up the prompt.
Unlike the original Shell GPT, GPT-SHell functions like an actual shell, where you enter a command and then get a response.
There are four types of commands: DO
, and THINK
, SHELL
, CODE
.
This is a NEW command of GPT-SHell. This is used to interact with GPT-SHell itself. You can use DO command to read or write files from your device, access environment variables, etc.
There are two DO commands implemented: SHOW_ENV_VARS
, LOAD_FILE
.
More will be implemented in the near future.
You do not need to know the exact name of these commands. Based on your input, GPT-SHell will automatically detect the action you want to take. If it cannot determine the action, it will show you a list of all actions.
This action let you check all the environment variables of GPT-SHell. This is NOT for checking the environment variables of your OS.
When there is no environment variable, the following is shown.
>>> DO: Show me all the env vars
No environment variables loaded.
When there are environment variables, the following is shown.
>>> DO: Show all env vars
FILE_CONTENT_VAR_1 = Created a dynamic, customizable dashboard supporti...
FILE_CONTENT_VAR_2 = JavaScript,TypeScript,HTML5,CSS3,Python, ReactJS, ...
>>> DO: Show var: FILE_CONTENT_VAR_1
FILE_CONTENT_VAR_1 = Created a dynamic, customizable dashboard supporti...
Currently, the first 50 characters of each value is printed. In the future, a feature that let user to specify the print length will be implemented.
This action let you save values to a variable. The value can be a raw value, such as a number or a string. The value can be the one stored in another variable. The value can be the latest response from CODE or THINK commands.
>>> DO: Set the value of KEYS_CONTENT to FILE_CONTENT_VAR_2 SET_ENV_VAR
Setting the variable with name KEYS_CONTENT
>>> DO: Set the value of DESC_CONTENT to FILE_CONTENT_VAR_1 SET_ENV_VAR
Setting the variable with name DESC_CONTENT
>>> DO: Show all env vars
DESC_CONTENT = Created a dynamic, customizable dashboard supporti...
KEYS_CONTENT = JavaScript, TypeScript, HTML5, CSS3, Python, React...
>>> DO: Set the value of LETTERS to be "ABC"
Setting the variable with name LETTERS
>>> DO: show var: LETTERS
LETTERS = ABC
This action let you delete a variable that is no longer needed.
>>> DO: delete the vars: FILE_CONTENT_VAR_1, FILE_CONTENT_VAR_2
Variable FILE_CONTENT_VAR_1 deleted.
Variable FILE_CONTENT_VAR_2 deleted.
>>> DO: show vars
DESC_CONTENT = Created a dynamic, customizable dashboard supporti...
KEYS_CONTENT = JavaScript, TypeScript, HTML5, CSS3, Python, React...
ANALYSIS = SENT: Created a dynamic, customizable dashboard su...
LETTERS = ABC
This action let you load the content of a file into GPT-SHell. This is one major difference or upgrade from the original Shell GPT. You can specify the paths of the files you want to load.
>>> DO: Load the following files. "/Users/timowang/Documents/test-sgpt/desc.txt" and "/Users/timowang/Documents/test-sgpt/keys.txt"
>>> DO: Show all env vars
FILE_CONTENT_VAR_1 = Created a dynamic, customizable dashboard supporti...
FILE_CONTENT_VAR_2 = JavaScript,TypeScript,HTML5,CSS3,Python, ReactJS, ...
This action let you save the value of a variable to your local file system.
>>> DO: save the value of ANALYSIS to /tmp/analysis.txt
Saving ANALYSIS to /tmp/analysis.txt.
>>> SHELL: show the content of /tmp/analysis.txt and only show the first 5 lines
COMMAND: head -n 5 /tmp/analysis.txt
Run this command? [y/N]: y
SENT: Created a dynamic, customizable dashboard supporting various widgets to display the issue count for each template, the trend of issue count throughout a certain number of days, etc. using Material-UI components for React.
KEYS: ReactJS, Material-UI
SENT: Refactored common properties of widgets such as widget titles, subtitles, and configuration menu wrapper to a shared component, enabling cleaner implementation and easier creation of new widgets.
KEYS:
This command is for you to build ChatGPT prompt using the content of the files you loaded and stored in the environment variables.
For example, in the above snippet, we loaded the description of a front-end project as well as keywords related to front-end job skills into two variables: FILE_CONTENT_VAR_1
and FILE_CONTENT_VAR_2
. We can now use them to build a new prompt to get sentences from the description that contain certain keywords.
>>> THINK: Given the following keywords: FILE_CONTENT_VAR_2.\n Given the following text: FILE_CONTENT_VAR_1. Identify all sentences that contain the keywords. Print with the following format: SENT: [A sentence with keywords]\nKEYS: [All keywords that occur in the sentence].
Your THINK prompt is: Given the following keywords: JavaScript,TypeScript,HTML5,CSS3,Python, ReactJS, jQuery, Bootstrap, Material-UI, RESTful API, ExpressJS, NodeJS, Microservices, Figma, Docker, Git, MongoDB, PostgreSQL, MySQL, Amazon Web Service(AWS), Google Cloud Platform(GCP), Vercel.\n Given the following text: Created a dynamic, customizable dashboard supporting various widgets to display the issue count for each template, the trend of issue count throughout a certain number of days, etc. using Material-UI components for React. Refactored common properties of widgets such as widget titles, subtitles, and configuration menu wrapper to a shared component, enabling cleaner implementation and easier creation of new widgets.
Built an interface allowing admin users to configure issue templates with customizable input options such as name, type and more. Implemented dynamically rendered issue submission forms based on the conditional rendering of different input options into MUI input components by specified input options.
Created an interface for issue owners of a particular category of issues to view the details of an issue, respond to the issue, and mark keywords that serve as evidence for particular attributes of the issue, enabling future training of machine learning models for automatic attribute classification.
Implemented ExpressJS backend endpoints for retrieving template data and issue-related statistics such as issue counts and attributes. Connected the backend to MongoDB Atlas via Mongoose for better scalability and data management. Leveraged Faker.js to generate mock data for testing the implementation of the application, ensuring robustness and reliability. Containrized the backend with Docker and deployed to Google Cloud Platform.
Developed a basic authentication mechanism, storing user info in localStorage upon successful login and clears it upon logout. Implemented the frontend routing using React Router and ensured unauthorized users are redirected to an error page. . Identify all sentences that contain the keywords. Print with the following format: SENT: [A sentence with keywords]\nKEYS: [All keywords that occur in the sentence].
SENT: Created a dynamic, customizable dashboard supporting various widgets to display the issue count for each template, the trend of issue count throughout a certain number of days, etc. using Material-UI components for React.
KEYS: ReactJS, Material-UI
SENT: Refactored common properties of widgets such as widget titles, subtitles, and configuration menu wrapper to a shared component, enabling cleaner implementation and easier creation of new widgets.
KEYS: JavaScript
SENT: Built an interface allowing admin users to configure issue templates with customizable input options such as name, type and more.
KEYS: None
SENT: Implemented dynamically rendered issue submission forms based on the conditional rendering of different input options into MUI input components by specified input options.
KEYS: Material-UI
SENT: Created an interface for issue owners of a particular category of issues to view the details of an issue, respond to the issue, and mark keywords that serve as evidence for particular attributes of the issue, enabling future training of machine learning models for automatic attribute classification.
KEYS: None
SENT: Implemented ExpressJS backend endpoints for retrieving template data and issue-related statistics such as issue counts and attributes.
KEYS: ExpressJS
SENT: Connected the backend to MongoDB Atlas via Mongoose for better scalability and data management.
KEYS: MongoDB
SENT: Leveraged Faker.js to generate mock data for testing the implementation of the application, ensuring robustness and reliability.
KEYS: None
SENT: Containrized the backend with Docker and deployed to Google Cloud Platform.
KEYS: Docker, Google Cloud Platform
SENT: Developed a basic authentication mechanism, storing user info in localStorage upon successful login and clears it upon logout.
KEYS: JavaScript
SENT: Implemented the frontend routing using React Router and ensured unauthorized users are redirected to an error page.
KEYS: ReactJS
This is the same as the shell command supported by Shell GPT. You can describe some action you want to perform with the shell, GPT-SHell will translate your command into a shell script and then execute your command.
>>> SHELL: Create five files with names from one to five and type of txt in /tmp
COMMAND: touch /tmp/{1..5}.txt
Run this command? [y/N]: y
This is the same as the code command supported by Shell GPT. You can describe the functionality of some code and have GPT write it for you.
>>> CODE: Write a c function for summing up an array.
int sumArray(int arr[], int len) {
int sum = 0;
for (int i = 0; i < len; i++) {
sum += arr[i];
}
return sum;
}
In the example
directory, you can find three .txt
files.
The file desc.txt
contains the description of a frontend project and
keys.txt
contains skill keywords related to frontend job market.
We want to identify sentences in desc.txt
with keywords that are listed in keys.txt
.
Following the commands in example_inputs.txt
, shown below as well, we can first load the files,
build a prompt with the content of the files, get analysis report, and save the report to a local file.
DO: Load the following files. "/Users/timowang/Developer/shell_gpt2/example/desc.txt" and "/Users/timowang/Developer/shell_gpt2/example/keys.txt"
DO: Show all env vars
DO: Set the value of DESC_CONTENT to FILE_CONTENT_VAR_1
DO: Set the value of KEYS_CONTENT to FILE_CONTENT_VAR_2
DO: delete the following variables: FILE_CONTENT_VAR_1, FILE_CONTENT_VAR_2
THINK: Given the following keywords: KEYS_CONTENT.\n Given the following text: DESC_CONTENT. Identify all sentences that contain the keywords. Print with the following format: SENT: [A sentence with keywords]\nKEYS: [All keywords that occur in the sentence].
DO: Save the LAST_RESPONSE to a variable called "ANALYSIS"
DO: Show all env vars
DO: Save the value of ANALYSIS to the file /tmp/analysis.txt
SHELL: Print out the first 3 lines of the content of /tmp/analysis.txt
You can also execute pre-defined scripts line by line automatically as follows.
gpt-sh --script_path example/example_inputs.txt
Currently GPT-SHell is still under active development. Unlike Shell GPT, which focuses on serving as a command-line interface for accessing GPT functionalities, such as a chat, GPT-SHell focuses on helping you processing files on your own device. No matter the task is summarizing the content of a long report, or creating new content and then saving it on your device for you directly, GPT-SHell (at least the future version) will be your best helper!
These are the features being developed right now. You can also suggest features in the Discussion/Issues section.
- Support basic shell commands without making requests to OpenAI apis such as ls, cd, etc.
This project is an extended version based on shell_gpt by TheR1D.