Skip to content

Commit

Permalink
🛑 Better stoppage
Browse files Browse the repository at this point in the history
  • Loading branch information
asim-shrestha committed Apr 15, 2023
1 parent 27ef2f2 commit fb956f9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/AutonomousAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -62,8 +62,6 @@ class AutonomousAgent {
console.log(this.tasks);

if (!this.isRunning) {
this.sendManualShutdownMessage();
this.shutdown();
return;
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit fb956f9

Please sign in to comment.