@2501-ai/cli
Version:
[](https://www.npmjs.com/package/@2501-ai/cli) [](https://www.2501.ai/research/full-humaneval-benchmark) [![Lic
28 lines (27 loc) • 902 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLooping = void 0;
const crypto_1 = require("crypto");
const REPETITION_THRESHOLD = 15;
const actionHashes = new Map();
function hashAction(action) {
return (0, crypto_1.createHash)('sha256')
.update(JSON.stringify(Object.assign(Object.assign({}, action), { id: '' })))
.digest('hex');
}
function isLooping(actions) {
let isLooping = false;
for (const action of actions) {
const actionHash = hashAction(action);
if (actionHashes.has(actionHash)) {
const count = actionHashes.get(actionHash);
actionHashes.set(actionHash, count + 1);
isLooping || (isLooping = count + 1 >= REPETITION_THRESHOLD);
}
else {
actionHashes.set(actionHash, 1);
}
}
return isLooping;
}
exports.isLooping = isLooping;