aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/agentsystem
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-01-21 18:13:39 -0500
committerbobzel <zzzman@gmail.com>2025-01-21 18:13:39 -0500
commitd72977ad8b67f2575cad8aea988fcfa7c04f794a (patch)
tree2b87cab8eade12394cb19f7168e0a9c5e5ff07f3 /src/client/views/nodes/chatbot/agentsystem
parentec0ab50aad9fbb55477476998c6932488b149f45 (diff)
more attempts to cleanup typing, etc in chat box
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem')
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
index 4d3f1e4e7..ee91ccb92 100644
--- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts
+++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
@@ -8,7 +8,7 @@ import { AnswerParser } from '../response_parsers/AnswerParser';
import { StreamedAnswerParser } from '../response_parsers/StreamedAnswerParser';
import { BaseTool } from '../tools/BaseTool';
import { CalculateTool } from '../tools/CalculateTool';
-import { CreateAnyDocumentTool } from '../tools/CreateAnyDocTool';
+import { CreateAnyDocumentTool, supportedDocumentTypes } from '../tools/CreateAnyDocTool';
import { CreateDocTool } from '../tools/CreateDocumentTool';
import { DataAnalysisTool } from '../tools/DataAnalysisTool';
import { NoTool } from '../tools/NoTool';
@@ -55,7 +55,8 @@ export class Agent {
history: () => string,
csvData: () => { filename: string; id: string; text: string }[],
addLinkedUrlDoc: (url: string, id: string) => void,
- addLinkedDoc: (doc_type: string, data: string | undefined, options: DocumentOptions, id: string) => void,
+ addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void,
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
createCSVInDash: (url: string, title: string, id: string, data: string) => void
) {
// Initialize OpenAI client with API key from environment
@@ -134,6 +135,7 @@ export class Agent {
console.log(this.interMessages);
console.log(`Turn ${i}/${maxTurns}`);
+ // eslint-disable-next-line no-await-in-loop
const result = await this.execute(onProcessingUpdate, onAnswerUpdate);
this.interMessages.push({ role: 'assistant', content: result });
@@ -195,6 +197,7 @@ export class Agent {
if (currentAction) {
try {
// Process the action with its input
+ // eslint-disable-next-line no-await-in-loop
const observation = (await this.processAction(currentAction, actionInput.inputs)) as Observation[];
const nextPrompt = [{ type: 'text', text: `<stage number="${i + 1}" role="user"> <observation>` }, ...observation, { type: 'text', text: '</observation></stage>' }] as Observation[];
console.log(observation);
@@ -299,7 +302,7 @@ export class Agent {
* @param response The parsed XML response from the assistant.
* @throws An error if the response does not meet the expected structure.
*/
- private validateAssistantResponse(response: any) {
+ private validateAssistantResponse(response: { stage: { [key: string]: object | string } }) {
if (!response.stage) {
throw new Error('Response does not contain a <stage> element');
}
@@ -342,7 +345,7 @@ export class Agent {
// If 'action_input' is present, validate its structure
if ('action_input' in stage) {
- const actionInput = stage.action_input;
+ const actionInput = stage.action_input as object;
if (!('action_input_description' in actionInput) || typeof actionInput.action_input_description !== 'string') {
throw new Error('action_input must contain an action_input_description string');
@@ -357,7 +360,7 @@ export class Agent {
// If 'answer' is present, validate its structure
if ('answer' in stage) {
- const answer = stage.answer;
+ const answer = stage.answer as object;
// Ensure answer contains at least one of the required elements
if (!('grounded_text' in answer || 'normal_text' in answer)) {