-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display document sources (#188)
- Loading branch information
1 parent
e6d9b39
commit 708c29f
Showing
2 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogTrigger asChild> | ||
<p className="cursor-pointer text-sm text-gray-500 underline"> | ||
{source.filename} | ||
</p> | ||
</DialogTrigger> | ||
<DialogContent className="overflow-y-scroll sm:max-h-[650px] sm:max-w-[900px]"> | ||
<DialogHeader> | ||
<DialogTitle> | ||
This answer was based on the following snippets | ||
</DialogTitle> | ||
</DialogHeader> | ||
<> | ||
{source.snippets.map((snippet, index) => { | ||
return <p key={index}>{snippet}</p>; | ||
})} | ||
</> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters