Add "unset" value for PM prompt role, refactor icons display
| @@ -28,6 +28,10 @@ | |||
| 28 | color: var(--white50a); | 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 | #completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible { | 35 | #completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible { |
| 32 | display: none; | 36 | display: none; |
| 33 | } | 37 | } |
| @@ -6115,6 +6115,7 @@ | |||
| 6115 | </label> | 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" data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</div> |
| 6117 | <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role"> | 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 | <option data-i18n="System" value="system">System</option> | 6119 | <option data-i18n="System" value="system">System</option> |
| 6119 | <option data-i18n="User" value="user">User</option> | 6120 | <option data-i18n="User" value="user">User</option> |
| 6120 | <option data-i18n="AI Assistant" value="assistant">AI Assistant</option> | 6121 | <option data-i18n="AI Assistant" value="assistant">AI Assistant</option> |
| @@ -1208,7 +1208,7 @@ class PromptManager { | |||
| 1208 | const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block'); | 1208 | const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block'); |
| 1209 | 1209 | ||
| 1210 | nameField.value = prompt.name ?? ''; | 1210 | nameField.value = prompt.name ?? ''; |
| 1211 | roleField.value = prompt.role ?? 'system'; | 1211 | roleField.value = prompt.role ?? ''; |
| 1212 | promptField.value = prompt.content ?? ''; | 1212 | promptField.value = prompt.content ?? ''; |
| 1213 | promptField.disabled = prompt.marker ?? false; | 1213 | promptField.disabled = prompt.marker ?? false; |
| 1214 | injectionPositionField.value = prompt.injection_position ?? INJECTION_POSITION.RELATIVE; | 1214 | injectionPositionField.value = prompt.injection_position ?? INJECTION_POSITION.RELATIVE; |
| @@ -1543,6 +1543,7 @@ class PromptManager { | |||
| 1543 | } | 1543 | } |
| 1544 | 1544 | ||
| 1545 | const encodedName = escapeHtml(prompt.name); | 1545 | const encodedName = escapeHtml(prompt.name); |
| 1546 | const isRolePrompt = !!prompt.role; | ||
| 1546 | const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE; | 1547 | const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE; |
| 1547 | const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides; | 1548 | const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides; |
| 1548 | const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides; | 1549 | const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides; |
| @@ -1552,36 +1553,16 @@ class PromptManager { | |||
| 1552 | const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; | 1553 | const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; |
| 1553 | 1554 | ||
| 1554 | //add role icons to the right of prompt name | 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 | listItemHtml += ` | 1564 | listItemHtml += ` |
| 1584 | <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${prompt.identifier}"> | 1565 | <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}"> |
| 1585 | <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}"> | 1566 | <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}"> |
| 1586 | ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''} | 1567 | ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''} |
| 1587 | ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''} | 1568 | ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''} |
| @@ -1589,14 +1570,14 @@ class PromptManager { | |||
| 1589 | ${isUserPrompt ? '<span class="fa-fw fa-solid fa-user" title="Preset Prompt"></span>' : ''} | 1570 | ${isUserPrompt ? '<span class="fa-fw fa-solid fa-user" title="Preset Prompt"></span>' : ''} |
| 1590 | ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''} | 1571 | ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''} |
| 1591 | ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`} | 1572 | ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`} |
| 1592 | ${hasRole ? `<span class='fa-solid ${roleIcon}' title='${roleTitle}'></span>` : ''} | 1573 | ${isRolePrompt ? `<span data-role="${escapeHtml(prompt.role)}" class="fa-xs fa-solid ${roleIcon}" title="${roleTitle}"></span>` : ''} |
| 1593 | ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${prompt.injection_depth}</small>` : ''} | 1574 | ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''} |
| 1594 | ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''} | 1575 | ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''} |
| 1595 | </span> | 1576 | </span> |
| 1596 | <span> | 1577 | <span> |
| 1597 | <span class="prompt_manager_prompt_controls"> | 1578 | <span class="prompt_manager_prompt_controls"> |
| 1598 | ${detachSpanHtml} | 1579 | ${detachSpanHtml} |
| 1599 | ${ editSpanHtml } | 1580 | ${editSpanHtml} |
| 1600 | ${toggleSpanHtml} | 1581 | ${toggleSpanHtml} |
| 1601 | </span> | 1582 | </span> |
| 1602 | </span> | 1583 | </span> |