-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (33 loc) · 1.63 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import random
import time
import mesop as me
import mesop.labs as mel
from .components import test_component
def on_load(e: me.LoadEvent):
me.set_theme_mode("system")
@me.page(
security_policy=me.SecurityPolicy(
allowed_script_srcs=["https://cdn.jsdelivr.net"],
allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"],
),
path="/",
title="Mesop Demo Chat",
on_load=on_load,
)
def page():
mel.chat(transform, title="Mesop Demo Chat", bot_user="Mesop Bot")
test_component()
def transform(input: str, history: list[mel.ChatMessage]):
for line in random.sample(LINES, random.randint(3, len(LINES) - 1)):
time.sleep(0.3)
yield line + " "
LINES = [
"Mesop is a Python-based UI framework designed to simplify web UI development for engineers without frontend experience.",
"It leverages the power of the Angular web framework and Angular Material components, allowing rapid construction of web demos and internal tools.",
"With Mesop, developers can enjoy a fast build-edit-refresh loop thanks to its hot reload feature, making UI tweaks and component integration seamless.",
"Deployment is straightforward, utilizing standard HTTP technologies.",
"Mesop's component library aims for comprehensive Angular Material component coverage, enhancing UI flexibility and composability.",
"It supports custom components for specific use cases, ensuring developers can extend its capabilities to fit their unique requirements.",
"Mesop's roadmap includes expanding its component library and simplifying the onboarding processs.",
]
app = me.create_wsgi_app()