aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-10-20 15:01:14 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-10-20 15:01:14 -0400
commitcd43a88affe04634045a1fcbce7123c10141ec8c (patch)
treeffc5b1f604b6731411c86cd8df1f703b9e8b41f9
parentc933ae724c1bf77fa8bd83c3c9e27d0029ef5cb0 (diff)
changed to generic addLinkedDoc
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts7
-rw-r--r--src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx14
-rw-r--r--src/client/views/nodes/chatbot/tools/BaseTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/CalculateTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateCSVTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts12
-rw-r--r--src/client/views/nodes/chatbot/tools/DataAnalysisTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/GetDocsTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/NoTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/RAGTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/SearchTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/WebsiteInfoScraperTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/WikipediaTool.ts2
-rw-r--r--src/client/views/nodes/chatbot/types/tool_types.ts (renamed from src/client/views/nodes/chatbot/tools/ToolTypes.ts)2
14 files changed, 33 insertions, 22 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
index df307bc21..9253175d5 100644
--- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts
+++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
@@ -15,8 +15,9 @@ import { AgentMessage, AssistantMessage, Observation, PROCESSING_TYPE, Processin
import { Vectorstore } from '../vectorstore/Vectorstore';
import { getReactPrompt } from './prompts';
import { BaseTool } from '../tools/BaseTool';
-import { Parameter, ParametersType } from '../tools/ToolTypes';
+import { Parameter, ParametersType } from '../types/tool_types';
import { CreateTextDocTool } from '../tools/CreateTextDocumentTool';
+import { DocumentOptions } from '../../../../documents/Documents';
dotenv.config();
@@ -55,7 +56,7 @@ export class Agent {
history: () => string,
csvData: () => { filename: string; id: string; text: string }[],
addLinkedUrlDoc: (url: string, id: string) => void,
- addLinkedTextDoc: (text_content: string, options: {}, id: string) => void,
+ addLinkedDoc: (doc_type: string, data: string, options: DocumentOptions, id: string) => void,
createCSVInDash: (url: string, title: string, id: string, data: string) => void
) {
// Initialize OpenAI client with API key from environment
@@ -74,7 +75,7 @@ export class Agent {
searchTool: new SearchTool(addLinkedUrlDoc),
createCSV: new CreateCSVTool(createCSVInDash),
noTool: new NoTool(),
- createTextDoc: new CreateTextDocTool(addLinkedTextDoc),
+ createTextDoc: new CreateTextDocTool(addLinkedDoc),
};
}
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
index 118d20153..98f242ebf 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -33,6 +33,7 @@ import { Vectorstore } from '../vectorstore/Vectorstore';
import './ChatBox.scss';
import MessageComponentBox from './MessageComponent';
import { ProgressBar } from './ProgressBar';
+import { RichTextField } from '../../../../../fields/RichTextField';
dotenv.config();
@@ -89,7 +90,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
this.vectorstore_id = StrCast(this.dataDoc.vectorstore_id);
}
this.vectorstore = new Vectorstore(this.vectorstore_id, this.retrieveDocIds);
- this.agent = new Agent(this.vectorstore, this.retrieveSummaries, this.retrieveFormattedHistory, this.retrieveCSVData, this.addLinkedUrlDoc, this.createTextDocInDash, this.createCSVInDash);
+ this.agent = new Agent(this.vectorstore, this.retrieveSummaries, this.retrieveFormattedHistory, this.retrieveCSVData, this.addLinkedUrlDoc, this.createDocInDash, this.createCSVInDash);
this.messagesRef = React.createRef<HTMLDivElement>();
// Reaction to update dataDoc when chat history changes
@@ -418,8 +419,15 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
* @param id The unique ID for the document.
*/
@action
- createTextDocInDash = async (text_content: string, options: DocumentOptions, id: string) => {
- const doc = DocCast(Docs.Create.TextDocument(text_content, options));
+ createDocInDash = async (doc_type: string, data: string, options: DocumentOptions, id: string) => {
+ let doc;
+ switch (doc_type) {
+ case 'text':
+ doc = DocCast(Docs.Create.TextDocument(data, options));
+ default:
+ doc = DocCast(Docs.Create.TextDocument(data, options));
+ }
+
const linkDoc = Docs.Create.LinkDocument(this.Document, doc);
LinkManager.Instance.addLink(linkDoc);
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/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 = [
{
diff --git a/src/client/views/nodes/chatbot/tools/ToolTypes.ts b/src/client/views/nodes/chatbot/types/tool_types.ts
index cc29d70f1..c1150534d 100644
--- a/src/client/views/nodes/chatbot/tools/ToolTypes.ts
+++ b/src/client/views/nodes/chatbot/types/tool_types.ts
@@ -1,4 +1,4 @@
-import { Observation } from '../types/types';
+import { Observation } from './types';
/**
* The `Parameter` type defines the structure of a parameter configuration.
*/