aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools/RAGTool.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-12-18 11:46:14 -0500
committerA.J. Shulman <Shulman.aj@gmail.com>2024-12-18 11:46:14 -0500
commitad1e0cf62187e0f8bbb19b4720b7681585361de9 (patch)
tree673dd63ddc1808e6e89dab5021c2136cbbe843c8 /src/client/views/nodes/chatbot/tools/RAGTool.ts
parent9e447814b551c352709296ae562f1f50480320f5 (diff)
better
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/RAGTool.ts')
-rw-r--r--src/client/views/nodes/chatbot/tools/RAGTool.ts28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/client/views/nodes/chatbot/tools/RAGTool.ts b/src/client/views/nodes/chatbot/tools/RAGTool.ts
index fcd93a07a..1f73986a7 100644
--- a/src/client/views/nodes/chatbot/tools/RAGTool.ts
+++ b/src/client/views/nodes/chatbot/tools/RAGTool.ts
@@ -1,6 +1,6 @@
import { Networking } from '../../../../Network';
import { Observation, RAGChunk } from '../types/types';
-import { ParametersType } from '../types/tool_types';
+import { ParametersType, ToolInfo } from '../types/tool_types';
import { Vectorstore } from '../vectorstore/Vectorstore';
import { BaseTool } from './BaseTool';
@@ -15,14 +15,10 @@ const ragToolParams = [
type RAGToolParamsType = typeof ragToolParams;
-export class RAGTool extends BaseTool<RAGToolParamsType> {
- constructor(private vectorstore: Vectorstore) {
- super(
- 'rag',
- 'Perform a RAG search on user documents',
- ragToolParams,
- `
- When using the RAG tool, the structure must adhere to the format described in the ReAct prompt. Below are additional guidelines specifically for RAG-based responses:
+const ragToolInfo: ToolInfo<RAGToolParamsType> = {
+ name: 'rag',
+ description: 'Performs a RAG (Retrieval-Augmented Generation) search on user documents and returns a set of document chunks (text or images) to provide a grounded response based on user documents.',
+ citationRules: `When using the RAG tool, the structure must adhere to the format described in the ReAct prompt. Below are additional guidelines specifically for RAG-based responses:
1. **Grounded Text Guidelines**:
- Each <grounded_text> tag must correspond to exactly one citation, ensuring a one-to-one relationship.
@@ -56,9 +52,17 @@ export class RAGTool extends BaseTool<RAGToolParamsType> {
<question>How might AI-driven advancements impact healthcare costs?</question>
</follow_up_questions>
</answer>
- `,
- `Performs a RAG (Retrieval-Augmented Generation) search on user documents and returns a set of document chunks (text or images) to provide a grounded response based on user documents.`
- );
+
+ ***NOTE***:
+ - Prefer to cite visual elements (i.e. chart, image, table, etc.) over text, if they both can be used. Only if a visual element is not going to be helpful, then use text. Otherwise, use both!
+ - Use as many citations as possible (even when one would be sufficient), thus keeping text as grounded as possible.
+ - Cite from as many documents as possible and always use MORE, and as granular, citations as possible.`,
+ parameterRules: ragToolParams,
+};
+
+export class RAGTool extends BaseTool<RAGToolParamsType> {
+ constructor(private vectorstore: Vectorstore) {
+ super(ragToolInfo);
}
async execute(args: ParametersType<RAGToolParamsType>): Promise<Observation[]> {