aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/tools/RAGTool.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools/RAGTool.ts')
-rw-r--r--src/client/views/nodes/ChatBox/tools/RAGTool.ts22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/client/views/nodes/ChatBox/tools/RAGTool.ts b/src/client/views/nodes/ChatBox/tools/RAGTool.ts
index fe8deae6b..544b9daba 100644
--- a/src/client/views/nodes/ChatBox/tools/RAGTool.ts
+++ b/src/client/views/nodes/ChatBox/tools/RAGTool.ts
@@ -6,7 +6,7 @@ import { Networking } from '../../../../Network';
import { file } from 'jszip';
import { ChatCompletion, ChatCompletionContentPart, ChatCompletionMessageParam } from 'openai/resources';
-export class RAGTool extends BaseTool<{ hypothetical_document_chunk: string }> {
+export class RAGTool extends BaseTool {
constructor(private vectorstore: Vectorstore) {
super(
'rag',
@@ -55,13 +55,15 @@ export class RAGTool extends BaseTool<{ hypothetical_document_chunk: string }> {
5. Detailed Citation Guidelines:
a. Create a unique citation for each distinct piece of information from the chunks that is used to support grounded_text.
- b. ALL TEXT CITATIONS must have direct text in its element content (e.g. <citation ...>DIRECT TEXT HERE</citation>) that is a relevant subset of the original text chunk that is being cited specifically.
- b. Ensure each citation has a unique index number.
- c. Specify the correct type: "text", "image", or "table".
- d. For text chunks, the content of the citation should ALWAYS have the relevant subset of the original text that the grounded_text is based on.
- e. For image/table chunks, leave the citation content empty.
- f. One citation can be used for multiple grounded_text tags if they are based on the same chunk information.
- g. !!!DO NOT OVERCITE - only include citations for information that is directly relevant to the grounded_text.
+ b. ALL TEXT CITATIONS must have direct text in its element content (e.g. <citation ...>DIRECT TEXT HERE</citation>) that is a relevant SUBSET of the original text chunk that is being cited specifically.
+ c. DO NOT paraphrase or summarize the text; use the original text as much as possible.
+ d. DO NOT USE THE FULL TEXT CHUNK as the citation content; only use the relevant subset of the text that the grounded_text is base. AS SHORT AS POSSIBLE WHILE PROVIDING INFORMATION (ONE TO TWO SENTENCES USUALLY)!
+ e. Ensure each citation has a unique index number.
+ f. Specify the correct type: "text", "image", or "table".
+ g. For text chunks, the content of the citation should ALWAYS have the relevant subset of the original text that the grounded_text is based on.
+ h. For image/table chunks, leave the citation content empty.
+ i. One citation can be used for multiple grounded_text tags if they are based on the same chunk information.
+ j. !!!DO NOT OVERCITE - only include citations for information that is directly relevant to the grounded_text.
6. Structural Integrity Checks:
a. Ensure all opening tags have corresponding closing tags.
@@ -113,13 +115,13 @@ export class RAGTool extends BaseTool<{ hypothetical_document_chunk: string }> {
);
}
- async execute(args: { hypothetical_document_chunk: string }): Promise<any> {
+ async execute(args: { hypothetical_document_chunk: string }): Promise {
const relevantChunks = await this.vectorstore.retrieve(args.hypothetical_document_chunk);
const formatted_chunks = await this.getFormattedChunks(relevantChunks);
return formatted_chunks;
}
- async getFormattedChunks(relevantChunks: RAGChunk[]): Promise<ChatCompletionContentPart[]> {
+ async getFormattedChunks(relevantChunks: RAGChunk[]): Promise {
try {
const { formattedChunks } = await Networking.PostToServer('/formatChunks', { relevantChunks });