From 596502c232ea6b6b88c3c58486e139074ea056ff Mon Sep 17 00:00:00 2001 From: "A.J. Shulman" Date: Tue, 15 Oct 2024 14:18:44 -0400 Subject: tried something for typechecking but way too overcomplicated --- src/client/views/nodes/chatbot/agentsystem/Agent.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/client/views/nodes/chatbot/agentsystem') diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts index ccf9caf15..0747ddd60 100644 --- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts +++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts @@ -11,7 +11,7 @@ import { NoTool } from '../tools/NoTool'; import { RAGTool } from '../tools/RAGTool'; import { SearchTool } from '../tools/SearchTool'; import { WebsiteInfoScraperTool } from '../tools/WebsiteInfoScraperTool'; -import { AgentMessage, AssistantMessage, PROCESSING_TYPE, ProcessingInfo, Tool } from '../types/types'; +import { AgentMessage, AssistantMessage, Observation, PROCESSING_TYPE, ProcessingInfo, Tool } from '../types/types'; import { Vectorstore } from '../vectorstore/Vectorstore'; import { getReactPrompt } from './prompts'; @@ -24,7 +24,6 @@ dotenv.config(); export class Agent { // Private properties private client: OpenAI; - private tools: Record>; // bcz: need a real type here private messages: AgentMessage[] = []; private interMessages: AgentMessage[] = []; private vectorstore: Vectorstore; @@ -36,6 +35,7 @@ export class Agent { private processingNumber: number = 0; private processingInfo: ProcessingInfo[] = []; private streamedAnswerParser: StreamedAnswerParser = new StreamedAnswerParser(); + private tools: Record>; /** * The constructor initializes the agent with the vector store and toolset, and sets up the OpenAI client. @@ -166,7 +166,7 @@ export class Agent { if (currentAction) { try { // Process the action with its input - const observation = (await this.processAction(currentAction, actionInput.inputs)) as any; // bcz: really need a type here + const observation = (await this.processAction(currentAction, actionInput.inputs)) as Observation[]; const nextPrompt = [{ type: 'text', text: ` ` }, ...observation, { type: 'text', text: '' }]; console.log(observation); this.interMessages.push({ role: 'user', content: nextPrompt }); @@ -266,7 +266,7 @@ export class Agent { * @param actionInput The inputs for the action. * @returns The result of the action. */ - private async processAction(action: string, actionInput: unknown): Promise { + private async processAction(action: string, actionInput: Record): Promise { if (!(action in this.tools)) { throw new Error(`Unknown action: ${action}`); } -- cgit v1.2.3-70-g09d2