adding support for thinking models #882
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
updated VannaBase.extract_sql to strip out , , , and tags—used by models like Alibaba’s Qwen3 to wrap intermediate reasoning—before parsing SQL. Without this, the extractor sometimes misread the reasoning as part of the query.
What Changed:
Tag Removal: We loop through known reasoning tags and use non-greedy regex (e.g. …) to clean them out.
Whitespace Cleanup: Removes extra blank lines to avoid confusing the parser.
Safe Defaults: If no tags are present (like with normal LLMs), nothing changes.
Why It Matters:
Qwen3 and similar LLMs output thoughts in XML-style tags. We now clean those up so only the final SQL remains, ensuring compatibility without breaking existing behavior.
Edge Cases:
Only known tags are removed—new ones (e.g., ) won’t be unless added.
Assumes well-formed tags; malformed ones may slip through.
Regex is cautious to avoid removing too much.
Minimal performance cost.