Repository navigation
Conversation
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.
This is the aidialog part of the dialog/document work in AnswerDotAI/mdhtml#91. The document importer needs to know whether a stored output is text, markdown, HTML or an image without first rendering it to markdown and then interpreting that again. The output selection and preparation already happened here inside
render_md, so this makes those prepared parts available separately.I also removed the
```outputlanguage label from plain-text output fences (mdhtml records its role as output in the document)Implementation details and design decisions (AI-written)
Separate preparation from serialization
out_parts(outputs, html1st=True)is now public. It returns an ordered list of(kind, text)pairs using four kinds:txt: plain text with ANSI escapes removed.html: HTML, SVG, or JavaScript wrapped in a script element.md: Markdown or LaTeX content.img: a raster image represented as a data URI.MIME selection still uses the existing
preferred_msg_outbehavior. HTML remains preferred by default;html1st=Falseprefers Markdown when available.Consecutive text outputs are pooled into one
txtpart. Encountering a non-text part flushes that pool, preserving output order. Stream handling continues to useconcat_streams.This gives document consumers access to the prepared content before Markdown-specific fences and image syntax are added. No dependency on mdhtml is introduced.
One Markdown writer for prepared outputs
render_md_parts(parts)serializes prepared parts:{=html}raw fence.render_md(outputs, html1st=True)retains its existing entry point and becomes the composition ofout_partsandrender_md_parts. Callers that already prepared the outputs can use the same writer without repeating MIME selection or maintaining another renderer.The previous private
_render_mdmixed MIME interpretation with Markdown serialization. Its preparation work now lives in_out_partandout_parts.Compatibility
Plain-text output fences change from a fence labelled
outputto a bare fence. Consumers that identify output regions using that language label need adjusting. Other output-format conventions remain the same.These APIs are required by the companion mdhtml changes. The release version and mdhtml’s minimum aidialog dependency need coordinating.
Documentation and validation
The implementation, examples and assertions are updated in
nbs/01_dialog.ipynb; the Python module and symbol index are regenerated exports.The notebook checks HTML/Markdown preference, prepared HTML and image parts, image serialization, error rendering, and text containing backticks.
nbdev-test nbs/01_dialog.ipynbpassed.