Skip to content

crypto-artisan/react-flask-chatgpt-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT Term


Bring OpenAIs GPT assistants to your terminal.

Requirements:


  1. You'll need an OpenAI API key Website
  2. Brave Search API key Website. They provide a free tier that gives 2000 requests a month.
  3. An initial assistants ID. You can create an assistant from the OpenAI website. You'll find the ID in the assistant creation section.
  4. 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"]
    }
}

.env

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
assistant_id=your_assistant_id

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")
assistant_id = os.getenv("assistant_id")

Dependencies:

  • rich
  • requests
  • BeautifulSoup4
  • python-dotenv

If you have these installed through your systems package manager you can skip the virutal env.

Setting up Virtualenv:


Inside the the folder where main.py is create a virtual environment

virtualenv env
source env/bin/activate

Next use pip install to install the requirements.

pip install -r requirements.txt

To run:

python main.py

I actually setup an alias in my .zshrc file called gpt that runs python /path/to/main.py so I can use it anywhere

How to use:


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.

About

react-flask-chatgpt-backend

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages