Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Quansight_ragna /ragna /deploy /_ui /app.py
| import panel as pn | |
| import param | |
| from ragna.deploy._engine import Engine | |
| from . import js | |
| from . import styles as ui | |
| from .main_page import MainPage | |
| pn.extension( | |
| loading_spinner="dots", | |
| loading_color=ui.MAIN_COLOR, | |
| layout_compatibility="error", | |
| ) | |
| pn.config.browser_info = True | |
| class App(param.Parameterized): | |
| def __init__(self, engine: Engine): | |
| super().__init__() | |
| # Apply the design modifiers to the panel components | |
| # It returns all the CSS files of the modifiers | |
| self.css_filepaths = ui.apply_design_modifiers() | |
| self._engine = engine | |
| def get_template(self): | |
| # A bit hacky, but works. | |
| # we need to preload the css files to avoid a flash of unstyled content, especially when switching between chats. | |
| # This is achieved by adding <link ref="preload" ...> tags in the head of the document. | |
| # But none of the panel templates allow to add custom link tags in the head. | |
| # the only way I found is to take advantage of the raw_css parameter, which allows to add custom css in the head. | |
| preload_css = "\n".join( | |
| [ | |
| f"""<link rel="preload" href="{css_fp}" as="style" />""" | |
| for css_fp in self.css_filepaths | |
| ] | |
| ) | |
| preload_css = f""" | |
| </style> | |
| {preload_css} | |
| <style type="text/css"> | |
| """ | |
| template = pn.template.FastListTemplate( | |
| # We need to set a title to have it appearing on the browser's tab | |
| # but it means we need to hide it from the header bar | |
| title="Ragna", | |
| accent_base_color=ui.MAIN_COLOR, | |
| theme_toggle=False, | |
| collapsed_sidebar=True, | |
| raw_css=[ui.CSS_VARS, preload_css], | |
| favicon="imgs/ragna_logo.svg", | |
| css_files=["https://rsms.me/inter/inter.css", "css/main.css"], | |
| ) | |
| template.modal.objects = [ | |
| pn.Column( | |
| sizing_mode="stretch_both", | |
| ) | |
| ] | |
| template.header.append(pn.pane.HTML(js.SHADOWROOT_INDEXING)) | |
| template.header.append(pn.pane.HTML(js.MODAL_MOUSE_UP_FIX)) | |
| template.header.append(pn.pane.HTML(js.CONNECTION_MONITOR)) | |
| return template | |
| def index_page(self): | |
| template = self.get_template() | |
| main_page = MainPage(engine=self._engine, template=template) | |
| template.main.append(main_page) | |
| return template | |
| def health_page(self): | |
| return pn.pane.HTML("<h1>Ok</h1>") | |
| def app(engine: Engine) -> App: | |
| return App(engine) | |
Xet Storage Details
- Size:
- 2.64 kB
- Xet hash:
- 1c8f3153121cf7a78601677e3b25a57e59844ac59ce73fcbc8a5aa04c37ca501
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.