Skip to content

Commit

Permalink
Feature/Hide or Show agent messages for share chatbot (#3140)
Browse files Browse the repository at this point in the history
ability to hide/show agent messages for share chatbot
  • Loading branch information
HenryHengZJ authored Sep 3, 2024
1 parent e691838 commit f464704
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/ui/src/views/chatflows/ShareChatbot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
const [backgroundColor, setBackgroundColor] = useState(chatbotConfig?.backgroundColor ?? defaultConfig.backgroundColor)
const [fontSize, setFontSize] = useState(chatbotConfig?.fontSize ?? defaultConfig.fontSize)
const [poweredByTextColor, setPoweredByTextColor] = useState(chatbotConfig?.poweredByTextColor ?? defaultConfig.poweredByTextColor)
const [showAgentMessages, setShowAgentMessages] = useState(chatbotConfig?.showAgentMessages || (isAgentCanvas ? true : undefined))

const [botMessageBackgroundColor, setBotMessageBackgroundColor] = useState(
chatbotConfig?.botMessage?.backgroundColor ?? defaultConfig.botMessage.backgroundColor
Expand Down Expand Up @@ -139,7 +140,14 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {

if (chatbotConfig?.starterPrompts) obj.starterPrompts = chatbotConfig.starterPrompts

if (isAgentCanvas) obj.showAgentMessages = true
if (isAgentCanvas) {
// if showAgentMessages is undefined, default to true
if (showAgentMessages === undefined || showAgentMessages === null) {
obj.showAgentMessages = true
} else {
obj.showAgentMessages = showAgentMessages
}
}

return obj
}
Expand Down Expand Up @@ -301,6 +309,9 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
case 'generateNewSession':
setGenerateNewSession(value)
break
case 'showAgentMessages':
setShowAgentMessages(value)
break
}
}

Expand Down Expand Up @@ -428,6 +439,7 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
{colorField(backgroundColor, 'backgroundColor', 'Background Color')}
{textField(fontSize, 'fontSize', 'Font Size', 'number')}
{colorField(poweredByTextColor, 'poweredByTextColor', 'PoweredBy TextColor')}
{booleanField(showAgentMessages, 'showAgentMessages', 'Show Agent Reasoning')}

{/*BOT Message*/}
<Typography variant='h4' sx={{ mb: 1, mt: 2 }}>
Expand Down

0 comments on commit f464704

Please sign in to comment.