Natural language to constraint solver. Describe optimization problems in English, get mathematically guaranteed solutions.
Website • Documentation • Skelf Research
Savanty combines LLM understanding with Answer Set Programming (ASP) to solve scheduling, allocation, and planning problems. The LLM translates your problem into formal constraints; the solver guarantees correctness.
pip install savanty
export OPENAI_API_KEY=your_key_herefrom savanty import solve_optimization_problem
result = solve_optimization_problem("""
Schedule 4 nurses (Alice, Bob, Carol, Dave) for morning/evening shifts
over 5 days. Each shift needs 1 nurse. Max 4 shifts per person.
""")
print(result.solution) # The assignment
print(result.asp_code) # Generated ASP (for debugging)savanty -p "Assign 5 tasks to 3 workers, balance workload"savanty --web # REST API at http://localhost:8000# Core package
pip install savanty
# With desktop GUI
pip install 'savanty[desktop]'
# Development
pip install 'savanty[dev]'Requirements: Python 3.10+ and an OpenAI API key
Returns a ProblemSolverResult with:
| Attribute | Type | Description |
|---|---|---|
solution |
str |
The solution if found |
asp_code |
str |
Generated ASP program |
visualization_html |
str |
HTML visualization |
needs_more_info |
bool |
True if clarification needed |
questions |
list[str] |
Clarifying questions |
error |
str |
Error message if failed |
not_suitable |
bool |
True if problem doesn't fit ASP |
result = solve_optimization_problem("Schedule my team")
if result.needs_more_info:
# Solver needs clarification
print("Questions:", result.questions)
# Re-call with answers
result = solve_optimization_problem(
"Schedule my team",
additional_info="5 people, morning/evening shifts, 7 days"
)
elif result.not_suitable:
# Wrong tool for this problem
print(f"Try: {result.suggested_tool}")
elif result.error:
print(f"Error: {result.error}")
else:
# Success
print(result.solution)savanty --web --port 8000POST /solve
curl -X POST http://localhost:8000/solve \
-H "Content-Type: application/json" \
-d '{"problem_description": "Assign 3 tasks to 2 workers"}'GET /health — Health check GET /ready — Readiness check (verifies API key)
OpenAPI docs at /docs when server is running.
Savanty excels at discrete constraint satisfaction:
| Good Fit | Not a Good Fit |
|---|---|
| Shift scheduling | Continuous optimization |
| Task assignment | Machine learning |
| Route planning | Statistical analysis |
| Resource allocation | Real-time streaming |
| Seating arrangements | Simple arithmetic |
| Timetabling |
When a problem doesn't fit, Savanty tells you and suggests alternatives (scipy, sklearn, etc.).
English description → LLM extracts constraints → ASP solver → Guaranteed solution
- LLM (GPT-4o) parses your problem into entities, constraints, objectives
- Gap detection identifies missing info and asks clarifying questions
- Code generation produces Answer Set Programming (ASP) code
- Clingo solver exhaustively searches for valid solutions
- Visualization renders results as tables/charts
The key: LLMs understand language but hallucinate solutions. ASP solvers guarantee correctness but can't parse English. Savanty uses each for what it's good at.
# Required
export OPENAI_API_KEY=sk-...
# Optional
export SAVANTY_LLM_MODEL=openai/gpt-4o # Default model
export SAVANTY_PORT=8000 # Web server port
export SAVANTY_LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
export SAVANTY_SOLVE_TIMEOUT=120 # Timeout in secondsSee .env.example for all options.
git clone https://github.com/skelf-research/savanty.git
cd savanty
uv sync --extra dev
# Run tests
uv run pytest
# Lint
uv run ruff check .
uv run ruff format .
# Run locally
uv run savanty --websavanty/
├── savanty/
│ ├── solver.py # Core solver logic
│ ├── dspy_modules.py # LLM prompts (DSPy signatures)
│ ├── cli.py # CLI + FastAPI server
│ └── logging_config.py # Logging setup
├── frontend/ # Vue.js web interface
├── desktop/ # Slint desktop app
├── tests/
└── documentation/ # MkDocs site
- Clingo — ASP solver (correctness guarantee)
- DSPy — LLM orchestration
- FastAPI — REST API
- Vue.js — Web frontend
- Slint — Desktop GUI
MIT — see LICENSE
savanty is built by Skelf Research — an independent UK AI research lab publishing production-grade open-source projects.
🌐 Website · 📚 Documentation · 🔬 All projects · 🤗 Hugging Face
Related projects: mpl (agent-comms contracts) · compere (pairwise ranking) · l0l1 (AI SQL co-pilot)
Released under MIT / Apache-2.0. © Skelf Research Limited.