Merge pull request #3242 from SillyTavern/role-icons-for-PM add prompt role icons to prompt manager
Signed| @@ -28,6 +28,11 @@ | ||
| 28 | 28 | color: var(--white50a); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | +#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt .completion_prompt_manager_prompt_name .fa-solid[data-role] { | |
| 32 | + vertical-align: unset; | |
| 33 | + margin-left: 3px; | |
| 34 | +} | |
| 35 | + | |
| 31 | 36 | #completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible { |
| 32 | 37 | display: none; |
| 33 | 38 | } |
| @@ -260,7 +265,7 @@ | ||
| 260 | 265 | } |
| 261 | 266 | |
| 262 | 267 | #completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt .completion_prompt_manager_prompt_name .fa-solid.prompt-manager-overridden { |
| 263 | 268 | margin-left: 5px3px; |
| 264 | 269 | color: var(--SmartThemeQuoteColor); |
| 265 | 270 | cursor: pointer; |
| 266 | 271 | opacity: 0.8; |
| @@ -6113,8 +6113,12 @@ | ||
| 6113 | 6113 | <label for="completion_prompt_manager_popup_entry_form_role"> |
| 6114 | 6114 | <span data-i18n="Role">Role</span> |
| 6115 | 6115 | </label> |
| 6116 | - <div class="text_muted" data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</div> | |
| 6116 | + <div class="text_muted"> | |
| 6117 | + <span data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</span> | |
| 6118 | + <span data-i18n="Unspecified = Prompt Manager decides.">Unspecified = Prompt Manager decides.</span> | |
| 6119 | + </div> | |
| 6117 | 6120 | <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role"> |
| 6121 | + <option data-i18n="Unspecified" value="">Unspecified</option> | |
| 6118 | 6122 | <option data-i18n="System" value="system">System</option> |
| 6119 | 6123 | <option data-i18n="User" value="user">User</option> |
| 6120 | 6124 | <option data-i18n="AI Assistant" value="assistant">AI Assistant</option> |
| @@ -430,7 +430,7 @@ class PromptManager { | ||
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_name').value = prompt.name; |
| 433 | 433 | document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_role').value = 'system'; |
| 434 | 434 | document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_prompt').value = prompt.content ?? ''; |
| 435 | 435 | document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_position').value = prompt.injection_position ?? 0; |
| 436 | 436 | document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_depth').value = prompt.injection_depth ?? DEFAULT_DEPTH; |
| @@ -1208,7 +1208,7 @@ class PromptManager { | ||
| 1208 | 1208 | const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block'); |
| 1209 | 1209 | |
| 1210 | 1210 | nameField.value = prompt.name ?? ''; |
| 1211 | 1211 | roleField.value = prompt.role ?? 'system'; |
| 1212 | 1212 | promptField.value = prompt.content ?? ''; |
| 1213 | 1213 | promptField.disabled = prompt.marker ?? false; |
| 1214 | 1214 | injectionPositionField.value = prompt.injection_position ?? INJECTION_POSITION.RELATIVE; |
| @@ -1518,7 +1518,7 @@ class PromptManager { | ||
| 1518 | 1518 | let detachSpanHtml = ''; |
| 1519 | 1519 | if (this.isPromptDeletionAllowed(prompt)) { |
| 1520 | 1520 | detachSpanHtml = ` |
| 1521 | 1521 | <span title="Remove" class="prompt-manager-detach-action caution fa-solid fa-chain-broken fa-xs"></span> |
| 1522 | 1522 | `; |
| 1523 | 1523 | } else { |
| 1524 | 1524 | detachSpanHtml = '<span class="fa-solid"></span>'; |
| @@ -1527,7 +1527,7 @@ class PromptManager { | ||
| 1527 | 1527 | let editSpanHtml = ''; |
| 1528 | 1528 | if (this.isPromptEditAllowed(prompt)) { |
| 1529 | 1529 | editSpanHtml = ` |
| 1530 | 1530 | <span title="edit" class="prompt-manager-edit-action fa-solid fa-pencil fa-xs"></span> |
| 1531 | 1531 | `; |
| 1532 | 1532 | } else { |
| 1533 | 1533 | editSpanHtml = '<span class="fa-solid"></span>'; |
| @@ -1543,6 +1543,7 @@ class PromptManager { | ||
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | const encodedName = escapeHtml(prompt.name); |
| 1546 | + const isRolePrompt = !!prompt.role; | |
| 1546 | 1547 | const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE; |
| 1547 | 1548 | const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides; |
| 1548 | 1549 | const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides; |
| @@ -1550,16 +1551,27 @@ class PromptManager { | ||
| 1550 | 1551 | const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE; |
| 1551 | 1552 | const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier); |
| 1552 | 1553 | const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; |
| 1554 | + | |
| 1555 | + //add role icons to the right of prompt name | |
| 1556 | + const promptRoles = { | |
| 1557 | + system: { roleIcon: 'fa-cog', roleTitle: 'Prompt will be sent as System' }, | |
| 1558 | + assistant: { roleIcon: 'fa-robot', roleTitle: 'Prompt will be sent as Assistant' }, | |
| 1559 | + user: { roleIcon: 'fa-user', roleTitle: 'Prompt will be sent as User' }, | |
| 1560 | + }; | |
| 1561 | + const roleIcon = isRolePrompt ? promptRoles[prompt.role]?.roleIcon : ''; | |
| 1562 | + const roleTitle = isRolePrompt ? promptRoles[prompt.role]?.roleTitle : ''; | |
| 1563 | + | |
| 1553 | 1564 | listItemHtml += ` |
| 1554 | 1565 | <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}"> |
| 1555 | 1566 | <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}"> |
| 1556 | 1567 | ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''} |
| 1557 | 1568 | ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''} |
| 1558 | 1569 | ${isImportantPrompt ? '<span class="fa-fw fa-solid fa-star" title="Important Prompt"></span>' : ''} |
| 1559 | 1570 | ${isUserPrompt ? '<span class="fa-fw fa-solid fa-userasterisk" title="UserPreset Prompt"></span>' : ''} |
| 1560 | 1571 | ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''} |
| 1561 | 1572 | ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`} |
| 1562 | 1573 | ${isInjectionPromptisRolePrompt ? `<smallspan classdata-role="${escapeHtml(prompt-manager.role)}" class="fa-injectionxs fa-depthsolid ${roleIcon}">@ title="${prompt.injection_depthroleTitle}"></smallspan>` : ''} |
| 1574 | + ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''} | |
| 1563 | 1575 | ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''} |
| 1564 | 1576 | </span> |
| 1565 | 1577 | <span> |