Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Hide or Show agent messages for share chatbot #3140

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading