diff --git a/chart/values.yaml b/chart/values.yaml index b52a461..248cadb 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -84,6 +84,17 @@ ui: appSettings: hf_model_name: *model-name hf_model_instruction: "You are a helpful AI assistant. Please response appropriately." + # Use local system fonts by default to avoid GDPR issues + # with Gradio's defaults fonts which require fetching from + # the Google fonts API. To restore default Gradio theme + # fonts, remove the font and font-mono keys. + theme_params: + font: + - sans-serif + - Arial + font_mono: + - sans-serif + - Arial # Container image config image: repository: ghcr.io/stackhpc/azimuth-llm-ui-base diff --git a/chart/web-app/config.py b/chart/web-app/config.py index 6f7efe4..9e45ae5 100644 --- a/chart/web-app/config.py +++ b/chart/web-app/config.py @@ -2,7 +2,7 @@ from pydantic import Field, HttpUrl from pydantic_settings import BaseSettings, SettingsConfigDict -from typing import Optional +from typing import Optional, Union, List def get_k8s_namespace(): @@ -52,7 +52,7 @@ class AppSettings(BaseSettings): # Variables explicitly passed to gradio.theme.Default() # For example: # {"primary_hue": "red"} - theme_params: dict[str, str] = Field(default_factory=dict) + theme_params: dict[str, Union[str, List[str]]] = Field(default_factory=dict) # Overrides for theme.body_background_fill property theme_background_colour: Optional[str] = Field(default=None) # Custom page title colour override passed as CSS diff --git a/chart/web-app/example-settings.yml b/chart/web-app/example-settings.yml index 463cf66..2d9a6b7 100644 --- a/chart/web-app/example-settings.yml +++ b/chart/web-app/example-settings.yml @@ -1,13 +1,19 @@ -backend_url: http://128.232.226.230 -hf_model_name: tiiuae/falcon-7b +backend_url: http://localhost:8081 +hf_model_name: ise-uiuc/Magicoder-S-DS-6.7B -hf_model_instruction: You are a helpful and cheerful AI assistant. Please respond appropriately. +# model_instruction: You are a helpful and cheerful AI assistant. Please respond appropriately. + +page_description: "[Privacy statement](https://google.com)" # UI theming tweaks # theme_title_colour: white # theme_background_colour: "#00376c" -# theme_params: -# primary_hue: blue +theme_params: + # primary_hue: blue + font: + - sans-serif + font_mono: + - sans-serif # llm_max_tokens: # llm_temperature: diff --git a/images/ui-base/Dockerfile b/images/ui-base/Dockerfile index 689301c..222de27 100644 --- a/images/ui-base/Dockerfile +++ b/images/ui-base/Dockerfile @@ -3,4 +3,7 @@ FROM python:3.11-slim ENV GRADIO_SERVER_PORT=7680 COPY requirements.txt requirements.txt -RUN pip install --no-cache-dir -r requirements.txt \ No newline at end of file +RUN pip install --no-cache-dir -r requirements.txt + +COPY purge-google-fonts.sh purge-google-fonts.sh +RUN bash purge-google-fonts.sh diff --git a/images/ui-base/purge-google-fonts.sh b/images/ui-base/purge-google-fonts.sh new file mode 100644 index 0000000..bc6cc96 --- /dev/null +++ b/images/ui-base/purge-google-fonts.sh @@ -0,0 +1,16 @@ + +SOURCE_CODE_PATH=/usr/local/lib/python3.11/site-packages/gradio/ + +# Strip out preconnect directives from HTML tags +find $SOURCE_CODE_PATH -name "*.html" -type f -exec sed -i s!'rel="preconnect"'!!g {} \; + +# Replace hard-coded links in HTML templates with something harmless but identifiable +declare -a LINKS=( + "https://fonts.gstatic.com" + "https://fonts.googleapis.com" + "https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/.*/iframeResizer.contentWindow.min.js" +) +REPLACEMENT="external-url-removed-for-gdpr-compliance" +for item in "${LINKS[@]}"; do + find $SOURCE_CODE_PATH -name "*.html" -type f -exec sed -i s!$item!$REPLACEMENT!g {} \; +done