oai is a command line tool that uses OpenAI's language model to provide a documentation-like experience to users. With oai, users can get answers to their questions and receive step-by-step guidance to complete tasks.
New in 0.7.0, run LLM locally on your computer, by using Ollama. Ollama install: https://github.com/ollama/ollama/blob/main/README.md Ollama will pull the requested LLM, like llama3:8b.
Get API Key from OpenAI
- Get your OpenAI API Key:
- Go to OpenAI's website (https://openai.com/api/login)
- Sign up or log in to your account
- Go to the API Key section (https://platform.openai.com/account/api-keys)
- Create a new secret key
- Copy the API key
- When running oai the first time, you will be prompted for your key
( Anyone who might be able to help me get this set up with a snap or flatpack? I've been working on trying to set up these workflows )
- Clone repository `git clone https://github.com/draupner1/oai.git'
- Change directory
cd oai
- Install dependencies
pip install -r requirements.txt
- Run
python oai
and enter OpenAI key as prompted to complete setup - Prompt with
python oai
orpython oai "how do I..."
- Optional: Install link in PATH, or in ~/.local/bin/
Python Requirements
- Python 3
- OpenAI API Key
- Rich library (install via
pip install rich
)
To use oai, simply run the script and provide a prompt that describes the task you want to complete or the question you want to ask.
For example:
python oai.py "How to install and run a web server on Ubuntu?"
If you have added the script to your path, you can run it from anywhere:
oai "How to install and run a web server on Ubuntu?"
To use Ollama as local LLM provider, Add in a in your oai command. Ex: oai oll "Tell me a joke"
Ollama integration only supports prompt:answer format today. See oai -h for details.
On new installs after Nov6-23 we get the new python lib v 1.2.4
This breaks some calls and response types.
OAI v.0.6.2 is adapted to the new lib!
Also, providing new shortcuts for -s size when generating Images. Use '1:1', '16:9', '9:16' as shorthand for '1024x1024' and...
Also-2, when generating images, printing the returned eventually altered prompt.
Available from v.0.6.0 As the API provides, creation -c is DALL-E3, Variants and Edit are DALL-E2.
-c, --create Create a new Image, DALL-E3 -w, --variant Create a variant of an Image-file. Provide "<image.png>", DALL-E2 -e, --edit Edit part of an Image-file. Provide "<image.png>,<mask.png>, Prompt-string",DALL-E2 -d DEFAULT, --default DEFAULT How many Images to create. 1-10, default=2 -s SIZE, --size SIZE Image size. default=1024x1024
Will respond with clickable link (that expires) to be opened in Browser.
Available from v.0.5.0
You can now define your own Functions. (See OpenAI-chatAPI for details)
Implement them in a Class file, and drop it in the functions directory where OAI is installed.
Your functions/FuncTemplate.txt, is a class template to get you started.
- If you wish, you can override automated settings by use of .env file
- You can set the OpenAI model to use by setting the
OPENAI_MODEL
environment variable in your .env file. - You can disable the notice that is displayed at the end of the response by setting the
OPENAI_DISABLE_NOTICE
environment variable in your .env file.
If you'd like to contribute to oai, feel free to create a pull request or open an issue. All contributions are welcome!