Skip to content

feat(phase-13): natural-language prompt parser + 'ropeway ask' CLI#21

Merged
harsh-pandhe merged 1 commit into
mainfrom
feat/phase-13-nlp
May 20, 2026
Merged

feat(phase-13): natural-language prompt parser + 'ropeway ask' CLI#21
harsh-pandhe merged 1 commit into
mainfrom
feat/phase-13-nlp

Conversation

@harsh-pandhe
Copy link
Copy Markdown
Owner

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)

  • 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
  • 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
  • format_summary(req) -> str — human-readable single-paragraph summary
  • run_from_prompt(text) -> dict — parsed request + metrics + feasibility
  • llm_available() -> bool — True iff ANTHROPIC_API_KEY is set (for the optional fallback)

CLI

ropeway ask "build a 2 km MGD with seed 7"
# Parsed request:
#   system: mgd | corridor: 2000 m synthetic | seed: 7
# Running optimizer on synthetic terrain...
# Feasible: True
#   intermediate_towers: 4
#   cable_length_m: 2161.0
#   ...

Test plan

  • tests/test_nlp.py27 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 passing, zero regressions
  • CLI smoke-tested: ropeway ask parses and runs end-to-end

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.
@harsh-pandhe harsh-pandhe merged commit 564ba79 into main May 20, 2026
2 checks passed
@harsh-pandhe harsh-pandhe deleted the feat/phase-13-nlp branch May 20, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant