Bring OpenAIs GPT assistants to your terminal.
- You'll need an OpenAI API key Website
- Brave Search API key Website. They provide a free tier that gives 2000 requests a month.
- In order to use the web search function, you'll need to enable function calling on your assistant by clicking add function and copy/paste the following into the function box on the website.
{
"name": "web_search",
"description": "Search the web for answers.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Your search query"
}
},
"required": ["query"]
}
}Create a .env with the following inside of it. The .env will need to be in the same folder as main.py
brave_api=your_brave_api_key
open_ai_key=your_open_ai_key
Variables must match, or rename in the main.py file to match your .env
# Main.py
api_key = os.getenv("open_ai_key")
brave_api = os.getenv("brave_api")- rich
- requests
- BeautifulSoup4
- python-dotenv
If you have these installed through your systems package manager you can skip the virutal env.
Inside the the folder where main.py is create a virtual environment
virtualenv envsource env/bin/activateNext use pip install to install the requirements.
pip install -r requirements.txtTo run:
python main.pyI actually setup an alias in my .zshrc file called gpt that runs python /path/to/main.py so I can use it anywhere
To see a list of commands in the program type any of the following: ?, help, show options, options
| Command | Description |
|---|---|
| clear | Clears the screen. |
| change assistant (ca) | Change the assistant. |
| send code (sc) | Inject a file into the conversation. |
| debug | Enables debug mode |
| save | Saves the conversation to a file. Saving as a .md works well. |
| new thread (nt) | Creates a new thread. So basically a new conversation. |
| save thread (st) | Saves current thread to threads.json, allows reloading previous threads. |
| load threads (lt) | Load a previous thread |
| quit (q) | Quits the program. |
