victor HF staff commited on
Commit
0a662b7
1 Parent(s): 6183fe7

Revert "Option to disable login on first N messages (#352)"

Browse files

This reverts commit 6183fe78b431f3b8319fa5b271ed017d2bdf47b4.

.env CHANGED
@@ -60,10 +60,10 @@ PUBLIC_SHARE_PREFIX=#https://hf.co/chat
60
  PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable
61
  PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID=#UA-XXXXXXXX-X / Leave empty to disable
62
  PUBLIC_ANNOUNCEMENT_BANNERS=`[
63
- {
64
- "title": "Llama v2 is live on HuggingChat! 🦙",
65
- "linkTitle": "Announcement",
66
- "linkHref": "https://huggingface.co/blog/llama2"
67
  }
68
  ]`
69
 
@@ -72,7 +72,6 @@ PARQUET_EXPORT_HF_TOKEN=
72
  PARQUET_EXPORT_SECRET=
73
 
74
  RATE_LIMIT= # requests per minute
75
- MESSAGES_BEFORE_LOGIN=# how many messages a user can send in a conversation before having to login. set to 0 to force login right away
76
 
77
  PUBLIC_APP_NAME=ChatUI # name used as title throughout the app
78
  PUBLIC_APP_ASSETS=chatui # used to find logos & favicons in static/$PUBLIC_APP_ASSETS
 
60
  PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable
61
  PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID=#UA-XXXXXXXX-X / Leave empty to disable
62
  PUBLIC_ANNOUNCEMENT_BANNERS=`[
63
+ {
64
+ "title": "Chat UI is now open sourced on GitHub",
65
+ "linkTitle": "GitHub repo",
66
+ "linkHref": "https://github.com/huggingface/chat-ui"
67
  }
68
  ]`
69
 
 
72
  PARQUET_EXPORT_SECRET=
73
 
74
  RATE_LIMIT= # requests per minute
 
75
 
76
  PUBLIC_APP_NAME=ChatUI # name used as title throughout the app
77
  PUBLIC_APP_ASSETS=chatui # used to find logos & favicons in static/$PUBLIC_APP_ASSETS
src/hooks.server.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { COOKIE_NAME, MESSAGES_BEFORE_LOGIN } from "$env/static/private";
2
  import type { Handle } from "@sveltejs/kit";
3
  import {
4
  PUBLIC_GOOGLE_ANALYTICS_ID,
@@ -64,7 +64,7 @@ export const handle: Handle = async ({ event, resolve }) => {
64
  !event.url.pathname.startsWith(`${base}/admin`) &&
65
  !["GET", "OPTIONS", "HEAD"].includes(event.request.method)
66
  ) {
67
- if (!user && requiresUser && !((parseInt(MESSAGES_BEFORE_LOGIN) || 0) > 0)) {
68
  return errorResponse(401, ERROR_MESSAGES.authOnly);
69
  }
70
 
 
1
+ import { COOKIE_NAME } from "$env/static/private";
2
  import type { Handle } from "@sveltejs/kit";
3
  import {
4
  PUBLIC_GOOGLE_ANALYTICS_ID,
 
64
  !event.url.pathname.startsWith(`${base}/admin`) &&
65
  !["GET", "OPTIONS", "HEAD"].includes(event.request.method)
66
  ) {
67
+ if (!user && requiresUser) {
68
  return errorResponse(401, ERROR_MESSAGES.authOnly);
69
  }
70
 
src/lib/components/LoginModal.svelte CHANGED
@@ -25,14 +25,11 @@
25
  v{PUBLIC_VERSION}
26
  </div>
27
  </h2>
28
- <p
29
- class="px-4 text-lg font-semibold leading-snug text-gray-800 sm:px-12"
30
- style="text-wrap: balance;"
31
- >
32
- Please Sign in with Hugging Face to continue
33
  </p>
34
  <p class="text-base text-gray-800">
35
- Disclaimer: AI is an area of active research with known problems such as biased generation and
36
  misinformation. Do not use this application for high-stakes decisions or advice.
37
  </p>
38
  {#if PUBLIC_APP_DATA_SHARING}
@@ -57,6 +54,7 @@
57
  with <LogoHuggingFaceBorderless classNames="text-xl mr-1 ml-1.5" /> Hugging Face
58
  {/if}
59
  </button>
 
60
  {:else}
61
  <input type="hidden" name="ethicsModalAccepted" value={true} />
62
  {#each Object.entries(settings) as [key, val]}
 
25
  v{PUBLIC_VERSION}
26
  </div>
27
  </h2>
28
+ <p class="px-4 text-lg font-semibold leading-snug text-gray-800 sm:px-12">
29
+ This application is for demonstration purposes only.
 
 
 
30
  </p>
31
  <p class="text-base text-gray-800">
32
+ AI is an area of active research with known problems such as biased generation and
33
  misinformation. Do not use this application for high-stakes decisions or advice.
34
  </p>
35
  {#if PUBLIC_APP_DATA_SHARING}
 
54
  with <LogoHuggingFaceBorderless classNames="text-xl mr-1 ml-1.5" /> Hugging Face
55
  {/if}
56
  </button>
57
+ <p class="mt-2 px-2 text-sm text-gray-500">to start chatting right away</p>
58
  {:else}
59
  <input type="hidden" name="ethicsModalAccepted" value={true} />
60
  {#each Object.entries(settings) as [key, val]}
src/routes/+layout.server.ts CHANGED
@@ -6,7 +6,7 @@ import { UrlDependency } from "$lib/types/UrlDependency";
6
  import { defaultModel, models, oldModels, validateModel } from "$lib/server/models";
7
  import { authCondition, requiresUser } from "$lib/server/auth";
8
  import { DEFAULT_SETTINGS } from "$lib/types/Settings";
9
- import { SERPAPI_KEY, SERPER_API_KEY, MESSAGES_BEFORE_LOGIN } from "$env/static/private";
10
 
11
  export const load: LayoutServerLoad = async ({ locals, depends, url }) => {
12
  const { conversations } = collections;
@@ -82,6 +82,5 @@ export const load: LayoutServerLoad = async ({ locals, depends, url }) => {
82
  email: locals.user.email,
83
  },
84
  requiresLogin: requiresUser,
85
- messagesBeforeLogin: parseInt(MESSAGES_BEFORE_LOGIN ?? 0),
86
  };
87
  };
 
6
  import { defaultModel, models, oldModels, validateModel } from "$lib/server/models";
7
  import { authCondition, requiresUser } from "$lib/server/auth";
8
  import { DEFAULT_SETTINGS } from "$lib/types/Settings";
9
+ import { SERPAPI_KEY, SERPER_API_KEY } from "$env/static/private";
10
 
11
  export const load: LayoutServerLoad = async ({ locals, depends, url }) => {
12
  const { conversations } = collections;
 
82
  email: locals.user.email,
83
  },
84
  requiresLogin: requiresUser,
 
85
  };
86
  };
src/routes/+layout.svelte CHANGED
@@ -178,7 +178,7 @@
178
  {#if isSettingsOpen}
179
  <SettingsModal on:close={() => (isSettingsOpen = false)} settings={data.settings} />
180
  {/if}
181
- {#if requiresLogin && data.messagesBeforeLogin === 0}
182
  <LoginModal settings={data.settings} />
183
  {/if}
184
  <slot />
 
178
  {#if isSettingsOpen}
179
  <SettingsModal on:close={() => (isSettingsOpen = false)} settings={data.settings} />
180
  {/if}
181
+ {#if requiresLogin}
182
  <LoginModal settings={data.settings} />
183
  {/if}
184
  <slot />
src/routes/conversation/[id]/+page.svelte CHANGED
@@ -16,7 +16,6 @@
16
  import type { WebSearchMessage } from "$lib/types/WebSearch";
17
  import type { Message } from "$lib/types/Message";
18
  import { browser } from "$app/environment";
19
- import { PUBLIC_APP_DISCLAIMER } from "$env/static/public";
20
 
21
  export let data;
22
 
@@ -280,8 +279,4 @@
280
  models={data.models}
281
  currentModel={findCurrentModel([...data.models, ...data.oldModels], data.model)}
282
  settings={data.settings}
283
- loginRequired={(data.requiresLogin
284
- ? !data.user
285
- : !data.settings.ethicsModalAcceptedAt && !!PUBLIC_APP_DISCLAIMER) &&
286
- data.messages.length > data.messagesBeforeLogin}
287
  />
 
16
  import type { WebSearchMessage } from "$lib/types/WebSearch";
17
  import type { Message } from "$lib/types/Message";
18
  import { browser } from "$app/environment";
 
19
 
20
  export let data;
21
 
 
279
  models={data.models}
280
  currentModel={findCurrentModel([...data.models, ...data.oldModels], data.model)}
281
  settings={data.settings}
 
 
 
 
282
  />