Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds custom_js #708

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
# The CSS file can be served from the public directory or via an external link.
# custom_css = "/public/test.css"

# Specify a Javascript file that can be used to customize the user interface.
# The Javascript file can be served from the public directory.
# custom_js = "/public/test.js"

# Specify a custom font url.
# custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"

Expand Down Expand Up @@ -198,6 +202,7 @@ class UISettings(DataClassJsonMixin):
theme: Optional[Theme] = None
# Optional custom CSS file that allows you to customize the UI
custom_css: Optional[str] = None
custom_js: Optional[str] = None
custom_font: Optional[str] = None


Expand All @@ -221,9 +226,9 @@ class CodeSettings:
on_message: Optional[Callable[[str], Any]] = None
author_rename: Optional[Callable[[str], str]] = None
on_settings_update: Optional[Callable[[Dict[str, Any]], Any]] = None
set_chat_profiles: Optional[
Callable[[Optional["User"]], List["ChatProfile"]]
] = None
set_chat_profiles: Optional[Callable[[Optional["User"]], List["ChatProfile"]]] = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the auto-linter, FYI.

None
)


@dataclass()
Expand Down
3 changes: 3 additions & 0 deletions backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def get_html_template():
f"""<link rel="stylesheet" type="text/css" href="{config.ui.custom_css}">"""
)

if config.ui.custom_js:
js += f"""<script src="{config.ui.custom_js}"></script>"""

font = None
if config.ui.custom_font:
font = f"""<link rel="stylesheet" href="{config.ui.custom_font}">"""
Expand Down
Loading