prompt-tester-cli
v1.2.0
Published
A CLI tool to test AI prompts locally with mock responses or live API calls to speed up development, reduce API costs, and prototype AI interactions quickly.
Readme
Prompt Tester CLI
A lightweight CLI tool to test AI prompts locally with mock responses or live API calls, saving API costs during development.
Installation
npm install -g prompt-tester-cliUsage
Initialize a mock file
Create a mocks.json file to store mock prompt-response pairs:
prompt-tester-cli initThis creates an empty mocks.json file in your current directory.
Test a prompt with a mock response
Test a prompt using a mock response from mocks.json:
prompt-tester-cli test --prompt "What is the capital of France?" --mock mocks.jsonIf the prompt exists in the mock file, it returns the stored response. If not, it adds the prompt with a placeholder response.
Test a prompt with a live API
Test a prompt using a live AI API (requires an OpenAI API key):
export OPENAI_API_KEY=your-openai-api-key
prompt-tester-cli test --prompt "What is the capital of France?" --liveSet OPENAI_API_KEY in your environment for live testing.
Mock File Format
The mocks.json file should follow this format:
[
{
"prompt": "Your prompt here",
"response": "Mock response here"
}
]Prerequisites
- Node.js >= 16
- For live testing, an OpenAI API key.
Development
- Clone the repo:
git clone https://github.com/rijonshahariar/Prompt-Tester-CLI.git cd prompt-tester-cli - Install dependencies:
npm install - Build the project:
npm run build - Run locally:
npm start -- test --prompt "Test prompt" --mock mocks.json
License
MIT
