-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial mode #10
Comments
This would also be useful for MDX IntelliSense, as content tends to be invalid while typing. Related: mdx-js/mdx-analyzer#267 |
The first and third have little to do with a stack, how would you want to solve that? This micromark extension I think doesn't use a stack, the stack is handled in the corresponding mdast utility |
Can you tell me more what you mean by the first not being related to stacks? Agreed for the third – that case was just clarifying that when the input was already valid, the output is unchanged. |
This PR adds `MdxChatCompletion`, which produces MDX output as a string. It does not handle: * Auto-healing partial MDX (related: micromark/micromark-extension-mdx-jsx#10) * Rendering to the UI I agree with @zkoch that this also might not be the final API we want. I added docs for this, but as a standalone, this feature isn't super interesting – it gets fun when we're actually able to render to the UI. That can be a follow-up. To verify that I didn't break the previous `UICompletion` component, I manually tested the nextjs demo at http://localhost:3000/recipe.
Adding another perspective in. I do think that some form of partial render could have value for authoring experience, human based or machine based. That said, I don't think speculative healing is a good idea for the parser. Giving a hypothetical example of how this distinction could be a problem (grounded in past experience maintaining MDX and remark). Problem 1: We now have an option only designed for development, enabled in production Down the road, the MDX maintainer team makes changes to improve the autohealing, and the authoring experience. Problem 2: We now have an unstable and unofficial API, being relied on as a SemVer stable API. I'm against adding auto healing to the core parser. |
That would work perfectly well for my usecase. (Preferably, there would be some signal from the compiler API to let the caller know that the render was partial.) |
The tag is still open. The tag needs to be closed before it can be pushed to a stack or popped off a stack.
To me, the 3rd is already some form of “autohealing” / “partial mode”. See #7.
Pausing could live here, right? Or where do you see it? Currently, in JS either a successful result is returned or an error is thrown. I guess the solution here is to expose the up to the error result, on errors? (perhaps optionally?). |
Yep, I think we're saying the same thing. I just meant that, if the parser sees something like |
The error is earlier, when parsing, before stacks: |
Pausing could live here
That could make sense
Right, there can still be issues downstream, even if |
Something like this isn’t really a high priority for me to work on currently. Could be years. But I can always advise if someone else finds this important and wants to work on this! |
Initial checklist
Problem
I'm working with large language models, which are relatively slow, so streaming/incremental output is important to a good user experience. (The project I'm working in is https://github.com/fixie-ai/ai-jsx.)
My LLM calls stream MDX. I'd like to be able to show the partially-rendered MDX to the user. However, if the MDX is incomplete, this parser crashes via the
crash
function (e.g. https://github.com/micromark/micromark-extension-mdx-jsx/blob/main/dev/lib/factory-tag.js#L311).Solution
Ideally, there would be a "partial" mode (similar to untruncate-json) which auto-closes all open AST nodes via best-guess.
Obviously, this might produce semantically strange results; it would be up to the caller to opt-in and handle these gracefully.
Alternatives
I considered sidestepping the compiler entirely and implementing my own function that maintains a stack, crawls the MDX as a string, and when it reaches the conclusion, tries to close everything on the stack.
My suspicion is that this would be simpler to implement for the easy cases, but using a modified version of the compiler would be more robust for the long tail.
The text was updated successfully, but these errors were encountered: