From 2109a7bda1c9d099df0dddb1615463cd0bcc01f5 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:27:07 +0900 Subject: [PATCH] add prompt role icons to prompt manager --- public/scripts/PromptManager.js | 35 +++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index 492a5a6e9..7668f8702 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -1550,22 +1550,53 @@ class PromptManager { const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE; const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier); const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; + + //add role icons to the right of prompt name + + const hasRole = prompt.role ? true : false; + let roleIcon, roleTitle; + if (hasRole) { + switch (prompt.role) { + case 'system': + roleIcon = 'fa-cog'; + roleTitle = 'Prompt will be sent as System'; + break; + case 'assistant': + roleIcon = 'fa-robot'; + roleTitle = 'Prompt will be sent as Assistant'; + break; + case 'user': + roleIcon = 'fa-user'; + roleTitle = 'Prompt will be sent as User'; + } + + // not sure if this makes sense to include as 'markers' should not be sendable except by System, included in case I'm wrong. + // if it shouldn't be changeable, we should remove that dropdown from editor for Marker prompts. + /* + if (isMarkerPrompt && prompt.role !== 'user' && prompt.role !== 'assistant' && prompt.role !== 'system') { + roleIcon = 'fa-cog'; + roleTitle = 'ST Global Prompt is sent as System by default (but can be changed in Editor)'; + } + */ + } + listItemHtml += `
  • ${isMarkerPrompt ? '' : ''} ${isSystemPrompt ? '' : ''} ${isImportantPrompt ? '' : ''} - ${isUserPrompt ? '' : ''} + ${isUserPrompt ? '' : ''} ${isInjectionPrompt ? '' : ''} ${this.isPromptInspectionAllowed(prompt) ? `${encodedName}` : `${encodedName}`} + ${hasRole ? `` : ''} ${isInjectionPrompt ? `@ ${prompt.injection_depth}` : ''} ${isOverriddenPrompt ? '' : ''} ${detachSpanHtml} - ${editSpanHtml} + ${ editSpanHtml } ${toggleSpanHtml}