Bug fix for validator execution before the bot initialization

This commit is contained in:
Ayush Maniar 2025-03-15 22:35:23 -07:00
parent 1195a194d5
commit 7c96cca59c

View file

@ -126,16 +126,25 @@ class CookingCraftingTaskValidator {
this.data = data;
this.agent = agent;
}
validate() {
const result = checkItemPresence(this.data, this.agent);
let score = 0;
if (result.success) {
score = 1;
validate(has_initiated) {
if (has_initiated) {
const result = checkItemPresence(this.data, this.agent);
let score = 0;
if (result.success) {
score = 1;
}
return {
"valid": result.success,
"score": score,
};
}
else {
return {
"valid": false,
"score": 0
};
}
return {
"valid": result.success,
"score": score,
};
}
}
@ -188,6 +197,7 @@ export class Task {
this.name = this.agent.name;
this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
this.agent_initialized = false;
}
getAgentGoal() {
@ -239,7 +249,7 @@ export class Task {
isDone() {
let res = null;
if (this.validator)
res = this.validator.validate();
res = this.validator.validate(this.agent_initialized);
if (res && res.valid) {
return {"message": 'Task successful', "score": res.score};
}
@ -311,6 +321,8 @@ export class Task {
await new Promise((resolve) => setTimeout(resolve, 500));
}
this.agent_initialized = true;
if (this.initiator) {
await this.initiator.init();
}