Conversation
`in2lambda wizard INPUT -o draft.md` turns a PDF/docx/tex/md document into the #/## markdown the Markdown filter reads, for a human to review before `in2lambda convert draft.md Markdown`. - wizard/run.py: routes input through Mathpix (PDF) / pandoc (docx) / raw read, runs one LLM extraction pass, renders #/## markdown, echoes check_markdown() warnings, writes the file. - wizard/extract.py: pydantic WizardSet/WizardQuestion/WizardPart + extract_set() via the OpenAI structured-output parse helper against OpenRouter, with a system prompt and one few-shot example. to_markdown() renders the contract Step 3's filter consumes. - main.py: `wizard` command; run.py imported lazily so the rest of the CLI works without the llm extra. - Root conftest.py skips the pydantic-dependent wizard modules from --doctest-modules on a bare install (CI runs --all-extras). - docs/source/wizard.md + toctree, quickstart + README pointers. Slimmed from conversion2025/converter.py on Summer2025: the line-number extraction and the trim/dedupe/evaluate passes are left out of v1; prompt shape informed by wizard/to_question.py on wxyang_hackathon. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017VXb8aZqgFBjoeuuddjW6r
- Extend `runner()` and `convert` CLI to accept an optional `--name` (`-n`) parameter for naming question sets. - Sanitize `set_name` into a filesystem-safe "slug" for output paths. - Update JSON generation to use the sanitized name in filenames (`set_<name>.json`) and directories. - Add tests for named sets and update documentation to reflect the new functionality.
- Add `_demangle` function to restore LaTeX control words whose backslashes were lost to JSON un-escaping. - Adjust `extract_set` to apply `_demangle` to question titles, text, solutions, and parts. - Add test to verify proper handling of mangled LaTeX commands and preservation of newlines.
|
Notes from review. The overall shape (document in, reviewable markdown out, human checks it before conversion) looks right to me. Four things I'd fix first. The Mathpix step runs before
I realise newlines are left alone deliberately, and I agree you can't tell a real line break from a mangled A question-level solution is dropped when the question has parts. In CI quietly stopped testing Python 3.10. One thing to think about rather than change now: the model is asked for JSON and we then repair LaTeX that JSON escaping mangled, when the thing we actually want is markdown. Asking for markdown directly would remove the schema, the escaping repair and |
- Load .env / validate OPENROUTER_API_KEY before running (paid) Mathpix OCR, not after, so a missing key is caught before it's spent. - Document _demangle's two known limitations in its docstring: \n-prefixed commands (\nu, \nabla, \neq) can't be repaired, and a genuine control char before a letter (e.g. a table row) can false-positive. - Fold a question's overall/closing solution into its last part instead of silently dropping it when the question also has parts - the Markdown filter has no separate slot for a question-level solution once parts exist. - Restore the CI test matrix to ['3.10', '3.11'], reverting an accidental drop to 3.11-only that shipped in a mislabelled commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Pushed a fix in 4974a31 for the four points above:
On the JSON-vs-markdown design note: not changing now, per the framing above — leaving it as a follow-up thought. All lint ( |
in2lambda wizard INPUT -o draft.mdturns a PDF/docx/tex/md document into the#/##markdown the Markdown filter reads, for a human to review beforein2lambda convert draft.md Markdown.Commits on this branch
wizard/run.pyroutes input through Mathpix (PDF) / pandoc (docx) / raw read, runs one LLM extraction pass, renders#/##markdown, echoescheck_markdown()warnings, writes the file.wizard/extract.py: pydanticWizardSet/WizardQuestion/WizardPart+extract_set()via the OpenAI structured-output parse against OpenRouter (system prompt + one few-shot).to_markdown()renders the filter's contract.run.pyimported lazily so the rest of the CLI works without thellmextra.docs/source/wizard.md+ toctree, quickstart + README pointers.--name/-nforconvert— optional set name; sanitised into a filesystem-safe slug forset_<slug>.json/<slug>//<slug>.zip, raw name kept in the JSONnamefield (what Lambda Feedback shows on import). Default unchanged (set).\text/\frac/\betawith a single backslash;\t/\f/\b/\rare valid JSON escapes so the backslash is swallowed and the field ends up with a bare control char glued to the command.extract_setnow re-escapes any TAB/CR/FF/BS immediately followed by a letter. Newlines left as-is..gitignore(docs/_bt/,/e2e/); CI test matrix reduced to Python 3.11 (.github/workflows/test.yml; the commit is mislabelled "Updated gitignore").Testing done
black --check .,isort,pydocstyle, fullpytest --cov— green (93 passed, 92%;wizard/extract.py100%).openai/gpt-4o-mini) for.tex,.mdand.docxinputs:wizard→ review →convert→ validset.zip. The\text→TAB corruption is fixed and verified on the real model output.Known gaps / notes
pyproject.tomlkeepspython = "^3.10"while CI now tests only 3.11..texruns) — hence the mandatorydraft.mdreview step.Stack (top): … ← mathpix ← wizard-command
Base:
mathpix— #26. Merges after the whole stack (#21–#26).🤖 Generated with Claude Code