diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem/Agent.ts')
| -rw-r--r-- | src/client/views/nodes/chatbot/agentsystem/Agent.ts | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts index 43faf5bf4..5af021dbf 100644 --- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts +++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts @@ -20,10 +20,12 @@ import { getReactPrompt } from './prompts'; //import { DictionaryTool } from '../tools/DictionaryTool'; import { ChatCompletionMessageParam } from 'openai/resources'; import { Doc } from '../../../../../fields/Doc'; -import { parsedDoc } from '../chatboxcomponents/ChatBox'; +import { ChatBox, parsedDoc } from '../chatboxcomponents/ChatBox'; import { WebsiteInfoScraperTool } from '../tools/WebsiteInfoScraperTool'; import { Upload } from '../../../../../server/SharedMediaTypes'; import { RAGTool } from '../tools/RAGTool'; +import { AgentDocumentManager } from '../utils/AgentDocumentManager'; +import { CreateLinksTool } from '../tools/CreateLinksTool'; //import { CreateTextDocTool } from '../tools/CreateTextDocumentTool'; dotenv.config(); @@ -47,6 +49,7 @@ export class Agent { private processingInfo: ProcessingInfo[] = []; private streamedAnswerParser: StreamedAnswerParser = new StreamedAnswerParser(); private tools: Record<string, BaseTool<ReadonlyArray<Parameter>>>; + private _docManager: AgentDocumentManager; /** * The constructor initializes the agent with the vector store and toolset, and sets up the OpenAI client. @@ -64,9 +67,9 @@ export class Agent { csvData: () => { filename: string; id: string; text: string }[], addLinkedUrlDoc: (url: string, id: string) => void, createImage: (result: Upload.FileInformation & Upload.InspectionResults, options: DocumentOptions) => void, - addLinkedDoc: (doc: parsedDoc) => Doc | undefined, // eslint-disable-next-line @typescript-eslint/no-unused-vars - createCSVInDash: (url: string, title: string, id: string, data: string) => void + createCSVInDash: (url: string, title: string, id: string, data: string) => void, + chatBox: ChatBox ) { // Initialize OpenAI client with API key from environment this.client = new OpenAI({ apiKey: process.env.OPENAI_KEY, dangerouslyAllowBrowser: true }); @@ -74,6 +77,7 @@ export class Agent { this._history = history; this._summaries = summaries; this._csvData = csvData; + this._docManager = new AgentDocumentManager(chatBox); // Define available tools for the assistant this.tools = { @@ -84,7 +88,8 @@ export class Agent { searchTool: new SearchTool(addLinkedUrlDoc), noTool: new NoTool(), //imageCreationTool: new ImageCreationTool(createImage), - documentMetadata: new DocumentMetadataTool(this), + documentMetadata: new DocumentMetadataTool(this._docManager), + createLinks: new CreateLinksTool(this._docManager), }; } @@ -541,9 +546,9 @@ export class Agent { * * @param chatBox The ChatBox instance to pass to the DocumentMetadataTool */ - public reinitializeDocumentMetadataTool(chatBox: any): void { + public reinitializeDocumentMetadataTool(): void { if (this.tools && this.tools.documentMetadata) { - this.tools.documentMetadata = new DocumentMetadataTool(chatBox); + this.tools.documentMetadata = new DocumentMetadataTool(this._docManager); console.log('Agent: Reinitialized DocumentMetadataTool with ChatBox instance'); } else { console.warn('Agent: Could not reinitialize DocumentMetadataTool - tool not found'); |
