A command-line tool which integrates with terminal/shell and interprets natural language commands and executes them as system operations using a Local Language Model (LLM). This tool can also search the internet, fetch information from webpages, and analyze web content.
- Natural language processing of system commands
- Internet search capabilities
- Web content analysis and extraction
- Browser-based rendering for JavaScript-heavy websites
- Interactive shell mode and command-line mode
- Context-aware command history
- Secure operation handling with user confirmations
- Local LLM integration
- Persistent context management
- Notification system
- RAG (Retrieval Augmented Generation) support for enhanced contextual responses
- Create and manage document collections
- Semantic search across indexed documents
- Context-aware responses using local knowledge base
- Python 3.7+
- Local LLM server running on http://localhost:1234/v1 (tested with LM Studio)
- An LLM model which supports tool usage (Recommended Model: Qwen2.5-14B-Instruct)
- An embedding model (Recommended: text-embedding-nomic-embed-text-v1.5-embedding)
- Required Python packages:
- docker
- setuptools
- twine
- pytest
- aiohttp
- psutil
- beautifulsoup4
- duckduckgo-search
- nltk
- playwright (for browser-based web page rendering)
- chromadb
- langchain
- langchain_core
- langchain_community
- sentence_transformers
- pypdf
- jq
- unstructured
- pdfminer.six
- pi_heif
- unstructured_pytesseract
- pdf2image
- pytesseract
- opencv-python
- tesserocr
- unstructured-inference (Has some issues on Ubuntu ARM 64)
- Includes
ai_code_sandboxas a submodule to execute python code in a sandbox.
- Clone the repository
- Create a soft link for ai_code_sandbox:
cd bashai
git submodule update --init
ln -s ai-code-sandbox/ai_code_sandbox- Install dependencies:
pip install -r requirements.txtNote: If you have an "externally-managed-environment" you might need to create a virtual environment for python, for your pip to work.
python3 -m venv .
source bin/activate- Install playwright browser depending on your platform and preference.
python3 -m playwright install chromium
python3 -m playwright install firefox
python3 -m playwright install webkit- Install Tesseract.
Linux:
sudo apt install tesseractMacOS:
brew install tesseract- Contexts and security configuration are maintained in
~/.bashaifolder - Configs can be overridden by creating a
config.jsonfile under the~/.bashaidirectory. Sample configs:
{
"llm": {
"api_url": "http://localhost:1234/v1",
"model": "local-model",
"temperature": 0.7,
"max_tokens": 4096
},
"context": {
"max_length": 4000,
"max_age_hours": 24
},
"logger": {
"level": 10
},
"browser": "webkit",
"rag": {
"provider": "huggingface",
"model": "all-MiniLM-L6-v2",
"data_directory": "~/.bashai/embeddings",
"chunk_size": 500,
"chunk_overlap": 50,
"distance_threshold": 0.7
}
}- Logs are generated in
/tmp - Contexts are maintained per
shelland are auto cleaned up if the shell is unused for a prolonged period of time. Context can also be manually cleared. See the "Clean Context" section below.
- Make sure LM Studio is running and the LLM and embedding model is loaded.
python agentpython agent <your prompt>OR
agent <your prompt>if you add agent to the PATH and chmod +x it (recommended).
Create a new collection from documents:
agent "create a RAG collection called 'docs' from the ./documentation folder"Query using RAG context:
agent "using the 'docs' collection, explain how to configure the logging system"List available collections:
agent "list all RAG collections"Delete a collection:
agent "delete the RAG collection named 'docs'"Clears the context associated with the current shell.
agent -- --clean# As a shell
$ python agent
agent> create a new file called test.txt
agent> show me the last 5 lines of /var/log/syslog
agent> search the web for latest Linux kernel features
agent> analyze the content from https://example.com/article
agent> fetch content from spa-webapp.com using browser rendering
agent> create a RAG collection called 'python-docs' from ./python/docs
agent> using python-docs collection, explain the asyncio module
# As a command
$ agent "create a backup of my-file.txt"
$ agent "what is the current weather in San Francisco"
$ agent "summarize the main points from https://example.com/blog-post"
$ tail -100 /var/log/syslog | agent analyze the logs
$ agent "index my-project-docs/ as a RAG collection called 'project'"The tool can be configured via ~/.bashai/config.json. Here are the available options:
{
"llm": {
"api_url": "http://localhost:1234/v1",
"model": "local-model",
"temperature": 0.7,
"max_tokens": 4096
},
"context": {
"max_length": 4000,
"max_age_hours": 24
},
"logger": {
"level": 10
},
"browser": "webkit",
"rag": {
"provider": "huggingface",
"model": "all-MiniLM-L6-v2",
"data_directory": "~/.bashai/embeddings",
"chunk_size": 500,
"chunk_overlap": 50
}
}provider: Embedding model provider (currently supports 'huggingface')model: The embedding model to use for document indexingdata_directory: Where to store the embeddings and collectionschunk_size: Size of text chunks for document splittingchunk_overlap: Overlap between consecutive chunksdistance_threshold: Similarity threshold for retrieval (0-1)
The tool includes security measures for potentially dangerous operations:
- User confirmation for destructive operations
- Process isolation
- Context cleanup
- Error handling
This project is licensed under the MIT License - see the LICENSE file for details.
[Aayush Chawla] mail@aay.sh