go-openai-cli

command module
v0.0.0-...-530f829 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 5 Imported by: 0

README

Go-OpenAI-CLI

Go-OpenAI-CLI is a command-line interface that provides access to OpenAI's GPT-3 language generation service. With this tool, users can send a prompt to the OpenAI API and receive a generated response, which can then be printed on the command-line or saved to a markdown file.

This project is useful for quickly generating text for various purposes such as creative writing, chatbots, virtual assistants, or content generation for websites.

Installation

To install and use the Go-OpenAI-CLI with golang :

go install github.com/MohammadBnei/go-openai-cli@latest

To install the compiled binaries, go to the the release page and select the exec matching your operating system.

Lastly, there is an unstable docker image. To run it, here is the code :

docker run -e OPENAI_KEY=<YOUR_OPENAI_KEY> -it mohammaddocker/go-openai-cli prompt

Usage

First, set up your OpenAI API key :

go-openai-cli config --OPENAI_KEY=<YOUR_API_KEY>

To send a prompt to OpenAI GPT, run:

go-openai-cli prompt

You will be prompted to enter your text. After submitting your prompt, OpenAI will process your input and generate a response.

Available command in prompt
q: quit
h: help
s: save the response to a file
f: add a file to the messages (won't send to openAi until you send a prompt)
c: clear message list

Configuration

To store your OpenAI API key and model, run the following command:

go-openai-cli config --OPENAI_KEY=<YOUR_API_KEY> --model=<MODEL>

To get a list of available models, run:

go-openai-cli config -l
Flags
  • --OPENAI_KEY: Your OpenAI API key.
  • --model: The default model to use.
  • -l, --list-model: List available models.
  • --config: The config file location.

The configuration file is located in $HOME/.go-openai-cli.yaml.

Contributing

To contribute to this project, fork the repository, make your changes, and submit a pull request. Please also ensure that your code adheres to the accepted Go style guide.

License

This project is licensed under the MIT License.

Documentation

Overview

Copyright © 2023 Mohammad-Amine BANAEI mohammadamine.banaei@pm.me

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL