term-helper
is a CLI application built using Cobra in Go that helps users write terminal commands. It utilizes the Groq API to assist with Linux terminal commands by interpreting user prompts.
- Provides assistance in writing Linux terminal commands based on user input.
- Interacts with the Groq API using a pre-trained language model (
llama3-8b-8192
). - Allows users to input prompts as flags or arguments.
- Provides a detailed response from the API, including tokens and message content.
To use this CLI, you'll need:
- Go (1.19 or later) installed on your system.
- A valid API key from Groq. Set the environment variable
GROQ_API_KEY
to authenticate API requests.
-
Clone the repository:
git clone https://github.com/basola21/term-helper.git cd term-helper
-
Build the project:
go build -o term-helper
-
Export your Groq API key:
export GROQ_API_KEY=your_api_key_here
-
Run the command-line tool:
./term-helper --prompt "Show me how to list all files"
You can run term-helper
in two ways:
Run the application by providing a prompt as an argument:
./term-helper "How do I list all files in a directory?"
You can also pass the prompt using a flag:
./term-helper --prompt "How do I change file permissions in Linux?"
-p
,--prompt
: Provide a prompt to query the Groq API.
./term-helper --prompt "How do I create a new directory in Linux?"
The application will return the response from the Groq API, including information about the message and tokens:
Response from Groq:
ID: 12345
Model: llama3-8b-8192
Message: Use the command `mkdir` followed by the directory name.
Make sure to set your Groq API key in the environment:
export GROQ_API_KEY=your_api_key_here
This is necessary for the application to authenticate with the Groq API.
- If no prompt is provided, the application will prompt you to input one.
- If the API key is not set, an error message will ask you to set the
GROQ_API_KEY
environment variable. - All HTTP errors or issues with the API response will be printed to the console.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to open issues or submit pull requests to improve this project. Contributions are welcome!
Enjoy using term-helper
to get quick assistance with Linux terminal commands!