Spaces:
Runtime error
Runtime error
test hf signin
Browse files- README.md +2 -0
- components/main/index.tsx +27 -11
- utils/checker/prompt.ts +1 -1
README.md
CHANGED
@@ -7,6 +7,8 @@ sdk: docker
|
|
7 |
pinned: true
|
8 |
app_port: 3002
|
9 |
license: mit
|
|
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
7 |
pinned: true
|
8 |
app_port: 3002
|
9 |
license: mit
|
10 |
+
|
11 |
+
hf_oauth: true
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
components/main/index.tsx
CHANGED
@@ -19,11 +19,13 @@ const categories = [
|
|
19 |
{
|
20 |
key: "my-own",
|
21 |
label: "My generations",
|
|
|
22 |
icon: <HiHeart className="text-2xl" />,
|
23 |
},
|
24 |
];
|
25 |
|
26 |
export const Main = () => {
|
|
|
27 |
const { list_styles, style, setStyle, loading } = useInputGeneration();
|
28 |
const [category, setCategory] = useState<string>("community");
|
29 |
const [advancedSettings, setAdvancedSettings] = useState<boolean>(false);
|
@@ -34,17 +36,31 @@ export const Main = () => {
|
|
34 |
<div className="flex flex-col lg:flex-row items-center justify-between w-full">
|
35 |
<InputGeneration />
|
36 |
<div className="items-center justify-center lg:justify-end gap-5 w-full mt-6 lg:mt-0 hidden lg:flex">
|
37 |
-
{categories.map(({ key, label, icon }) =>
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
</div>
|
49 |
</div>
|
50 |
</div>
|
|
|
19 |
{
|
20 |
key: "my-own",
|
21 |
label: "My generations",
|
22 |
+
isLogged: true,
|
23 |
icon: <HiHeart className="text-2xl" />,
|
24 |
},
|
25 |
];
|
26 |
|
27 |
export const Main = () => {
|
28 |
+
const user = false;
|
29 |
const { list_styles, style, setStyle, loading } = useInputGeneration();
|
30 |
const [category, setCategory] = useState<string>("community");
|
31 |
const [advancedSettings, setAdvancedSettings] = useState<boolean>(false);
|
|
|
36 |
<div className="flex flex-col lg:flex-row items-center justify-between w-full">
|
37 |
<InputGeneration />
|
38 |
<div className="items-center justify-center lg:justify-end gap-5 w-full mt-6 lg:mt-0 hidden lg:flex">
|
39 |
+
{categories.map(({ key, label, icon, isLogged }) =>
|
40 |
+
isLogged && !user ? (
|
41 |
+
<Button
|
42 |
+
key={key}
|
43 |
+
theme="white"
|
44 |
+
onClick={() =>
|
45 |
+
console.log(
|
46 |
+
`https://huggingface.co/oauth/authorize?redirect_uri=${process.env.REDIRECT_URI}&scope=openid%20profile&client_id=${process.env.CLIENT_ID}&state=${process.env.STATE}`
|
47 |
+
)
|
48 |
+
}
|
49 |
+
>
|
50 |
+
Sign in with Hugging Face
|
51 |
+
</Button>
|
52 |
+
) : (
|
53 |
+
<Button
|
54 |
+
key={key}
|
55 |
+
disabled={loading}
|
56 |
+
theme={key !== category ? "white" : "primary"}
|
57 |
+
onClick={() => setCategory(key)}
|
58 |
+
>
|
59 |
+
{icon}
|
60 |
+
{label}
|
61 |
+
</Button>
|
62 |
+
)
|
63 |
+
)}
|
64 |
</div>
|
65 |
</div>
|
66 |
</div>
|
utils/checker/prompt.ts
CHANGED
@@ -8,7 +8,7 @@ export const isTextNSFW = async (prompt: string, headers: any) => {
|
|
8 |
headers: headers,
|
9 |
})
|
10 |
const res = await request.clone().json().catch(() => ({}));
|
11 |
-
const isNSFW = res?.[0]?.find((item: { label: string, score: number }) => item?.label === "NSFW")?.score > 0.
|
12 |
resolve(isNSFW)
|
13 |
})
|
14 |
}
|
|
|
8 |
headers: headers,
|
9 |
})
|
10 |
const res = await request.clone().json().catch(() => ({}));
|
11 |
+
const isNSFW = res?.[0]?.find((item: { label: string, score: number }) => item?.label === "NSFW")?.score > 0.73 ?? false
|
12 |
resolve(isNSFW)
|
13 |
})
|
14 |
}
|