@@ -55,18 +59,115 @@ const ConversationBubble = forwardRef<
ref={ref}
className={`flex flex-wrap self-start ${className} group flex-col dark:text-bright-gray`}
>
-
-
+
+
+ }
/>
- }
- />
-
+
Sources
+
+
+ {Array.from({ length: 4 }).map((_, index) => (
+
+
+
+
+
+
+
+ ))}
+
+
+ ) : (
+
+
+
+
+ {sources?.slice(0, 3)?.map((source, index) => (
+
+
setActiveTooltip(index)}
+ onMouseOut={() => setActiveTooltip(null)}
+ onClick={() =>
+ source.source && source.source !== 'local'
+ ? window.open(
+ source.source,
+ '_blank',
+ 'noopener, noreferrer',
+ )
+ : setOpenSource(openSource === index ? null : index)
+ }
+ >
+
+ {source.title}
+
+
+ {activeTooltip === index && (
+
setActiveTooltip(index)}
+ onMouseOut={() => setActiveTooltip(null)}
+ >
+
+ {source.text}
+
+
+ )}
+
+ ))}
+ {(sources?.length ?? 0) > 3 && (
+
setIsSidebarOpen(true)}
+ >
+
{`View ${
+ sources?.length ? sources.length - 3 : 0
+ } more`}
+
+ )}
+
+
+
+ )}
+
+
{message}
- {DisableSourceFE ||
- type === 'ERROR' ||
- !sources ||
- sources.length === 0 ? null : (
- <>
-
-
-
Sources:
-
- {sources?.map((source, index) => (
-
- source.source !== 'local'
- ? window.open(
- source.source,
- '_blank',
- 'noopener, noreferrer',
- )
- : setOpenSource(openSource === index ? null : index)
- }
- >
-
- {index + 1}. {source.title.substring(0, 45)}
-
-
- ))}
-
-
- >
- )}
-
+
-
- {sources && openSource !== null && sources[openSource] && (
-
-
- Source: {sources[openSource].title}
-
-
-
-
- {sources[openSource].text}
-
-
-
+ {sources && (
+
{
+ setIsSidebarOpen(state);
+ }}
+ children={}
+ />
)}
);
@@ -312,4 +366,31 @@ const ConversationBubble = forwardRef<
return bubble;
});
+type AllSourcesProps = {
+ sources: { title: string; text: string; source: string }[];
+};
+
+function AllSources(sources: AllSourcesProps) {
+ return (
+
+
+
{`${sources.sources.length} Sources`}
+
+
+
+ {sources.sources.map((source, index) => (
+
+
+ {`${index + 1}. ${source.title}`}
+
+
+ {source.text}
+
+
+ ))}
+
+
+ );
+}
+
export default ConversationBubble;
diff --git a/frontend/src/index.css b/frontend/src/index.css
index cf90289f..3b78e9de 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -433,3 +433,11 @@ template {
.bottom-safe {
bottom: env(safe-area-inset-bottom, 0);
}
+
+.ellipsis-text {
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-line-clamp: 4;
+ -webkit-box-orient: vertical;
+ text-overflow: ellipsis;
+}