A natural language to SQL conversion tool with semantic understanding.
- Convert natural language questions to SQL queries
- Semantic understanding of database schema
- Safe, read-only query execution
- Rich, formatted output options
- Interactive mode for multiple queries
- Persistent conversation state with Redis session management
- Horizontal scalability with distributed session storage
# Install using Poetry
poetry install
# Or using pip
pip install -r requirements.txtCreate a .env file with your database, LLM, and Redis settings:
# Database
SENS_DB_URL=postgresql://user:pass@localhost:5432/dbname
# OpenRouter LLM
SENS_OPENROUTER_API_KEY=your_api_key
SENS_OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
# Redis Session Management (optional)
SENS_REDIS_URL=redis://localhost:6379
SENS_SESSION_TTL_SECONDS=86400 # 24 hoursIf Redis is not available, Sens will operate in a degraded mode with in-memory session state.
# Convert a question to SQL
sens nl2sql -q "How many users signed up last month?"
# Interactive mode
sens nl2sql -i
# Execute a SQL query
sens execute "SELECT * FROM users LIMIT 5"For more details on system administration commands like debug, metrics, and status, as well as advanced CLI configuration options, please see the Sens CLI Commands and Configuration documentation.
The nl2sql command supports different output formats:
# JSON output (default)
sens nl2sql -q "List all users" --format json
# Table format with preview
sens nl2sql -q "List all users" --format table
# Summary only
sens nl2sql -q "List all users" --format summary
# Control preview rows
sens nl2sql -q "List all users" --max-rows 10
# Hide preview
sens nl2sql -q "List all users" --no-preview# Extract database schema
sens extract-schema -o schema.json
# Build search indices
sens build-index -s schema.json# Run tests
poetry run pytest
- Full Documentation - Complete documentation index
- Architecture Overview - System design
- API Reference - Interactive API docs
- Deployment Guide - Production deployment
- Test Coverage - Testing status
SENS is evolving towards an intelligent, proactive data platform:
- ✅ Natural language to SQL
- ✅ Multi-datasource support
- ✅ Web interface
- ✅ Session management
- 🚧 Intelligent value mapping
- 🚧 Self-correcting queries
- 🚧 Learning from interactions
- 📅 Proactive insights
See the full Roadmap for details.
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone your fork
git clone https://github.com/yourusername/sens.git
cd sens
# Install development dependencies
poetry install --with dev
# Set up pre-commit hooks
pre-commit install
# Run tests before committing
poetry run pytestThis project is licensed under the MIT License - see the LICENSE file for details.
- OpenRouter for LLM infrastructure
- The FastAPI team for the excellent framework
- All contributors who have helped improve SENS
- 📖 Documentation
- 🐛 Issue Tracker
- 💬 Discussions
- 📧 Email: support@sens-ai.dev
Made with ❤️ by the SENS team
poetry run mypy src
## License
MIT License. See LICENSE file for details.