From fb956f918fe16836eb106a5b7b9dc67e36070d20 Mon Sep 17 00:00:00 2001 From: Asim Shrestha Date: Sat, 15 Apr 2023 15:28:01 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=91=20Better=20stoppage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AutonomousAgent.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/AutonomousAgent.ts b/src/components/AutonomousAgent.ts index 030068aace..afb9882ffe 100644 --- a/src/components/AutonomousAgent.ts +++ b/src/components/AutonomousAgent.ts @@ -14,20 +14,20 @@ class AutonomousAgent { completedTasks: string[] = []; modelSettings: ModelSettings; isRunning = true; - sendMessage: (message: Message) => void; + renderMessage: (message: Message) => void; shutdown: () => void; numLoops = 0; constructor( name: string, goal: string, - addMessage: (message: Message) => void, + renderMessage: (message: Message) => void, shutdown: () => void, modelSettings: ModelSettings ) { this.name = name; this.goal = goal; - this.sendMessage = addMessage; + this.renderMessage = renderMessage; this.shutdown = shutdown; this.modelSettings = modelSettings; } @@ -62,8 +62,6 @@ class AutonomousAgent { console.log(this.tasks); if (!this.isRunning) { - this.sendManualShutdownMessage(); - this.shutdown(); return; } @@ -183,7 +181,16 @@ class AutonomousAgent { } stopAgent() { + this.sendManualShutdownMessage(); this.isRunning = false; + this.shutdown(); + return; + } + + sendMessage(message: Message) { + if (this.isRunning) { + this.renderMessage(message); + } } sendGoalMessage() {