jbilcke-hf HF staff commited on
Commit
ae2cf82
β€’
1 Parent(s): 9cfce0d

make the rate limiter optional

Browse files
Files changed (2) hide show
  1. .env +3 -0
  2. src/app/interface/panel/index.tsx +4 -2
.env CHANGED
@@ -11,6 +11,9 @@ RENDERING_ENGINE="INFERENCE_API"
11
  # - OPENAI
12
  LLM_ENGINE="INFERENCE_API"
13
 
 
 
 
14
  # ------------- PROVIDER AUTH ------------
15
  # You only need to configure the access token(s) for the provider(s) you want to use
16
 
 
11
  # - OPENAI
12
  LLM_ENGINE="INFERENCE_API"
13
 
14
+ # Set to "true" to create artificial delays and smooth out traffic
15
+ NEXT_PUBLIC_ENABLE_RATE_LIMITER="false"
16
+
17
  # ------------- PROVIDER AUTH ------------
18
  # You only need to configure the access token(s) for the provider(s) you want to use
19
 
src/app/interface/panel/index.tsx CHANGED
@@ -59,7 +59,9 @@ export function Panel({
59
 
60
  const timeoutRef = useRef<any>(null)
61
 
62
- const delay = 3000 + (1000 * panel)
 
 
63
 
64
  // since this run in its own loop, we need to use references everywhere
65
  // but perhaps this could be refactored
@@ -105,7 +107,7 @@ export function Panel({
105
  return
106
  }
107
  })
108
- }, 2000 * panel)
109
  }, [prompt, width, height])
110
 
111
 
 
59
 
60
  const timeoutRef = useRef<any>(null)
61
 
62
+ const enableRateLimiter = `${process.env.NEXT_PUBLIC_ENABLE_RATE_LIMITER}` === "true"
63
+
64
+ const delay = enableRateLimiter ? (3000 + (1000 * panel)) : 1000
65
 
66
  // since this run in its own loop, we need to use references everywhere
67
  // but perhaps this could be refactored
 
107
  return
108
  }
109
  })
110
+ }, enableRateLimiter ? 2000 * panel : 0)
111
  }, [prompt, width, height])
112
 
113