aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2025-07-07 14:39:06 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2025-07-07 14:39:06 -0400
commit9092494778abd55b6aa299fe06b4f70e7c7a767f (patch)
tree28aedb8db51224374e1a31d9557ffd28e1c7e8f9 /src/client/views/nodes/chatbot/tools
parent86c666427ff8b9d516450a150af641570e00f2d2 (diff)
changes (seeing if they work)
Diffstat (limited to 'src/client/views/nodes/chatbot/tools')
-rw-r--r--src/client/views/nodes/chatbot/tools/RAGTool.ts3
-rw-r--r--src/client/views/nodes/chatbot/tools/dynamic/AlignDocumentsTool.ts42
-rw-r--r--src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts33
-rw-r--r--src/client/views/nodes/chatbot/tools/dynamic/CohensDTool.ts52
-rw-r--r--src/client/views/nodes/chatbot/tools/dynamic/InspirationalQuotesTool.ts39
-rw-r--r--src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts33
6 files changed, 162 insertions, 40 deletions
diff --git a/src/client/views/nodes/chatbot/tools/RAGTool.ts b/src/client/views/nodes/chatbot/tools/RAGTool.ts
index af44de520..b0150868e 100644
--- a/src/client/views/nodes/chatbot/tools/RAGTool.ts
+++ b/src/client/views/nodes/chatbot/tools/RAGTool.ts
@@ -62,8 +62,9 @@ const ragToolInfo: ToolInfo<RAGToolParamsType> = {
</answer>
***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!
+ - !!!IMPORTANT: Prefer to cite visual elements (i.e. table, chart, image 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 a visual element!
- Use as many citations as possible (even when one would be sufficient), thus keeping text as grounded as possible.
+ - When using text citations, keep the EXACT TEXT FROM THE CHUNK—WORD FOR WORD—DO NOT EMIT ANYTHING OR ADD ANYTHING. DO NOT PARAPHRASE! DO NOT CITE TEXT CONTENT FROM A TABLE OR IMAGE—INSTEAD CITE THE TABLE OR IMAGE ITSELF!
- Cite from as many documents as possible and always use MORE, and as granular, citations as possible.
- CITATION TEXT MUST BE EXACTLY AS IT APPEARS IN THE CHUNK. DO NOT PARAPHRASE!`,
parameterRules: ragToolParams,
diff --git a/src/client/views/nodes/chatbot/tools/dynamic/AlignDocumentsTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/AlignDocumentsTool.ts
new file mode 100644
index 000000000..53a1dd50d
--- /dev/null
+++ b/src/client/views/nodes/chatbot/tools/dynamic/AlignDocumentsTool.ts
@@ -0,0 +1,42 @@
+import { Observation } from '../../types/types';
+import { ParametersType, ToolInfo } from '../../types/tool_types';
+import { BaseTool } from '../BaseTool';
+
+const alignDocumentsParams = [
+ {
+ name: 'alignmenttype',
+ type: 'string',
+ description: 'The type of alignment: "vertical" or "horizontal".',
+ required: true
+ },
+ {
+ name: 'numberofdocuments',
+ type: 'number',
+ description: 'The number of documents to align.',
+ required: true
+ }
+ ] as const;
+
+ type AlignDocumentsParamsType = typeof alignDocumentsParams;
+
+ const alignDocumentsInfo: ToolInfo<AlignDocumentsParamsType> = {
+ name: 'aligndocumentstool',
+ description: 'Provides generic alignment guidelines for a specified number of documents to be aligned vertically or horizontally.',
+ citationRules: 'No citation needed.',
+ parameterRules: alignDocumentsParams
+ };
+
+ export class AlignDocumentsTool extends BaseTool<AlignDocumentsParamsType> {
+ constructor() {
+ super(alignDocumentsInfo);
+ }
+
+ async execute(args: ParametersType<AlignDocumentsParamsType>): Promise<Observation[]> {
+ const { alignmenttype, numberofdocuments } = args;
+ // Provide generic alignment guidelines
+ const guidelines = Array.from({ length: numberofdocuments }, (_, index) => ({
+ position: alignmenttype === 'vertical' ? `Position ${index} vertically` : `Position ${index} horizontally`
+ }));
+ return [{ type: 'text', text: `Alignment guidelines: ${JSON.stringify(guidelines)}` }];
+ }
+ } \ No newline at end of file
diff --git a/src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts
new file mode 100644
index 000000000..38fed231c
--- /dev/null
+++ b/src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts
@@ -0,0 +1,33 @@
+import { Observation } from '../../types/types';
+import { ParametersType, ToolInfo } from '../../types/tool_types';
+import { BaseTool } from '../BaseTool';
+
+const characterCountParams = [
+ {
+ name: 'text',
+ type: 'string',
+ description: 'The text to count characters in',
+ required: true
+ }
+ ] as const;
+
+ type CharacterCountParamsType = typeof characterCountParams;
+
+ const characterCountInfo: ToolInfo<CharacterCountParamsType> = {
+ name: 'charactercount',
+ description: 'Counts characters in text, excluding spaces',
+ citationRules: 'No citation needed.',
+ parameterRules: characterCountParams
+ };
+
+ export class CharacterCountTool extends BaseTool<CharacterCountParamsType> {
+ constructor() {
+ super(characterCountInfo);
+ }
+
+ async execute(args: ParametersType<CharacterCountParamsType>): Promise<Observation[]> {
+ const { text } = args;
+ const count = text ? text.replace(/\s/g, '').length : 0;
+ return [{ type: 'text', text: `Character count (excluding spaces): ${count}` }];
+ }
+ } \ No newline at end of file
diff --git a/src/client/views/nodes/chatbot/tools/dynamic/CohensDTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/CohensDTool.ts
new file mode 100644
index 000000000..51cadeb6d
--- /dev/null
+++ b/src/client/views/nodes/chatbot/tools/dynamic/CohensDTool.ts
@@ -0,0 +1,52 @@
+import { Observation } from '../../types/types';
+import { ParametersType, ToolInfo } from '../../types/tool_types';
+import { BaseTool } from '../BaseTool';
+
+const cohensDToolParams = [
+ {
+ name: 'meandifference',
+ type: 'number',
+ description: 'The difference between the means of two groups',
+ required: true
+ },
+ {
+ name: 'standarddeviation',
+ type: 'number',
+ description: 'The pooled standard deviation of the two groups',
+ required: true
+ },
+ {
+ name: 'samplesize1',
+ type: 'number',
+ description: 'The sample size of the first group',
+ required: true
+ },
+ {
+ name: 'samplesize2',
+ type: 'number',
+ description: 'The sample size of the second group',
+ required: true
+ }
+ ] as const;
+
+ type CohensDToolParamsType = typeof cohensDToolParams;
+
+ const cohensDToolInfo: ToolInfo<CohensDToolParamsType> = {
+ name: 'cohensdtool',
+ description: 'Calculates Cohen\'s d for effect size and determines statistical significance levels.',
+ citationRules: 'No citation needed.',
+ parameterRules: cohensDToolParams
+ };
+
+ export class CohensDTool extends BaseTool<CohensDToolParamsType> {
+ constructor() {
+ super(cohensDToolInfo);
+ }
+
+ async execute(args: ParametersType<CohensDToolParamsType>): Promise<Observation[]> {
+ const { meandifference, standarddeviation, samplesize1, samplesize2 } = args;
+ const pooledSD = Math.sqrt(((samplesize1 - 1) * Math.pow(standarddeviation, 2) + (samplesize2 - 1) * Math.pow(standarddeviation, 2)) / (samplesize1 + samplesize2 - 2));
+ const cohensD = meandifference / pooledSD;
+ return [{ type: 'text', text: `Cohen's d: ${cohensD.toFixed(3)}` }];
+ }
+ } \ No newline at end of file
diff --git a/src/client/views/nodes/chatbot/tools/dynamic/InspirationalQuotesTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/InspirationalQuotesTool.ts
deleted file mode 100644
index 23bbe1d76..000000000
--- a/src/client/views/nodes/chatbot/tools/dynamic/InspirationalQuotesTool.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Observation } from '../../types/types';
-import { ParametersType, ToolInfo } from '../../types/tool_types';
-import { BaseTool } from '../BaseTool';
-
-const inspirationalQuotesParams = [
- {
- name: 'category',
- type: 'string',
- description: 'The category of inspirational quotes to retrieve',
- required: false
- }
- ] as const;
-
- type InspirationalQuotesParamsType = typeof inspirationalQuotesParams;
-
- const inspirationalQuotesInfo: ToolInfo<InspirationalQuotesParamsType> = {
- name: 'inspirationalquotestool',
- description: 'Provides a random inspirational quote from a predefined list.',
- citationRules: 'No citation needed.',
- parameterRules: inspirationalQuotesParams
- };
-
- export class InspirationalQuotesTool extends BaseTool<InspirationalQuotesParamsType> {
- constructor() {
- super(inspirationalQuotesInfo);
- }
-
- async execute(args: ParametersType<InspirationalQuotesParamsType>): Promise<Observation[]> {
- const quotes = [
- "The only way to do great work is to love what you do. - Steve Jobs",
- "The best time to plant a tree was 20 years ago. The second best time is now. - Chinese Proverb",
- "Your time is limited, so don’t waste it living someone else’s life. - Steve Jobs",
- "Not everything that is faced can be changed, but nothing can be changed until it is faced. - James Baldwin",
- "The purpose of our lives is to be happy. - Dalai Lama"
- ];
- const randomQuote = quotes[Math.floor(Math.random() * quotes.length)];
- return [{ type: 'text', text: randomQuote }];
- }
- } \ No newline at end of file
diff --git a/src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts
new file mode 100644
index 000000000..5e15b4795
--- /dev/null
+++ b/src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts
@@ -0,0 +1,33 @@
+import { Observation } from '../../types/types';
+import { ParametersType, ToolInfo } from '../../types/tool_types';
+import { BaseTool } from '../BaseTool';
+
+const wordCountParams = [
+ {
+ name: 'phrase',
+ type: 'string',
+ description: 'The phrase to count words in',
+ required: true
+ }
+ ] as const;
+
+ type WordCountParamsType = typeof wordCountParams;
+
+ const wordCountInfo: ToolInfo<WordCountParamsType> = {
+ name: 'wordcount',
+ description: 'Counts the number of words in a given phrase',
+ citationRules: 'No citation needed.',
+ parameterRules: wordCountParams
+ };
+
+ export class WordCountTool extends BaseTool<WordCountParamsType> {
+ constructor() {
+ super(wordCountInfo);
+ }
+
+ async execute(args: ParametersType<WordCountParamsType>): Promise<Observation[]> {
+ const { phrase } = args;
+ const wordCount = phrase ? phrase.trim().split(/\s+/).length : 0;
+ return [{ type: 'text', text: `Word count: ${wordCount}` }];
+ }
+ } \ No newline at end of file