-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
patch-error-on-invalid-grammar #2282
Conversation
Can you provide a triggering error. Ideally this is handled on the Rust HTTP server. Silently ignoring the grammar is the worst solution (which we might have to resort to depending on the complexity incurred of making a real check). @drbh for vis. |
Okay, that makes sense 👍 I'll work out a solution where we move the error to the rust server. |
In summary:
Suggestion: if the json-->regex compilation fails --> allow anything in grammar (silent failure) and print error log to stdout How to reproduce behavior, run TGI and send in this request: curl localhost:3000/generate \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"inputs": "My name is Olivier and I",
"parameters": {
"grammar": {"type": "json", "value": {"abc":"def"}}
}
}' |
Updating here some of the offline discussion I've had:
|
approving and merging although this path should not fire in any case. This is added as a defensive measure as noted above. |
* quick fix * allow silent failure * explicit todo that this is only short term
What does this PR do?
Implementation
Try + except the
schema = build_regex_from_schema(schema)
and returnNone
from_cached_compile_fsm
if grammar compilation fails.There might be a better place to do the error handling. This solution in a way creates two errors, like here:
But the error from outlines is clear and this doesn't crash the server. So the job gets done.
This is what the result looks like on the client side: