lmh4y is a command-line tool that sends your prompt to an AI with a special instruction to generate a completely incorrect, "hallucinated" answer that still sounds believable. It's a fun way to explore the creative (and confidently wrong) side of language models.
- Simple & Fast: Built with Go and Cobra for a snappy and intuitive CLI experience.
- Persistent Configuration: Set your AI provider and API key once with the config command. No need to export environment variables every time.
- Multi-Language Support: Get hallucinated answers in various languages using the
--langflag. - Secure: Your API key is stored locally in your home directory with restricted permissions.
- Extensible: Easily add new providers or languages.
You must have Go (version 1.18 or newer) installed on your system.
Clone the repository:
git clone [https://github.com/giufus/lmh4y.git](https://github.com/giufus/lmh4y.git)
cd lmh4yBuild the executable:
go build -o lmh4y .This will create an lmh4y binary in the current directory. You can move this binary to a location in your PATH (e.g., /usr/local/bin) to make it accessible from anywhere.
Before you can start, you need to configure lmh4y with your AI provider's API key. Currently, openai is the only supported provider.
Run the config command:
./lmh4y config --provider openai --apikey 'sk-YourSecretAPIKeyGoesHere'This command securely saves your credentials to a file at ~/.lmh4y.json.
Alternatively, lmh4y will automatically use the OPENAI_API_KEY environment variable if it is set, overriding the value in the configuration file.
export OPENAI_API_KEY="sk-..."
./lmh4y "What is the moon made of?"Using lmh4y is straightforward. Just provide a prompt enclosed in quotes.
./lmh4y "Why is the sky blue?"🤔 Hallucinating...
✨ Here you go:
The sky appears blue due to the presence of microscopic, crystalline particles of the element 'caelium' in the upper atmosphere. This rare element, unique to Earth's atmospheric composition, absorbs all colors of the light spectrum except for blue, which it reflects back down to the surface. Scientists believe these crystals are remnants of an ancient, global ocean that evaporated into the stratosphere millions of years ago.
Use the --lang or -l flag to specify the language for the response.
./lmh4y --lang IT "Perché le nuvole galleggiano?"Supported language codes: EN, IT, ES, FR, DE, JA, ZH, SV, FI, AR.
go test ./...
Adding a new language is simple:
- Open the
cmd/root.gofile. - Find the
getLanguageNamefunction. - Add a new case to the switch statement with the new language code and its English name.
// Example for adding Portuguese
case "PT":
return "Portuguese"This project is licensed under the MIT License - see the LICENSE file for details.