Spaces:
Running
on
Inf2
Running
on
Inf2
feat: show login modal if login is required for creating assistants & tools (#1640)
Browse files- chart/env/prod.yaml +1 -1
- src/lib/components/chat/ChatWindow.svelte +4 -12
- src/lib/stores/loginModal.ts +3 -0
- src/routes/+layout.svelte +10 -0
- src/routes/assistants/+page.svelte +18 -6
- src/routes/tools/+page.svelte +18 -6
chart/env/prod.yaml
CHANGED
|
@@ -417,7 +417,7 @@ envVars:
|
|
| 417 |
PUBLIC_APP_COLOR: "yellow"
|
| 418 |
PUBLIC_APP_DESCRIPTION: "Making the community's best AI chat models available to everyone."
|
| 419 |
PUBLIC_APP_DISCLAIMER_MESSAGE: "Disclaimer: AI is an area of active research with known problems such as biased generation and misinformation. Do not use this application for high-stakes decisions or advice."
|
| 420 |
-
PUBLIC_APP_GUEST_MESSAGE: "
|
| 421 |
PUBLIC_APP_DATA_SHARING: 0
|
| 422 |
PUBLIC_APP_DISCLAIMER: 1
|
| 423 |
PUBLIC_PLAUSIBLE_SCRIPT_URL: "/js/script.js"
|
|
|
|
| 417 |
PUBLIC_APP_COLOR: "yellow"
|
| 418 |
PUBLIC_APP_DESCRIPTION: "Making the community's best AI chat models available to everyone."
|
| 419 |
PUBLIC_APP_DISCLAIMER_MESSAGE: "Disclaimer: AI is an area of active research with known problems such as biased generation and misinformation. Do not use this application for high-stakes decisions or advice."
|
| 420 |
+
PUBLIC_APP_GUEST_MESSAGE: "Sign in with a free Hugging Face account to continue using HuggingChat."
|
| 421 |
PUBLIC_APP_DATA_SHARING: 0
|
| 422 |
PUBLIC_APP_DISCLAIMER: 1
|
| 423 |
PUBLIC_PLAUSIBLE_SCRIPT_URL: "/js/script.js"
|
src/lib/components/chat/ChatWindow.svelte
CHANGED
|
@@ -12,7 +12,6 @@
|
|
| 12 |
import ChatInput from "./ChatInput.svelte";
|
| 13 |
import StopGeneratingBtn from "../StopGeneratingBtn.svelte";
|
| 14 |
import type { Model } from "$lib/types/Model";
|
| 15 |
-
import LoginModal from "../LoginModal.svelte";
|
| 16 |
import { page } from "$app/stores";
|
| 17 |
import FileDropzone from "./FileDropzone.svelte";
|
| 18 |
import RetryBtn from "../RetryBtn.svelte";
|
|
@@ -36,6 +35,7 @@
|
|
| 36 |
import { fly } from "svelte/transition";
|
| 37 |
import { cubicInOut } from "svelte/easing";
|
| 38 |
import type { ToolFront } from "$lib/types/Tool";
|
|
|
|
| 39 |
|
| 40 |
export let messages: Message[] = [];
|
| 41 |
export let loading = false;
|
|
@@ -50,7 +50,6 @@
|
|
| 50 |
|
| 51 |
$: isReadOnly = !models.some((model) => model.id === currentModel.id);
|
| 52 |
|
| 53 |
-
let loginModalOpen = false;
|
| 54 |
let message: string;
|
| 55 |
let timeout: ReturnType<typeof setTimeout>;
|
| 56 |
let isSharedRecently = false;
|
|
@@ -250,13 +249,6 @@
|
|
| 250 |
/>
|
| 251 |
|
| 252 |
<div class="relative min-h-0 min-w-0">
|
| 253 |
-
{#if loginModalOpen}
|
| 254 |
-
<LoginModal
|
| 255 |
-
on:close={() => {
|
| 256 |
-
loginModalOpen = false;
|
| 257 |
-
}}
|
| 258 |
-
/>
|
| 259 |
-
{/if}
|
| 260 |
<div
|
| 261 |
class="scrollbar-custom h-full overflow-y-auto"
|
| 262 |
use:snapScrollToBottom={messages.length ? [...messages] : false}
|
|
@@ -330,7 +322,7 @@
|
|
| 330 |
on:message={(ev) => {
|
| 331 |
if ($page.data.loginRequired) {
|
| 332 |
ev.preventDefault();
|
| 333 |
-
loginModalOpen = true;
|
| 334 |
} else {
|
| 335 |
dispatch("message", ev.detail);
|
| 336 |
}
|
|
@@ -343,7 +335,7 @@
|
|
| 343 |
on:message={(ev) => {
|
| 344 |
if ($page.data.loginRequired) {
|
| 345 |
ev.preventDefault();
|
| 346 |
-
loginModalOpen = true;
|
| 347 |
} else {
|
| 348 |
dispatch("message", ev.detail);
|
| 349 |
}
|
|
@@ -442,7 +434,7 @@
|
|
| 442 |
on:beforeinput={(ev) => {
|
| 443 |
if ($page.data.loginRequired) {
|
| 444 |
ev.preventDefault();
|
| 445 |
-
loginModalOpen = true;
|
| 446 |
}
|
| 447 |
}}
|
| 448 |
on:paste={onPaste}
|
|
|
|
| 12 |
import ChatInput from "./ChatInput.svelte";
|
| 13 |
import StopGeneratingBtn from "../StopGeneratingBtn.svelte";
|
| 14 |
import type { Model } from "$lib/types/Model";
|
|
|
|
| 15 |
import { page } from "$app/stores";
|
| 16 |
import FileDropzone from "./FileDropzone.svelte";
|
| 17 |
import RetryBtn from "../RetryBtn.svelte";
|
|
|
|
| 35 |
import { fly } from "svelte/transition";
|
| 36 |
import { cubicInOut } from "svelte/easing";
|
| 37 |
import type { ToolFront } from "$lib/types/Tool";
|
| 38 |
+
import { loginModalOpen } from "$lib/stores/loginModal";
|
| 39 |
|
| 40 |
export let messages: Message[] = [];
|
| 41 |
export let loading = false;
|
|
|
|
| 50 |
|
| 51 |
$: isReadOnly = !models.some((model) => model.id === currentModel.id);
|
| 52 |
|
|
|
|
| 53 |
let message: string;
|
| 54 |
let timeout: ReturnType<typeof setTimeout>;
|
| 55 |
let isSharedRecently = false;
|
|
|
|
| 249 |
/>
|
| 250 |
|
| 251 |
<div class="relative min-h-0 min-w-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
<div
|
| 253 |
class="scrollbar-custom h-full overflow-y-auto"
|
| 254 |
use:snapScrollToBottom={messages.length ? [...messages] : false}
|
|
|
|
| 322 |
on:message={(ev) => {
|
| 323 |
if ($page.data.loginRequired) {
|
| 324 |
ev.preventDefault();
|
| 325 |
+
$loginModalOpen = true;
|
| 326 |
} else {
|
| 327 |
dispatch("message", ev.detail);
|
| 328 |
}
|
|
|
|
| 335 |
on:message={(ev) => {
|
| 336 |
if ($page.data.loginRequired) {
|
| 337 |
ev.preventDefault();
|
| 338 |
+
$loginModalOpen = true;
|
| 339 |
} else {
|
| 340 |
dispatch("message", ev.detail);
|
| 341 |
}
|
|
|
|
| 434 |
on:beforeinput={(ev) => {
|
| 435 |
if ($page.data.loginRequired) {
|
| 436 |
ev.preventDefault();
|
| 437 |
+
$loginModalOpen = true;
|
| 438 |
}
|
| 439 |
}}
|
| 440 |
on:paste={onPaste}
|
src/lib/stores/loginModal.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { writable } from "svelte/store";
|
| 2 |
+
|
| 3 |
+
export const loginModalOpen = writable(false);
|
src/routes/+layout.svelte
CHANGED
|
@@ -19,6 +19,8 @@
|
|
| 19 |
import titleUpdate from "$lib/stores/titleUpdate";
|
| 20 |
import DisclaimerModal from "$lib/components/DisclaimerModal.svelte";
|
| 21 |
import ExpandNavigation from "$lib/components/ExpandNavigation.svelte";
|
|
|
|
|
|
|
| 22 |
|
| 23 |
export let data;
|
| 24 |
|
|
@@ -215,6 +217,14 @@
|
|
| 215 |
<DisclaimerModal on:close={() => ($settings.ethicsModalAccepted = true)} />
|
| 216 |
{/if}
|
| 217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
<ExpandNavigation
|
| 219 |
isCollapsed={isNavCollapsed}
|
| 220 |
on:click={() => (isNavCollapsed = !isNavCollapsed)}
|
|
|
|
| 19 |
import titleUpdate from "$lib/stores/titleUpdate";
|
| 20 |
import DisclaimerModal from "$lib/components/DisclaimerModal.svelte";
|
| 21 |
import ExpandNavigation from "$lib/components/ExpandNavigation.svelte";
|
| 22 |
+
import { loginModalOpen } from "$lib/stores/loginModal";
|
| 23 |
+
import LoginModal from "$lib/components/LoginModal.svelte";
|
| 24 |
|
| 25 |
export let data;
|
| 26 |
|
|
|
|
| 217 |
<DisclaimerModal on:close={() => ($settings.ethicsModalAccepted = true)} />
|
| 218 |
{/if}
|
| 219 |
|
| 220 |
+
{#if $loginModalOpen}
|
| 221 |
+
<LoginModal
|
| 222 |
+
on:close={() => {
|
| 223 |
+
$loginModalOpen = false;
|
| 224 |
+
}}
|
| 225 |
+
/>
|
| 226 |
+
{/if}
|
| 227 |
+
|
| 228 |
<ExpandNavigation
|
| 229 |
isCollapsed={isNavCollapsed}
|
| 230 |
on:click={() => (isNavCollapsed = !isNavCollapsed)}
|
src/routes/assistants/+page.svelte
CHANGED
|
@@ -26,6 +26,7 @@
|
|
| 26 |
import { isDesktop } from "$lib/utils/isDesktop";
|
| 27 |
import { SortKey } from "$lib/types/Assistant";
|
| 28 |
import { ReviewStatus } from "$lib/types/Review";
|
|
|
|
| 29 |
|
| 30 |
export let data: PageData;
|
| 31 |
|
|
@@ -152,12 +153,23 @@
|
|
| 152 |
Show unfeatured assistants
|
| 153 |
</label>
|
| 154 |
{/if}
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
</div>
|
| 162 |
|
| 163 |
<div class="mt-7 flex flex-wrap items-center gap-x-2 gap-y-3 text-sm">
|
|
|
|
| 26 |
import { isDesktop } from "$lib/utils/isDesktop";
|
| 27 |
import { SortKey } from "$lib/types/Assistant";
|
| 28 |
import { ReviewStatus } from "$lib/types/Review";
|
| 29 |
+
import { loginModalOpen } from "$lib/stores/loginModal";
|
| 30 |
|
| 31 |
export let data: PageData;
|
| 32 |
|
|
|
|
| 153 |
Show unfeatured assistants
|
| 154 |
</label>
|
| 155 |
{/if}
|
| 156 |
+
{#if $page.data.loginRequired && !data.user}
|
| 157 |
+
<button
|
| 158 |
+
on:click={() => {
|
| 159 |
+
$loginModalOpen = true;
|
| 160 |
+
}}
|
| 161 |
+
class="flex items-center gap-1 whitespace-nowrap rounded-lg border bg-white py-1 pl-1.5 pr-2.5 shadow-sm hover:bg-gray-50 hover:shadow-none dark:border-gray-600 dark:bg-gray-700 dark:hover:bg-gray-700"
|
| 162 |
+
>
|
| 163 |
+
<CarbonAdd />Create new assistant
|
| 164 |
+
</button>
|
| 165 |
+
{:else}
|
| 166 |
+
<a
|
| 167 |
+
href={`${base}/settings/assistants/new`}
|
| 168 |
+
class="flex items-center gap-1 whitespace-nowrap rounded-lg border bg-white py-1 pl-1.5 pr-2.5 shadow-sm hover:bg-gray-50 hover:shadow-none dark:border-gray-600 dark:bg-gray-700 dark:hover:bg-gray-700"
|
| 169 |
+
>
|
| 170 |
+
<CarbonAdd />Create new assistant
|
| 171 |
+
</a>
|
| 172 |
+
{/if}
|
| 173 |
</div>
|
| 174 |
|
| 175 |
<div class="mt-7 flex flex-wrap items-center gap-x-2 gap-y-3 text-sm">
|
src/routes/tools/+page.svelte
CHANGED
|
@@ -21,6 +21,7 @@
|
|
| 21 |
import ToolLogo from "$lib/components/ToolLogo.svelte";
|
| 22 |
import { ReviewStatus } from "$lib/types/Review";
|
| 23 |
import { useSettingsStore } from "$lib/stores/settings";
|
|
|
|
| 24 |
|
| 25 |
export let data: PageData;
|
| 26 |
|
|
@@ -142,12 +143,23 @@
|
|
| 142 |
Show unfeatured tools
|
| 143 |
</label>
|
| 144 |
{/if}
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
</div>
|
| 152 |
|
| 153 |
<div class="mb-4 mt-7 flex flex-wrap items-center gap-x-2 gap-y-3 text-sm">
|
|
|
|
| 21 |
import ToolLogo from "$lib/components/ToolLogo.svelte";
|
| 22 |
import { ReviewStatus } from "$lib/types/Review";
|
| 23 |
import { useSettingsStore } from "$lib/stores/settings";
|
| 24 |
+
import { loginModalOpen } from "$lib/stores/loginModal";
|
| 25 |
|
| 26 |
export let data: PageData;
|
| 27 |
|
|
|
|
| 143 |
Show unfeatured tools
|
| 144 |
</label>
|
| 145 |
{/if}
|
| 146 |
+
{#if $page.data.loginRequired && !data.user}
|
| 147 |
+
<button
|
| 148 |
+
on:click={() => {
|
| 149 |
+
$loginModalOpen = true;
|
| 150 |
+
}}
|
| 151 |
+
class="flex items-center gap-1 whitespace-nowrap rounded-lg border bg-white py-1 pl-1.5 pr-2.5 shadow-sm hover:bg-gray-50 hover:shadow-none dark:border-gray-600 dark:bg-gray-700 dark:hover:bg-gray-700"
|
| 152 |
+
>
|
| 153 |
+
<CarbonAdd />Create new tool
|
| 154 |
+
</button>
|
| 155 |
+
{:else}
|
| 156 |
+
<a
|
| 157 |
+
href={`${base}/tools/new`}
|
| 158 |
+
class="flex items-center gap-1 whitespace-nowrap rounded-lg border bg-white py-1 pl-1.5 pr-2.5 shadow-sm hover:bg-gray-50 hover:shadow-none dark:border-gray-600 dark:bg-gray-700 dark:hover:bg-gray-700"
|
| 159 |
+
>
|
| 160 |
+
<CarbonAdd />Create new tool
|
| 161 |
+
</a>
|
| 162 |
+
{/if}
|
| 163 |
</div>
|
| 164 |
|
| 165 |
<div class="mb-4 mt-7 flex flex-wrap items-center gap-x-2 gap-y-3 text-sm">
|