feat(phase-13): natural-language prompt parser + 'ropeway ask' CLI#21
Merged
Conversation
Phase 13 ships an LLM-style natural-language interface to the optimizer
WITHOUT pinning a third-party SDK or an API key into the test path.
Design: deterministic rule-based parser is the primary, fully-tested
path. Anthropic SDK / LLM fallback is left as an optional hook gated
on ANTHROPIC_API_KEY; CI never exercises it. The CLI surface mirrors
this — 'ropeway ask "build a 2 km MGD with seed 7"' works offline.
What the parser recognises (src/ropeway/nlp.py):
- system: mgd, jigback, bgd, 3s, funitel, chair + English aliases
('urban gondola' -> MGD, 'aerial tram' -> jigback, 'tri-cable' -> 3S,
'six-pack' -> chairlift)
- corridor length: '2 km', '2.5km', '2000 m', 'two kilometres'
- coordinates: two (lon,lat) pairs separated by comma or space, range
validated against WGS84 envelope
- generations / seed / max_towers — num-before-keyword preferred so
'80 generations, seed 7' doesn't bleed the seed into the gens field
API:
- parse_prompt(text) -> ParsedRequest dataclass
- format_summary(req) -> single-paragraph human-readable summary
- run_from_prompt(text) -> dict with parsed request + metrics + feasibility
- llm_available() -> True iff ANTHROPIC_API_KEY is set (for the optional
fallback path)
CLI:
- 'ropeway ask <prompt...>' parses the prompt, prints the parsed
request, runs on synthetic terrain, and prints the headline metrics.
Tests: tests/test_nlp.py — 27 new tests covering length parsing
(numeric + word forms), system aliasing, coordinate pairs, num-vs-
keyword precedence, summary formatting, run_from_prompt orchestration.
Full suite 157 -> 184, zero regressions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 13 ships an LLM-style natural-language interface to the optimizer without pinning a third-party SDK or an API key into the test path.
Design choice: deterministic rule-based parser is the primary, fully-tested path. Anthropic SDK / LLM fallback is left as an optional hook gated on
ANTHROPIC_API_KEY; CI never exercises it. The CLI surface mirrors this —ropeway ask "build a 2 km MGD with seed 7"works offline.What the parser recognises (
src/ropeway/nlp.py)mgd,jigback,bgd,3s,funitel,chair+ English aliases (urban gondola→ MGD,aerial tram→ jigback,tri-cable→ 3S,six-pack→ chairlift)2 km,2.5km,2000 m,two kilometres80 generations, seed 7doesn't bleed the seed into the gens fieldAPI
parse_prompt(text) -> ParsedRequestformat_summary(req) -> str— human-readable single-paragraph summaryrun_from_prompt(text) -> dict— parsed request + metrics + feasibilityllm_available() -> bool— True iffANTHROPIC_API_KEYis set (for the optional fallback)CLI
Test plan
tests/test_nlp.py— 27 new tests covering length parsing (numeric + word forms), system aliasing, coordinate pairs, num-vs-keyword precedence, summary formatting,run_from_promptorchestrationropeway askparses and runs end-to-end