-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add mako template rendering #1082
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
Open
clementb49
wants to merge
13
commits into
master
Choose a base branch
from
feature/mako-templating
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
dfe4658
chore(ders): add mako dependency
clementb49 fa9e32c
chore: add .worktrees to .gitignore
clementb49 9144f07
feat: add TemplateService for Mako-based prompt and HTML rendering
clementb49 9719f91
feat: use TemplateService in HtmlViewWindow instead of str.format
clementb49 7ae1c36
feat: add TemplatesSettings to BasiliskConfig for custom template paths
clementb49 cae121f
feat: add HTML template path controls to Preferences dialog
clementb49 8f95694
feat: render system prompt Mako template when applying profile
clementb49 f9bd01b
feat: render system prompt Mako template when applying profile
clementb49 5c4f648
feat: add system prompt preview button to profile editor
clementb49 d597c43
feat: add Export conversation as HTML menu action
clementb49 0e5cd9f
fix: capitalize docstring and move datetime import to module level in…
clementb49 9926715
refactor: move file-dialog save/export logic to ConversationTab
clementb49 64d06db
fix: address code review findings on mako template PR
clementb49 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,4 @@ basilisk_config.yml | |
| *.mo | ||
| user_data/ | ||
| coverage.xml | ||
| .worktrees/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>${conversation.title or _("Conversation") | h}</title> | ||
| <style> | ||
| body { font-family: system-ui, sans-serif; max-width: 860px; margin: 2rem auto; padding: 0 1rem; color: #1a1a1a; background: #fff; } | ||
| article { margin-bottom: 2rem; border-radius: 6px; padding: 1rem 1.25rem; } | ||
| article.user { background: #f0f4ff; } | ||
| article.assistant { background: #f6faf3; } | ||
| .meta { font-size: 0.8rem; color: #666; margin-top: 0.5rem; } | ||
| pre { background: #f4f4f4; padding: 0.75rem; border-radius: 4px; overflow-x: auto; } | ||
| code { font-family: monospace; } | ||
| @media (prefers-color-scheme: dark) { | ||
| body { background: #1a1a1a; color: #e8e8e8; } | ||
| article.user { background: #1e2a40; } | ||
| article.assistant { background: #1a2d1a; } | ||
| .meta { color: #aaa; } | ||
| pre { background: #2a2a2a; } | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>${conversation.title or _("Conversation") | h}</h1> | ||
| % if profile: | ||
| <p class="meta">${_("Profile")}: ${profile.name | h}</p> | ||
| % endif | ||
| </header> | ||
| <main role="log" aria-label="${_('Conversation history')}"> | ||
| % for block in conversation.messages: | ||
| <article class="user" aria-label="${_('User message')}"> | ||
| <div>${block.request.content | h}</div> | ||
| % if block.request.attachments: | ||
| % for att in block.request.attachments: | ||
| <% | ||
| mime = att.mime_type or "application/octet-stream" | ||
| is_image = mime.startswith("image/") | ||
| b64 = att.encoded_data if hasattr(att, "encoded_data") else "" | ||
| %> | ||
| % if is_image: | ||
| <img src="data:${mime};base64,${b64}" alt="${att.name | h}" style="max-width:100%"> | ||
| % else: | ||
| <a href="#" onclick="downloadAttachment('${b64}','${att.name | h}','${mime}');return false">${_("Download")} ${att.name | h}</a> | ||
| % endif | ||
| % endfor | ||
| % endif | ||
| </article> | ||
| % if block.response: | ||
| <article class="assistant" aria-label="${_('Assistant message')}"> | ||
| <div>${block.response.content | h}</div> | ||
| <p class="meta"> | ||
| ${block.model.name | h} — | ||
| <time datetime="${block.created_at.isoformat()}">${block.created_at.strftime('%Y-%m-%d %H:%M')}</time> | ||
| </p> | ||
| </article> | ||
| % endif | ||
| % endfor | ||
| </main> | ||
| <script> | ||
| function downloadAttachment(b64, filename, mime) { | ||
| const bytes = atob(b64); | ||
| const arr = new Uint8Array(bytes.length); | ||
| for (let i = 0; i < bytes.length; i++) arr[i] = bytes.charCodeAt(i); | ||
| const blob = new Blob([arr], {type: mime}); | ||
| const a = document.createElement('a'); | ||
| a.href = URL.createObjectURL(blob); | ||
| a.download = filename; | ||
| a.click(); | ||
| } | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>${title | h}</title> | ||
| </head> | ||
| <body> | ||
| ${content} | ||
| </body> | ||
| </html> |
Oops, something went wrong.
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.
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.
Roll back staged config changes when saving fails.
These assignments mutate the live
config.conf()object beforeconf.save()runs. Ifsave()raises, the dialog stays open but the process is still using the unsaved values, so a failed save can silently change runtime behavior for the rest of the session. Stage the edits on a copy or restore the previous config state in theexceptpath.🤖 Prompt for AI Agents