A command-line tool that translates natural language instructions into safe shell commands using advanced NLP. This project integrates with the Google Gemini API to process natural language input, then validates and executes (or simulates) the resulting shell commands.
-
Natural Language Processing:
Converts user instructions into shell commands using a generative AI API. -
Command Validation:
Validates generated commands against a whitelist to ensure safe execution. -
CLI-Centric Interface:
Fully command-line based, with interactive prompts and command-line flags. -
Configurable Storage & Environment:
Uses environment variables (loaded from a.envfile) to store API keys and project settings. -
Modular Design:
Organized into modules for configuration, NLP processing, command translation, validation, and command execution.
- Go: Version 1.20 or later
- Docker (optional): For containerized deployment
- Environment: Linux (or any system that supports Go)
-
Clone the Repository:
git clone https://github.com/YashSaini99/NLP_CLI.git cd NLP_CLI -
Set Up Environment Variables:
Create a
.envfile in the project root with the following content (replace the placeholder values):GOOGLE_GEMINI_API_KEY=your_google_gemini_api_key_here GOOGLE_GEMINI_MODEL=gemini-model-default
-
Download Dependencies:
go mod download
-
Build the Project:
go build -o nlp-task-runner
Run the application using one of the following methods:
Simply run the binary without any flags:
./nlp-task-runnerYou will be prompted to enter a natural language instruction. For example:
Enter your instruction: archive all logs modified yesterday and compress them
You can also pass the instruction directly as a flag and enable verbose output:
./nlp-task-runner -instruction="archive all logs modified yesterday and compress them" -verboseTo simulate the command execution without making any system changes, you can use the -dry-run flag:
./nlp-task-runner -instruction="archive all logs modified yesterday and compress them" -dry-run-
Configuration Issues:
Ensure your.envfile is in the project root and contains valid values. -
API Errors:
If you encounter API errors, verify your API key and model configuration. Refer to the official documentation. -
Command Validation:
The generated shell command is validated against a whitelist invalidator/validator.go. If a valid command is being rejected, adjust the whitelist regex patterns accordingly.