aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/agentsystem
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-09-30 12:19:22 -0400
committerbobzel <zzzman@gmail.com>2024-09-30 12:19:22 -0400
commit139a3cb0b3b081c270187e9b4ca281d04ca923bf (patch)
treedd952f65f1bb53c29059fa22c2a38db8e0c47c47 /src/client/views/nodes/chatbot/agentsystem
parent04f1047d81bba00f9258543a8171683bce5272bb (diff)
upate AJ assistant from master and fix some lint errors
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem')
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
index 180d05cf3..ccf9caf15 100644
--- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts
+++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
@@ -1,20 +1,19 @@
+import dotenv from 'dotenv';
+import { XMLBuilder, XMLParser } from 'fast-xml-parser';
import OpenAI from 'openai';
-import { Tool, AgentMessage, AssistantMessage, TEXT_TYPE, CHUNK_TYPE, ASSISTANT_ROLE, ProcessingInfo, PROCESSING_TYPE } from '../types/types';
-import { getReactPrompt } from './prompts';
-import { XMLParser, XMLBuilder } from 'fast-xml-parser';
-import { Vectorstore } from '../vectorstore/Vectorstore';
import { ChatCompletionMessageParam } from 'openai/resources';
-import dotenv from 'dotenv';
-import { CalculateTool } from '../tools/CalculateTool';
-import { RAGTool } from '../tools/RAGTool';
-import { DataAnalysisTool } from '../tools/DataAnalysisTool';
-import { WebsiteInfoScraperTool } from '../tools/WebsiteInfoScraperTool';
-import { SearchTool } from '../tools/SearchTool';
-import { NoTool } from '../tools/NoTool';
-import { v4 as uuidv4 } from 'uuid';
import { AnswerParser } from '../response_parsers/AnswerParser';
import { StreamedAnswerParser } from '../response_parsers/StreamedAnswerParser';
+import { CalculateTool } from '../tools/CalculateTool';
import { CreateCSVTool } from '../tools/CreateCSVTool';
+import { DataAnalysisTool } from '../tools/DataAnalysisTool';
+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 { Vectorstore } from '../vectorstore/Vectorstore';
+import { getReactPrompt } from './prompts';
dotenv.config();
@@ -25,7 +24,7 @@ dotenv.config();
export class Agent {
// Private properties
private client: OpenAI;
- private tools: Record<string, Tool<any>>;
+ private tools: Record<string, Tool<any>>; // bcz: need a real type here
private messages: AgentMessage[] = [];
private interMessages: AgentMessage[] = [];
private vectorstore: Vectorstore;
@@ -102,7 +101,7 @@ export class Agent {
ignoreAttributes: false,
attributeNamePrefix: '@_',
textNodeName: '_text',
- isArray: (name, jpath, isLeafNode, isAttribute) => ['query', 'url'].indexOf(name) !== -1,
+ isArray: (name /* , jpath, isLeafNode, isAttribute */) => ['query', 'url'].indexOf(name) !== -1,
});
const builder = new XMLBuilder({ ignoreAttributes: false, attributeNamePrefix: '@_' });
@@ -167,7 +166,7 @@ export class Agent {
if (currentAction) {
try {
// Process the action with its input
- const observation = await this.processAction(currentAction, actionInput.inputs);
+ const observation = (await this.processAction(currentAction, actionInput.inputs)) as any; // bcz: really need a type here
const nextPrompt = [{ type: 'text', text: `<stage number="${i + 1}" role="user"> <observation>` }, ...observation, { type: 'text', text: '</observation></stage>' }];
console.log(observation);
this.interMessages.push({ role: 'user', content: nextPrompt });
@@ -214,7 +213,7 @@ export class Agent {
// Process each chunk of the streamed response
for await (const chunk of stream) {
- let content = chunk.choices[0]?.delta?.content || '';
+ const content = chunk.choices[0]?.delta?.content || '';
fullResponse += content;
// Parse the streamed content character by character
@@ -267,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: any): Promise<any> {
+ private async processAction(action: string, actionInput: unknown): Promise<unknown> {
if (!(action in this.tools)) {
throw new Error(`Unknown action: ${action}`);
}