Skip to content

Commit

Permalink
feat(Assistant): Show sources when present
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Oct 23, 2024
1 parent 9f68cc1 commit 5c820ae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/assistant/AssistantProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ const AssistantProvider = ({ children }) => {
}))
}, 250)
}
} else {
}

if (res.object === 'delta') {
setAssistantState(v => ({
...v,
message: v.message + res.content,
Expand Down
20 changes: 12 additions & 8 deletions src/assistant/Conversations/ChatAssistantItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ import Icon from 'cozy-ui/transpiled/react/Icon'

import AssistantIcon from 'assets/images/icon-assistant.png'

import Sources from './Sources/Sources'
import ChatItem from './ChatItem'

const ChatAssistantItem = ({ className, label, ...props }) => {
const ChatAssistantItem = ({ className, label, sources, ...props }) => {
const { t } = useI18n()
// need memo to avoid rendering it everytime
const icon = useMemo(() => <Icon icon={AssistantIcon} size={32} />, [])

return (
<ChatItem
{...props}
className={className}
icon={icon}
name={t('assistant.name')}
label={label}
/>
<>
<ChatItem
{...props}
className={className}
icon={icon}
name={t('assistant.name')}
label={label}
/>
{sources?.length > 0 && <Sources sources={sources} />}
</>
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/assistant/Conversations/ChatConversation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const ChatConversation = ({ conversation, myself }) => {
key={conversation._id + '--' + idx}
className="u-mt-1-half"
label={message.content}
sources={message.sources}
/>
)
}
Expand All @@ -56,6 +57,7 @@ const ChatConversation = ({ conversation, myself }) => {
key={conversation._id + '--' + idx}
className="u-mt-1-half"
label={message.content}
sources={message.sources}
/>
)
})}
Expand Down

0 comments on commit 5c820ae

Please sign in to comment.