microsoft / llguidance

Low-level Guidance Parser
MIT License
27 stars 7 forks source link

[Bug] Unhelpful error message for simple HTML grammar #9

Open riedgar-ms opened 3 months ago

riedgar-ms commented 3 months ago

I've created a very simple HTML cookbook for Guidance: https://github.com/Harsha-Nori/guidance-cookbook/tree/main/simple-html However, when trying to run this against and Azure AI deployed model, I got a rather strange error message: image This is.... not particularly helpful to someone who isn't an expert in grammars and the like.

I was eventually able to bully things into working by simplifying the HTML which could be generated even more, but the limit I appear to be encountering seems very low given how simple the basic structure being described is.

mmoskal commented 3 months ago

If you use gen(regex=[^<>]+) or similar for gen text it should work

riedgar-ms commented 3 months ago

That did it ... although that's not an entirely obvious fix.

Sorry for the deleted comments, I managed to mess up my initial application of your fix

mmoskal commented 2 months ago

Yeah, I agree. I think we should have a warning about zero_or_more(char_range(...)) and similar. In some cases, we may be able to automatically wrap them in as_regular_grammar() (it's equivalent to gen()), however it is a bit tricky not to mess with semantics...