From 99e6b144fc1c430158383c9bb7a0df1b513e6d87 Mon Sep 17 00:00:00 2001 From: "Khattab, Sameh" Date: Fri, 30 Aug 2024 16:04:06 +0200 Subject: [PATCH 1/3] feat: allow custom guest message. --- .env | 1 + README.md | 1 + docs/source/developing/copy-huggingchat.md | 1 + src/lib/components/LoginModal.svelte | 17 ++++++++++++----- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.env b/.env index abb84264fdf..df8f92ab0c4 100644 --- a/.env +++ b/.env @@ -131,6 +131,7 @@ PARQUET_EXPORT_SECRET=#DEPRECATED, use ADMIN_API_SECRET instead RATE_LIMIT= # /!\ Legacy definition of messages per minute. Use USAGE_LIMITS.messagesPerMinute instead 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 +PUBLIC_APP_GUEST_MESSAGE=# a message to the guest user. If not set, a default message will be used APP_BASE="" # base path of the app, e.g. /chat, left blank as default PUBLIC_APP_NAME=ChatUI # name used as title throughout the app diff --git a/README.md b/README.md index 2d70651a098..1a6ea76bdb3 100644 --- a/README.md +++ b/README.md @@ -958,6 +958,7 @@ OPENID_CONFIG=`{ }` SERPER_API_KEY= MESSAGES_BEFORE_LOGIN= +PUBLIC_APP_GUEST_MESSAGE=# a message to the guest user. If not set, a default message will be used ``` You can then run `npm run updateLocalEnv` in the root of chat-ui. This will create a `.env.local` file which combines the `chart/env/prod.yaml` and the `.env.SECRET_CONFIG` file. You can then run `npm run dev` to start your local instance of HuggingChat. diff --git a/docs/source/developing/copy-huggingchat.md b/docs/source/developing/copy-huggingchat.md index 1e64c6f2341..a6ad475f63f 100644 --- a/docs/source/developing/copy-huggingchat.md +++ b/docs/source/developing/copy-huggingchat.md @@ -29,6 +29,7 @@ OPENID_CONFIG=`{ }` SERPER_API_KEY= MESSAGES_BEFORE_LOGIN= +PUBLIC_APP_GUEST_MESSAGE= ``` You can then run `npm run updateLocalEnv` in the root of chat-ui. This will create a `.env.local` file which combines the `chart/env/prod.yaml` and the `.env.SECRET_CONFIG` file. You can then run `npm run dev` to start your local instance of HuggingChat. diff --git a/src/lib/components/LoginModal.svelte b/src/lib/components/LoginModal.svelte index 02afdf75ac2..877726ab71d 100644 --- a/src/lib/components/LoginModal.svelte +++ b/src/lib/components/LoginModal.svelte @@ -22,11 +22,18 @@

{envPublic.PUBLIC_APP_DESCRIPTION}

-

- You have reached the guest message limit, Sign In with a free Hugging Face account to continue using HuggingChat. -

+ {#if envPublic.MESSAGES_BEFORE_LOGIN > 0} +

+ {envPublic.PUBLIC_APP_GUEST_MESSAGE || "You have reached the guest message limit, please sign in to continue using the HuggingChat."} +

+ {:else} +

+ You have reached the guest message limit, Sign In with a free Hugging Face account to continue using HuggingChat. +

+ {/if} +
Date: Tue, 10 Sep 2024 16:31:15 +0200 Subject: [PATCH 2/3] remove the messages_before_login condition. --- README.md | 1 - chart/env/prod.yaml | 1 + docs/source/developing/copy-huggingchat.md | 1 - src/lib/components/LoginModal.svelte | 17 ++++------------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1a6ea76bdb3..2d70651a098 100644 --- a/README.md +++ b/README.md @@ -958,7 +958,6 @@ OPENID_CONFIG=`{ }` SERPER_API_KEY= MESSAGES_BEFORE_LOGIN= -PUBLIC_APP_GUEST_MESSAGE=# a message to the guest user. If not set, a default message will be used ``` You can then run `npm run updateLocalEnv` in the root of chat-ui. This will create a `.env.local` file which combines the `chart/env/prod.yaml` and the `.env.SECRET_CONFIG` file. You can then run `npm run dev` to start your local instance of HuggingChat. diff --git a/chart/env/prod.yaml b/chart/env/prod.yaml index 4b87d6decd0..b77423504bd 100644 --- a/chart/env/prod.yaml +++ b/chart/env/prod.yaml @@ -277,6 +277,7 @@ envVars: PUBLIC_APP_COLOR: "yellow" PUBLIC_APP_DESCRIPTION: "Making the community's best AI chat models available to everyone." 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." + PUBLIC_APP_GUEST_MESSAGE: "You have reached the guest message limit, Sign In with a free Hugging Face account to continue using HuggingChat." PUBLIC_APP_DATA_SHARING: 0 PUBLIC_APP_DISCLAIMER: 1 PUBLIC_PLAUSIBLE_SCRIPT_URL: "/js/script.js" diff --git a/docs/source/developing/copy-huggingchat.md b/docs/source/developing/copy-huggingchat.md index a6ad475f63f..1e64c6f2341 100644 --- a/docs/source/developing/copy-huggingchat.md +++ b/docs/source/developing/copy-huggingchat.md @@ -29,7 +29,6 @@ OPENID_CONFIG=`{ }` SERPER_API_KEY= MESSAGES_BEFORE_LOGIN= -PUBLIC_APP_GUEST_MESSAGE= ``` You can then run `npm run updateLocalEnv` in the root of chat-ui. This will create a `.env.local` file which combines the `chart/env/prod.yaml` and the `.env.SECRET_CONFIG` file. You can then run `npm run dev` to start your local instance of HuggingChat. diff --git a/src/lib/components/LoginModal.svelte b/src/lib/components/LoginModal.svelte index 877726ab71d..6a07b2dbfce 100644 --- a/src/lib/components/LoginModal.svelte +++ b/src/lib/components/LoginModal.svelte @@ -22,18 +22,9 @@

{envPublic.PUBLIC_APP_DESCRIPTION}

- {#if envPublic.MESSAGES_BEFORE_LOGIN > 0} -

- {envPublic.PUBLIC_APP_GUEST_MESSAGE || "You have reached the guest message limit, please sign in to continue using the HuggingChat."} -

- {:else} -

- You have reached the guest message limit, Sign In with a free Hugging Face account to continue using HuggingChat. -

- {/if} - +

+ {envPublic.PUBLIC_APP_GUEST_MESSAGE} +

- + \ No newline at end of file From e027f6ecb1ab8c2d9a50a46833a965daf0c6c3f4 Mon Sep 17 00:00:00 2001 From: Nathan Sarrazin Date: Fri, 27 Sep 2024 11:03:00 +0000 Subject: [PATCH 3/3] fix: lint --- src/lib/components/LoginModal.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/LoginModal.svelte b/src/lib/components/LoginModal.svelte index 6a07b2dbfce..a163cfbfa56 100644 --- a/src/lib/components/LoginModal.svelte +++ b/src/lib/components/LoginModal.svelte @@ -60,4 +60,4 @@ {/if} - \ No newline at end of file +