@convo-lang/convo-lang
Version:
The language of AI
29 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setGlobalConversationLockMaxConcurrent = exports.getGlobalConversationLock = void 0;
const common_1 = require("@iyio/common");
let lock = globalThis?.window ? new common_1.Lock(5) : null;
/**
* Returns a lock that is used to limit the max number of open requests to LLMs.
* Default value is 5 in the browser and the limit is disabled outside of the browser.
*/
const getGlobalConversationLock = () => lock;
exports.getGlobalConversationLock = getGlobalConversationLock;
/**
* Sets the max global number of conversation completion requests that can be set at the same
* time. Set the value to null will disable the global lock.
* @warning Calling this function while Conversations are actively sending messages can result in the
* current max count being exceeded while the new lock count takes affect.
*/
const setGlobalConversationLockMaxConcurrent = (maxConcurrent) => {
if (!maxConcurrent || maxConcurrent <= 0) {
lock = null;
return;
}
if (lock && lock.maxConcurrent === maxConcurrent) {
return;
}
lock = new common_1.Lock(maxConcurrent);
};
exports.setGlobalConversationLockMaxConcurrent = setGlobalConversationLockMaxConcurrent;
//# sourceMappingURL=convo-lang-lock.js.map