-
Notifications
You must be signed in to change notification settings - Fork 203
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
Quotes aren't always parsed properly #324
Comments
Thanks for reporting. Marking this as a good first issue. The fix is likely somewhere close to https://github.com/eth-sri/lmql/blob/main/src/lmql/language/compiler.py#L428, where we compile LLM query strings into multi-line strings in the compiled representation of the program. |
I did some investigation and here are my findings: import lmql
@lmql.query()
def quote_at_begin():
'''lmql
"\"x\"=123"
'''
# This case passes without any errors.
@lmql.query()
def quote_at_end():
'''lmql
"123=\"x\""
'''
# This triggers a SyntaxError:
# SyntaxError: unterminated string literal (detected at line 1) So only the A temporary workaround is to check if we ends with quote and add a space after it to make the parser working and then remove the space immediately after parsing. |
I think the behavior of To fix this issue, I think it should be enough to just add:
This prevents a |
For example:
Fails with the error:
There is an ugly workaround for now:
The text was updated successfully, but these errors were encountered: