diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2024-10-20 15:01:14 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2024-10-20 15:01:14 -0400 |
| commit | cd43a88affe04634045a1fcbce7123c10141ec8c (patch) | |
| tree | ffc5b1f604b6731411c86cd8df1f703b9e8b41f9 /src/client/views/nodes/chatbot/tools | |
| parent | c933ae724c1bf77fa8bd83c3c9e27d0029ef5cb0 (diff) | |
changed to generic addLinkedDoc
Diffstat (limited to 'src/client/views/nodes/chatbot/tools')
12 files changed, 17 insertions, 61 deletions
diff --git a/src/client/views/nodes/chatbot/tools/BaseTool.ts b/src/client/views/nodes/chatbot/tools/BaseTool.ts index b6091af6c..05ca83b26 100644 --- a/src/client/views/nodes/chatbot/tools/BaseTool.ts +++ b/src/client/views/nodes/chatbot/tools/BaseTool.ts @@ -1,5 +1,5 @@ import { Observation } from '../types/types'; -import { Parameter, ParametersType } from './ToolTypes'; +import { Parameter, ParametersType } from '../types/tool_types'; /** * @file BaseTool.ts diff --git a/src/client/views/nodes/chatbot/tools/CalculateTool.ts b/src/client/views/nodes/chatbot/tools/CalculateTool.ts index e96c9a98a..139ede8f0 100644 --- a/src/client/views/nodes/chatbot/tools/CalculateTool.ts +++ b/src/client/views/nodes/chatbot/tools/CalculateTool.ts @@ -1,5 +1,5 @@ import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; import { BaseTool } from './BaseTool'; const calculateToolParams = [ diff --git a/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts b/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts index b321d98ba..2cc513d6c 100644 --- a/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts @@ -1,7 +1,7 @@ import { BaseTool } from './BaseTool'; import { Networking } from '../../../../Network'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; const createCSVToolParams = [ { diff --git a/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts index fa978bdc3..fae78aa49 100644 --- a/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts @@ -2,8 +2,9 @@ import { v4 as uuidv4 } from 'uuid'; import { Networking } from '../../../../Network'; import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; import { DocumentOptions } from '../../../../documents/Documents'; +import { RTFCast, StrCast } from '../../../../../fields/Types'; const createTextDocToolParams = [ { @@ -35,9 +36,9 @@ const createTextDocToolParams = [ type CreateTextDocToolParamsType = typeof createTextDocToolParams; export class CreateTextDocTool extends BaseTool<CreateTextDocToolParamsType> { - private _addLinkedTextDoc: (text_content: string, options: DocumentOptions, id: string) => void; + private _addLinkedDoc: (doc_type: string, data: string, options: DocumentOptions, id: string) => void; - constructor(addLinkedTextDoc: (text_content: string, options: DocumentOptions, id: string) => void) { + constructor(addLinkedDoc: (text_content: string, data: string, options: DocumentOptions, id: string) => void) { super( 'createTextDoc', 'Creates a text document with the provided content and title (and of specified other options if wanted)', @@ -45,12 +46,13 @@ export class CreateTextDocTool extends BaseTool<CreateTextDocToolParamsType> { 'Provide the text content and title (and optionally color) for the document.', 'Creates a text document with the provided content and title (and of specified other options if wanted). Use if the user wants to create a textbox or text document of some sort. Can use after a search or other tool to save information.' ); - this._addLinkedTextDoc = addLinkedTextDoc; + this._addLinkedDoc = addLinkedDoc; } async execute(args: ParametersType<CreateTextDocToolParamsType>): Promise<Observation[]> { try { - this._addLinkedTextDoc(args.text_content, { title: args.title, backgroundColor: args.background_color, text_fontColor: args.font_color }, uuidv4()); + console.log(RTFCast(args.text_content)); + this._addLinkedDoc('text', args.text_content, { title: args.title, backgroundColor: args.background_color, text_fontColor: args.font_color }, uuidv4()); return [{ type: 'text', text: 'Created text document.' }]; } catch (error) { return [{ type: 'text', text: 'Error creating text document, ' + error }]; diff --git a/src/client/views/nodes/chatbot/tools/DataAnalysisTool.ts b/src/client/views/nodes/chatbot/tools/DataAnalysisTool.ts index d9b75219d..97b9ee023 100644 --- a/src/client/views/nodes/chatbot/tools/DataAnalysisTool.ts +++ b/src/client/views/nodes/chatbot/tools/DataAnalysisTool.ts @@ -1,5 +1,5 @@ import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; import { BaseTool } from './BaseTool'; const dataAnalysisToolParams = [ diff --git a/src/client/views/nodes/chatbot/tools/GetDocsTool.ts b/src/client/views/nodes/chatbot/tools/GetDocsTool.ts index 26756522c..4286e7ffe 100644 --- a/src/client/views/nodes/chatbot/tools/GetDocsTool.ts +++ b/src/client/views/nodes/chatbot/tools/GetDocsTool.ts @@ -1,5 +1,5 @@ import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; import { BaseTool } from './BaseTool'; import { DocServer } from '../../../../DocServer'; import { Docs } from '../../../../documents/Documents'; diff --git a/src/client/views/nodes/chatbot/tools/NoTool.ts b/src/client/views/nodes/chatbot/tools/NoTool.ts index a92e3fa23..5d652fd8d 100644 --- a/src/client/views/nodes/chatbot/tools/NoTool.ts +++ b/src/client/views/nodes/chatbot/tools/NoTool.ts @@ -1,6 +1,6 @@ import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; const noToolParams = [] as const; diff --git a/src/client/views/nodes/chatbot/tools/RAGTool.ts b/src/client/views/nodes/chatbot/tools/RAGTool.ts index 482069f36..fcd93a07a 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 './ToolTypes'; +import { ParametersType } from '../types/tool_types'; import { Vectorstore } from '../vectorstore/Vectorstore'; import { BaseTool } from './BaseTool'; diff --git a/src/client/views/nodes/chatbot/tools/SearchTool.ts b/src/client/views/nodes/chatbot/tools/SearchTool.ts index 267dab6ff..03340aae5 100644 --- a/src/client/views/nodes/chatbot/tools/SearchTool.ts +++ b/src/client/views/nodes/chatbot/tools/SearchTool.ts @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid'; import { Networking } from '../../../../Network'; import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; const searchToolParams = [ { diff --git a/src/client/views/nodes/chatbot/tools/ToolTypes.ts b/src/client/views/nodes/chatbot/tools/ToolTypes.ts deleted file mode 100644 index cc29d70f1..000000000 --- a/src/client/views/nodes/chatbot/tools/ToolTypes.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Observation } from '../types/types'; -/** - * The `Parameter` type defines the structure of a parameter configuration. - */ -export type Parameter = { - // The type of the parameter; constrained to the types 'string', 'number', 'boolean', 'string[]', 'number[]' - readonly type: 'string' | 'number' | 'boolean' | 'string[]' | 'number[]'; - // The name of the parameter - readonly name: string; - // A description of the parameter - readonly description: string; - // Indicates whether the parameter is required - readonly required: boolean; - // (Optional) The maximum number of inputs (useful for array types) - readonly max_inputs?: number; -}; - -/** - * A utility type that maps string representations of types to actual TypeScript types. - * This is used to convert the `type` field of a `Parameter` into a concrete TypeScript type. - */ -type TypeMap = { - string: string; - number: number; - boolean: boolean; - 'string[]': string[]; - 'number[]': number[]; -}; - -/** - * The `ParamType` type maps a `Parameter`'s `type` field to the corresponding TypeScript type. - * If the `type` field matches a key in `TypeMap`, it returns the associated type. - * Otherwise, it returns `unknown`. - * @template P - A `Parameter` object. - */ -export type ParamType<P extends Parameter> = P['type'] extends keyof TypeMap ? TypeMap[P['type']] : unknown; - -/** - * The `ParametersType` type transforms an array of `Parameter` objects into an object type - * where each key is the parameter's name, and the value is the corresponding TypeScript type. - * This is used to define the types of the arguments passed to the `execute` method of a tool. - * @template P - An array of `Parameter` objects. - */ -export type ParametersType<P extends ReadonlyArray<Parameter>> = { - [K in P[number] as K['name']]: ParamType<K>; -}; diff --git a/src/client/views/nodes/chatbot/tools/WebsiteInfoScraperTool.ts b/src/client/views/nodes/chatbot/tools/WebsiteInfoScraperTool.ts index f2e3863a6..ce659e344 100644 --- a/src/client/views/nodes/chatbot/tools/WebsiteInfoScraperTool.ts +++ b/src/client/views/nodes/chatbot/tools/WebsiteInfoScraperTool.ts @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid'; import { Networking } from '../../../../Network'; import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; const websiteInfoScraperToolParams = [ { diff --git a/src/client/views/nodes/chatbot/tools/WikipediaTool.ts b/src/client/views/nodes/chatbot/tools/WikipediaTool.ts index 966ca7708..f2dbf3cfd 100644 --- a/src/client/views/nodes/chatbot/tools/WikipediaTool.ts +++ b/src/client/views/nodes/chatbot/tools/WikipediaTool.ts @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid'; import { Networking } from '../../../../Network'; import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType } from '../types/tool_types'; const wikipediaToolParams = [ { |
