Add "unset" value for PM prompt role, refactor icons display
| @@ -28,6 +28,10 @@ | ||
| 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 | +} | |
| 34 | + | |
| 31 | 35 | #completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible { |
| 32 | 36 | display: none; |
| 33 | 37 | } |
| @@ -6115,6 +6115,7 @@ | ||
| 6115 | 6115 | </label> |
| 6116 | 6116 | <div class="text_muted" data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</div> |
| 6117 | 6117 | <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role"> |
| 6118 | + <option data-i18n="Default (unset)" value="">Default (unset)</option> | |
| 6118 | 6119 | <option data-i18n="System" value="system">System</option> |
| 6119 | 6120 | <option data-i18n="User" value="user">User</option> |
| 6120 | 6121 | <option data-i18n="AI Assistant" value="assistant">AI Assistant</option> |
| @@ -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; |
| @@ -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; |
| @@ -1552,36 +1553,16 @@ class PromptManager { | ||
| 1552 | 1553 | const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; |
| 1553 | 1554 | |
| 1554 | 1555 | //add role icons to the right of prompt name |
| 1555 | - | |
| 1556 | + const promptRoles = { | |
| 1556 | - const hasRole = !!prompt.role; | |
| 1557 | + system: { roleIcon: 'fa-cog', roleTitle: 'Prompt will be sent as System' }, | |
| 1557 | - let roleIcon, roleTitle; | |
| 1558 | + assistant: { roleIcon: 'fa-robot', roleTitle: 'Prompt will be sent as Assistant' }, | |
| 1558 | - if (hasRole) { | |
| 1559 | + user: { roleIcon: 'fa-user', roleTitle: 'Prompt will be sent as User' }, | |
| 1559 | - switch (prompt.role) { | |
| 1560 | + }; | |
| 1560 | - case 'system': | |
| 1561 | + const roleIcon = isRolePrompt ? promptRoles[prompt.role]?.roleIcon : ''; | |
| 1561 | - roleIcon = 'fa-cog'; | |
| 1562 | + const roleTitle = isRolePrompt ? promptRoles[prompt.role]?.roleTitle : ''; | |
| 1562 | - roleTitle = 'Prompt will be sent as System'; | |
| 1563 | - break; | |
| 1564 | - case 'assistant': | |
| 1565 | - roleIcon = 'fa-robot'; | |
| 1566 | - roleTitle = 'Prompt will be sent as Assistant'; | |
| 1567 | - break; | |
| 1568 | - case 'user': | |
| 1569 | - roleIcon = 'fa-user'; | |
| 1570 | - roleTitle = 'Prompt will be sent as User'; | |
| 1571 | - } | |
| 1572 | - | |
| 1573 | - // not sure if this makes sense to include as 'markers' should not be sendable except by System, included in case I'm wrong. | |
| 1574 | - // if it shouldn't be changeable, we should remove that dropdown from editor for Marker prompts. | |
| 1575 | - /* | |
| 1576 | - if (isMarkerPrompt && prompt.role !== 'user' && prompt.role !== 'assistant' && prompt.role !== 'system') { | |
| 1577 | - roleIcon = 'fa-cog'; | |
| 1578 | - roleTitle = 'ST Global Prompt is sent as System by default (but can be changed in Editor)'; | |
| 1579 | - } | |
| 1580 | - */ | |
| 1581 | - } | |
| 1582 | 1563 | |
| 1583 | 1564 | listItemHtml += ` |
| 1584 | 1565 | <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}"> |
| 1585 | 1566 | <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}"> |
| 1586 | 1567 | ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''} |
| 1587 | 1568 | ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''} |
| @@ -1589,8 +1570,8 @@ class PromptManager { | ||
| 1589 | 1570 | ${isUserPrompt ? '<span class="fa-fw fa-solid fa-user" title="Preset Prompt"></span>' : ''} |
| 1590 | 1571 | ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''} |
| 1591 | 1572 | ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`} |
| 1592 | 1573 | ${hasRoleisRolePrompt ? `<span data-role="${escapeHtml(prompt.role)}" class='"fa-xs fa-solid ${roleIcon}'" title='"${roleTitle}'"></span>` : ''} |
| 1593 | 1574 | ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''} |
| 1594 | 1575 | ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''} |
| 1595 | 1576 | </span> |
| 1596 | 1577 | <span> |