mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Rate-limit Poe message requests
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
secret_state,
|
||||
writeSecret,
|
||||
} from "./secrets.js";
|
||||
import { delay, splitRecursive } from "./utils.js";
|
||||
import { RateLimiter, delay, splitRecursive } from "./utils.js";
|
||||
|
||||
export {
|
||||
is_get_status_poe,
|
||||
@@ -66,6 +66,8 @@ let is_get_status_poe = false;
|
||||
let is_poe_button_press = false;
|
||||
let abortControllerSuggest = null;
|
||||
|
||||
const rateLimiter = new RateLimiter((60 / 10 * 1000)); // 10 requests per minute
|
||||
|
||||
function loadPoeSettings(settings) {
|
||||
if (settings.poe_settings) {
|
||||
Object.assign(poe_settings, settings.poe_settings);
|
||||
@@ -334,6 +336,8 @@ async function sendMessage(prompt, withStreaming, withSuggestions, signal) {
|
||||
signal = new AbortController().signal;
|
||||
}
|
||||
|
||||
await rateLimiter.waitForResolve(signal);
|
||||
|
||||
const body = JSON.stringify({
|
||||
bot: poe_settings.bot,
|
||||
streaming: withStreaming && poe_settings.streaming,
|
||||
|
Reference in New Issue
Block a user