Skip to content

Conversation

@jorge-campo
Copy link
Contributor

Summary

This PR adds a deterministic, script-based process to convert our OneDoc Markdown procedure templates into machine-readable JSON. It replaces ad-hoc chat usage with an API-driven flow to ensure consistent, reviewable results across runs and users.

Why not a chat window

  • Chat UIs do not let us pin all runtime parameters (model version, seed, response format) and often apply hidden defaults. Results vary between sessions and users.
  • We need JSON-only output with strict ordering and fixed validation fields. Chat UIs sometimes add prose, formatting, or paraphrase text.
  • Some models (for example, GPT-5 variants) ignore or reject sampling parameters. The API script handles these model constraints explicitly and retries safely.

What this adds

  • md2json-prompt-templates.md

    • The deterministic instructions for Markdown → JSON conversion. No paraphrasing, fixed key order, canonical rule grouping, and fixed validation messages.
  • transform.py

    • A Python runner that calls the LLM via API, enforces JSON-only responses, validates JSON, and writes the result.

Inputs and outputs

  • Inputs

    • md2json-prompt-templates.md (do not edit without bumping the version)
    • The Markdown source file (for example, quickstart-template.md)
    • Environment variables to choose backend and model
  • Outputs

    • <output>.json — the final schema-compliant JSON
    • <output>.json.raw.txt — only if the model returns non-JSON, for debugging

Security and keys

  • API keys are read from environment variables in the active shell and sent only over HTTPS.
  • The script never logs or writes keys to disk.

How to review this PR:

  1. Complete the PR review for the Markdown template you're working on.
  2. Create a OpenAI API Key in https://platform.openai.com/. Copy the key somewhere; you will need it to run the script. Do not share your key and don't copy the key to any file you push to the repo. You may need to add credit to your OpenAI account.
  3. Using the process described in the README.md in this PR, set up your environment and create the JSON template from Markdown.
  4. If anything is unclear while doing this process, update the README.md.
  5. Verify that the output JSON is clean from errors. At the end of the JSON file, you should see the validation section empty:
  "validation": {
    "missingRuleIds": [],
    "duplicateRuleIds": [],
    "groupViolations": [],
    "forbiddenViolations": [],
    "notes": []
  }
  1. Move the JSON template you have generated to its corresponding folder at manual/2-populate-the-structure/templates.
  2. Send the JSON template for review.

@jorge-campo jorge-campo requested a review from cheny0 October 28, 2025 16:00
@jorge-campo jorge-campo self-assigned this Oct 28, 2025
@jorge-campo jorge-campo added the deliverables Any other project deliverable label Oct 28, 2025
@jorge-campo jorge-campo linked an issue Oct 28, 2025 that may be closed by this pull request
@jorge-campo jorge-campo merged commit c4ff11b into main Nov 3, 2025
@jorge-campo jorge-campo deleted the 73-procedure-for-md-to-json-templates-converstion branch November 3, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deliverables Any other project deliverable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Procedure for Markdown to JSON templates conversion

3 participants