Skip to content

Crashes whenever it's about to output a code block #1

@Mouradif

Description

@Mouradif

Using deepseek-r1-distill-qwen-1.5b-q4-0.gguf, I asked the model to generate code 3 distinct times. I could see the whole reasoning then something like "Here's the code for (whatever-I-asked-for):" then it crashes with

panicked at /Users/sebcrozet/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/web-framework-markdown-0.0.1/src/render.rs:408:18:
expected string event, got something else

Stack:

Error
    at imports.wbg.__wbg_new_8a6f238a6ece86ea (https://wgmath.rs/assets/wgml-chat-037d1557cb8c1e8b.js:2:22945)
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[17255]:0x39cdb3
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[2431]:0x232adc
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[20284]:0x3a8076
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[4161]:0x29d3d0
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[5158]:0x2c7fea
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[19951]:0x3a74b2
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[13926]:0x3828ca
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[13927]:0x3828f7
    at https://wgmath.rs/assets/wgml-chat_bg-82a20fa9032c28bc.wasm:wasm-function[3144]:0x2650d2

Seeing that the panic seems to be in web-framework-markdown crate, I feel like it might have something to do with the model starting a triple-backquote code block. This only happens in that scenario and the crash occurs right where you would expect the model to start a code block.

Looking at the code from 2 months ago in web-framework-markdown (when the crate was published)

    /// extract the text from the next text event
    fn children_text(&mut self, tag: Tag<'a>) -> Option<String> {
        let text = match self.stream.next() {
            Some((Event::Text(s), _)) => Some(s.to_string()),
            None => None,
            _ => panic!("expected string event, got something else"), // <-- this is line 408
        };

        self.assert_closing_tag(tag.to_end());
        text
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions