Spaces:
Sleeping
Sleeping
Julian Bilcke
commited on
Commit
·
1cebed6
1
Parent(s):
7892804
stop DDoS Replicate with polling requests
Browse files
src/app/interface/panel/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
import { useEffect, useRef, useState, useTransition } from "react"
|
| 4 |
import { RxReload, RxPencil2 } from "react-icons/rx"
|
| 5 |
|
| 6 |
-
import { RenderedScene } from "@/types"
|
| 7 |
|
| 8 |
import { getRender, newRender } from "@/app/engine/render"
|
| 9 |
import { useStore } from "@/app/store"
|
|
@@ -14,6 +14,9 @@ import { Progress } from "@/app/interface/progress"
|
|
| 14 |
import { EditModal } from "../edit-modal"
|
| 15 |
import { Bubble } from "./bubble"
|
| 16 |
import { getSettings } from "../settings-dialog/getSettings"
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
export function Panel({
|
| 19 |
page,
|
|
@@ -83,9 +86,18 @@ export function Panel({
|
|
| 83 |
const timeoutRef = useRef<any>(null)
|
| 84 |
|
| 85 |
const enableRateLimiter = `${process.env.NEXT_PUBLIC_ENABLE_RATE_LIMITER}` === "true"
|
| 86 |
-
|
| 87 |
|
| 88 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
const startImageGeneration = ({ prompt, width, height, revision }: {
|
| 91 |
prompt: string
|
|
|
|
| 3 |
import { useEffect, useRef, useState, useTransition } from "react"
|
| 4 |
import { RxReload, RxPencil2 } from "react-icons/rx"
|
| 5 |
|
| 6 |
+
import { RenderedScene, RenderingModelVendor } from "@/types"
|
| 7 |
|
| 8 |
import { getRender, newRender } from "@/app/engine/render"
|
| 9 |
import { useStore } from "@/app/store"
|
|
|
|
| 14 |
import { EditModal } from "../edit-modal"
|
| 15 |
import { Bubble } from "./bubble"
|
| 16 |
import { getSettings } from "../settings-dialog/getSettings"
|
| 17 |
+
import { useLocalStorage } from "usehooks-ts"
|
| 18 |
+
import { localStorageKeys } from "../settings-dialog/localStorageKeys"
|
| 19 |
+
import { defaultSettings } from "../settings-dialog/defaultSettings"
|
| 20 |
|
| 21 |
export function Panel({
|
| 22 |
page,
|
|
|
|
| 86 |
const timeoutRef = useRef<any>(null)
|
| 87 |
|
| 88 |
const enableRateLimiter = `${process.env.NEXT_PUBLIC_ENABLE_RATE_LIMITER}` === "true"
|
|
|
|
| 89 |
|
| 90 |
+
const [renderingModelVendor, _setRenderingModelVendor] = useLocalStorage<RenderingModelVendor>(
|
| 91 |
+
localStorageKeys.renderingModelVendor,
|
| 92 |
+
defaultSettings.renderingModelVendor
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
let delay = enableRateLimiter ? (1000 + (500 * panelIndex)) : 1000
|
| 96 |
+
|
| 97 |
+
// Let's be gentle with Replicate or else they will believe they are under attack
|
| 98 |
+
if (renderingModelVendor === "REPLICATE") {
|
| 99 |
+
delay += 8000
|
| 100 |
+
}
|
| 101 |
|
| 102 |
const startImageGeneration = ({ prompt, width, height, revision }: {
|
| 103 |
prompt: string
|
src/app/interface/settings-dialog/index.tsx
CHANGED
|
@@ -71,7 +71,7 @@ export function SettingsDialog() {
|
|
| 71 |
</div>
|
| 72 |
</Button>
|
| 73 |
</DialogTrigger>
|
| 74 |
-
<DialogContent className="sm:max-w-[500px] overflow-y-auto h-[80vh]">
|
| 75 |
<DialogHeader>
|
| 76 |
<DialogDescription className="w-full text-center text-lg font-bold text-stone-800">
|
| 77 |
Custom Settings
|
|
|
|
| 71 |
</div>
|
| 72 |
</Button>
|
| 73 |
</DialogTrigger>
|
| 74 |
+
<DialogContent className="w-full sm:max-w-[500px] md:max-w-[700px] overflow-y-auto h-[100vh] md:h-[80vh]">
|
| 75 |
<DialogHeader>
|
| 76 |
<DialogDescription className="w-full text-center text-lg font-bold text-stone-800">
|
| 77 |
Custom Settings
|