-
Notifications
You must be signed in to change notification settings - Fork 99
feat: describegpt use minijinja engine for prompt processing
#3188
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
Conversation
…duce JSON unreliably
moving prompt building more to minijinja
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the describegpt command by migrating from a manual string replacement approach to using the minijinja template engine for prompt processing. This aligns describegpt with other qsv commands (template and fetchpost) that already leverage minijinja for dynamic content generation. Additionally, the PR includes improvements to JSON extraction logic to better handle common formatting issues from LLM responses.
Key Changes
- Replaced manual string replacement (
.replace("{VARIABLE}", value)) with minijinja template engine rendering - Updated template syntax in
resources/describegpt_defaults.tomlfrom{VARIABLE}to{{ variable }}(Jinja2 syntax) - Enhanced JSON extraction with automatic fixing of common issues (unescaped newlines, tabs, carriage returns in strings)
- Added fallback patterns for extracting JSON from LLM responses with both non-greedy and greedy regex matching
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/cmd/describegpt.rs | Integrated minijinja for template rendering, replaced manual string substitution with context-based rendering, improved JSON extraction with auto-fixing logic for malformed responses, and updated documentation |
| resources/describegpt_defaults.toml | Migrated all prompt templates from {VARIABLE} to {{ variable }} Jinja2 syntax, added conditional logic with {% if %} blocks, used {% raw %} blocks to escape JSON examples, and updated variable documentation |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
resolves #3023