mirror of
https://github.com/StanGirard/quivr.git
synced 2024-10-26 22:10:26 +03:00
Fix: citation handling in ChatItem component (#2524)
This pull request fixes the citation handling in the ChatItem component. Previously, if the citation did not contain the word "Content:", the component would throw an error. This PR adds a check for the presence of "Content:" in the citation and handles it accordingly.
This commit is contained in:
parent
d2cab9332f
commit
365ac1ab87
@ -11,8 +11,14 @@ export const Citation = ({ citation }: CitationProps): JSX.Element => {
|
|||||||
const [isExpanded, setIsExpanded] = useState<boolean>(false);
|
const [isExpanded, setIsExpanded] = useState<boolean>(false);
|
||||||
|
|
||||||
const contentIndex = citation.indexOf("Content:");
|
const contentIndex = citation.indexOf("Content:");
|
||||||
const cleanedCitation = citation.substring(contentIndex);
|
let cleanedCitation, content;
|
||||||
const [, content] = cleanedCitation.split("Content:");
|
|
||||||
|
if (contentIndex !== -1) {
|
||||||
|
cleanedCitation = citation.substring(contentIndex);
|
||||||
|
[, content] = cleanedCitation.split("Content:");
|
||||||
|
} else {
|
||||||
|
content = citation;
|
||||||
|
}
|
||||||
|
|
||||||
const handleIconClick = (event: React.MouseEvent) => {
|
const handleIconClick = (event: React.MouseEvent) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
Loading…
Reference in New Issue
Block a user