aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')
-rw-r--r--src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
index ad2f3e892..fc51ca5f9 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -196,7 +196,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// Add CSV details to linked files
this._linked_csv_files.push({
- filename: CsvCast(newLinkedDoc.data).url.pathname,
+ filename: CsvCast(newLinkedDoc.data)?.url.pathname ?? '',
id: csvId,
text: csvData,
});
@@ -621,6 +621,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
};
getDirectMatchingSegmentStart = (doc: Doc, citationText: string, indexesOfSegments: string[]): number => {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const originalSegments = JSON.parse(StrCast(doc.original_segments!)).map((segment: any, index: number) => ({
index: index.toString(),
text: segment.text,
@@ -720,9 +721,9 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
const x2 = parseFloat(values[2]) * Doc.NativeWidth(doc);
const y2 = parseFloat(values[3]) * Doc.NativeHeight(doc) + foundChunk.startPage * Doc.NativeHeight(doc);
- const annotationKey = Doc.LayoutFieldKey(doc) + '_annotations';
+ const annotationKey = '$' + Doc.LayoutDataKey(doc) + '_annotations';
- const existingDoc = DocListCast(doc[DocData][annotationKey]).find(d => d.citation_id === citation.citation_id);
+ const existingDoc = DocListCast(doc[annotationKey]).find(d => d.citation_id === citation.citation_id);
const highlightDoc = existingDoc ?? this.createImageCitationHighlight(x1, y1, x2, y2, citation, annotationKey, doc);
DocumentManager.Instance.showDocument(highlightDoc, { willZoomCentered: true }, () => {});
@@ -766,7 +767,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
_height: y2 - y1,
backgroundColor: 'rgba(255, 255, 0, 0.5)',
});
- highlight_doc[DocData].citation_id = citation.citation_id;
+ highlight_doc.$citation_id = citation.citation_id;
Doc.AddDocToList(pdfDoc[DocData], annotationKey, highlight_doc);
highlight_doc.annotationOn = pdfDoc;
Doc.SetContainer(highlight_doc, pdfDoc);
@@ -866,7 +867,8 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
return LinkManager.Instance.getAllRelatedLinks(this.Document)
.map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)))
.map(d => DocCast(d?.annotationOn, d))
- .filter(d => d);
+ .filter(d => d)
+ .map(d => d!);
}
/**
@@ -878,6 +880,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
.map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)))
.map(d => DocCast(d?.annotationOn, d))
.filter(d => d)
+ .map(d => d!)
.filter(d => {
console.log(d.ai_doc_id);
return d.ai_doc_id;
@@ -894,15 +897,14 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
LinkManager.Instance.getAllRelatedLinks(this.Document)
.map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)))
.map(d => DocCast(d?.annotationOn, d))
- .filter(d => d)
- .filter(d => d.summary)
+ .filter(d => d?.summary)
.map((doc, index) => {
- if (PDFCast(doc.data)) {
- return `<summary file_name="${PDFCast(doc.data).url.pathname}" applicable_tools=["rag"]>${doc.summary}</summary>`;
- } else if (CsvCast(doc.data)) {
- return `<summary file_name="${CsvCast(doc.data).url.pathname}" applicable_tools=["dataAnalysis"]>${doc.summary}</summary>`;
+ if (PDFCast(doc?.data)) {
+ return `<summary file_name="${PDFCast(doc!.data)!.url.pathname}" applicable_tools=["rag"]>${doc!.summary}</summary>`;
+ } else if (CsvCast(doc?.data)) {
+ return `<summary file_name="${CsvCast(doc!.data)!.url.pathname}" applicable_tools=["dataAnalysis"]>${doc!.summary}</summary>`;
} else {
- return `${index + 1}) ${doc.summary}`;
+ return `${index + 1}) ${doc?.summary}`;
}
})
.join('\n') + '\n'