diff --git a/packages/web-ui/components/document-snippets.tsx b/packages/web-ui/components/document-snippets.tsx new file mode 100644 index 0000000..3a3bbb6 --- /dev/null +++ b/packages/web-ui/components/document-snippets.tsx @@ -0,0 +1,42 @@ +'use client'; + +import React, { useState } from 'react'; + +import { ChatMessageSourceType } from '@/types/chat'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/ui/dialog'; + +type DocumentSnippetsProps = { + source: ChatMessageSourceType; +}; + +export function DocumentSnippets({ source }: DocumentSnippetsProps) { + const [open, setOpen] = useState(false); + + return ( + + +

+ {source.filename} +

+
+ + + + This answer was based on the following snippets + + + <> + {source.snippets.map((snippet, index) => { + return

{snippet}

; + })} + +
+
+ ); +} diff --git a/packages/web-ui/components/message.tsx b/packages/web-ui/components/message.tsx index 7d1cd51..018bfea 100644 --- a/packages/web-ui/components/message.tsx +++ b/packages/web-ui/components/message.tsx @@ -7,6 +7,7 @@ import { format } from 'date-fns'; import { ChatMessageType } from '@/types/chat'; import { Avatar, AvatarImage } from '@/components/ui/avatar'; +import { DocumentSnippets } from '@/components/document-snippets'; import Markdown from '@/components/markdown'; export interface MessageProps { @@ -31,11 +32,21 @@ const Message = memo(function Message({ message }: MessageProps) { {message.response ? ( -
- - - - +
+
+ + + + +
+ {message.source && ( +
+

+ Answer based on the following document:  +

+ +
+ )}
) : (