{c["title_html"]}
{c["lead_html"]}
Try an example
Generation settings
{c["hint_html"]}
"""Custom The Fin AI page for Gradio-backed demo Spaces. Gradio only serves the page and the `/chat` API (gr.api); the whole UI is our own HTML/CSS/JS (page/), which talks to the API with @gradio/client. Works with Gradio 5 (head/css on Blocks) and Gradio 6 (head/css on launch). page = fa_page.Page(cfg) # cfg: see build_body() with gr.Blocks(**page.blocks_kwargs()) as demo: page.render() gr.api(chat, api_name="chat") demo.queue().launch(**page.launch_kwargs()) """ import html import json import os import gradio as gr HERE = os.path.dirname(os.path.abspath(__file__)) PAGE = os.path.join(HERE, "page") ASSETS = os.path.join(HERE, "assets") gr.set_static_paths(paths=[ASSETS]) GRADIO6 = int(gr.__version__.split(".")[0]) >= 6 CLIENT = "2.7.1" if GRADIO6 else "1.19.1" # @gradio/client matching the Gradio major version e = lambda s: html.escape(str(s), quote=True) def asset(path): return f"/gradio_api/file={os.path.join(ASSETS, path)}" def _read(name): with open(os.path.join(PAGE, name), encoding="utf-8") as f: return f.read() ICON_SEND = '' ICON_STOP = '' ICON_IMG = '' class Page: def __init__(self, cfg): self.cfg = cfg def head(self): c = self.cfg chat = {"client": CLIENT, "endpoint": "/chat", "image": c.get("image", False), "avatar": asset(c["avatar"]), "greeting": c["greeting"], "params": c["params"], "readyText": c.get("ready_text", "Ready"), "examples": [{**x, "image": asset(x["image"]) if x.get("image") else None} for x in c["examples"]]} fonts = ('' '') return (fonts + f'' f'') def body(self): c = self.cfg nav = "".join(f'{e(l)}' for l, u in c["nav"]) stats = "".join(f'
{c["lead_html"]}
{c["hint_html"]}
{c["orgs_sub_html"]}
{c["disclaimer"]}