Skip to content

Commit

Permalink
Add consent popup env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
cornzz committed Sep 19, 2024
1 parent dcb246f commit c002338
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ spec:
env:
- name: APP_PATH
value: /compress
- name: CONSENT_POPUP
value: "true"
- name: LLM_LIST
value: meta-llama/Meta-Llama-3.1-70B-Instruct, CohereForAI/c4ai-command-r-plus
# - name: HF_HUB_CACHE
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
() => {
if (!document.cookie.includes('session=')) {
window.alert("By using this app, you agree that submitted data is logged (only when clicking the feedback buttons) and may be used for research purposes.\n\nPlease refrain from submitting any personal or confidential information.");
if (CONSENT_POPUP) window.alert("By using this app, you agree that submitted data is logged (only when clicking the feedback buttons) and may be used for research purposes.\n\nPlease refrain from submitting any personal or confidential information.");
const date = new Date(+new Date() + 10 * 365 * 24 * 60 * 60 * 1000);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
document.cookie = `session=${Array(32).fill().map(() => chars.charAt(Math.floor(Math.random() * chars.length))).join('')}; expires=${date.toUTCString()}; path=/`;
Expand Down
6 changes: 5 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
load_dotenv()

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
CONSENT_POPUP = os.getenv("CONSENT_POPUP", "false")
FLAG_DIRECTORY = os.path.join(BASE_DIR, "../flagged")
FLAG_PASSWORD = os.getenv("FLAG_PASSWORD")
LOG_DIRECTORY = os.path.join(FLAG_DIRECTORY, "logs")
Expand Down Expand Up @@ -215,7 +216,10 @@ def run_demo(
title="LLMLingua-2 Demo",
css=os.path.join(BASE_DIR, "app.css"),
js=os.path.join(BASE_DIR, "app.js"),
head='<link rel="icon" href="favicon.ico">',
head=f"""
<link rel=\"icon\" href=\"favicon.ico\">
<script>const CONSENT_POPUP = {CONSENT_POPUP}</script>
""",
analytics_enabled=False,
theme=gr.themes.Default(font="Source Sans 3", font_mono="IBM Plex Mono"),
) as demo:
Expand Down

0 comments on commit c002338

Please sign in to comment.