AI Search CLI Tool
A powerful CLI tool that combines AI capabilities with web search functionality using Groq and Tavily APIs.
Features
- 🤖 AI-powered responses using Groq's LLaMA model
- 🔍 Real-time web search integration with Tavily
- 💬 Interactive chat mode
- 📱 Instagram user search functionality
- 🎨 Beautiful CLI interface with colors and loading spinners
- ⚡ Fast and efficient API calls
Installation
Local Installation
git clone <repository-url>
cd ai-search-cli
npm install
echo "GROQ_API_KEY=your_groq_api_key_here" > .env
echo "TAVILY_API_KEY=your_tavily_api_key_here" >> .env
npm install -g .
Global Installation (if published to npm)
npm install -g ai-search-cli
Setup
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
Usage
Interactive Mode (Default)
ai-search
ai-search chat
Direct Search
ai-search search "What's the weather like today?"
ai-search search "Latest news about AI" --force
Instagram Search
ai-search instagram _mr.dhaval_io
ai-search instagram username
Commands
ai-search | Start interactive mode | ai-search |
ai-search chat | Start interactive chat | ai-search chat |
ai-search search <query> | Direct search | ai-search search "Python tutorials" |
ai-search search <query> --force | Force web search | ai-search search "News" --force |
ai-search instagram <username> | Search Instagram user | ai-search instagram elonmusk |
Interactive Mode Commands
In chat mode, you can:
- Ask any question
- Type
stop, bye, exit, or quit to end
- Press
Ctrl+C to exit
Examples
ai-search
ai-search search "Bitcoin price today"
ai-search search "Latest iPhone release" --force
ai-search instagram _mr.dhaval_io
ai-search chat
> What's the weather in Mumbai?
> Tell me about latest tech news
> Search for best restaurants in Delhi
> stop
Development
Project Structure
ai-search-cli/
├── index.js # Main CLI application
├── package.json # Dependencies and CLI configuration
├── .env # API keys (create this)
├── README.md # Documentation
└── .gitignore # Git ignore file
Publishing to npm
npm login
npm version patch
npm publish
- Test locally before publishing:
npm link
ai-search --help
Making it a Global CLI Tool
The key parts for CLI tool export:
- Shebang line in
index.js:
#!/usr/bin/env node
- Bin field in
package.json:
{
"bin": {
"ai-search": "./index.js"
}
}
chmod +x index.js
npm install -g .
API Keys Required
- Groq API: Free tier available, fast LLaMA inference
- Tavily API: Web search API, free tier available
Error Handling
- Network connectivity issues
- API rate limits
- Invalid API keys
- Empty search results
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
MIT License - see LICENSE file for details.
Support
If you encounter any issues:
- Check your API keys in
.env file
- Verify internet connectivity
- Check API rate limits
- Open an issue on GitHub