Spaces:
Running
Running
Richard
commited on
Commit
·
d45098d
1
Parent(s):
48f7fed
Fix bug with incorrectly place event handler
Browse files- main.py +2 -5
- prompt/base_examples.txt +110 -1
- prompt/chat_elements_examples.txt +111 -0
main.py
CHANGED
@@ -180,13 +180,10 @@ def main():
|
|
180 |
):
|
181 |
for prompt_history in reversed(state.prompt_history):
|
182 |
with me.box(
|
183 |
-
key=f"prompt-{prompt_history['index']}",
|
184 |
on_click=on_click_history_prompt,
|
|
|
185 |
style=me.Style(
|
186 |
background=me.theme_var("surface-container"),
|
187 |
-
border=me.Border.all(
|
188 |
-
me.BorderSide(width=1, color=me.theme_var("outline-variant"), style="solid")
|
189 |
-
),
|
190 |
border_radius=5,
|
191 |
cursor="pointer",
|
192 |
margin=me.Margin.symmetric(vertical=10),
|
@@ -202,7 +199,7 @@ def main():
|
|
202 |
display="grid",
|
203 |
grid_template_columns="1fr 2fr 35fr" if state.menu_open else "1fr 40fr",
|
204 |
height="100vh",
|
205 |
-
)
|
206 |
):
|
207 |
with me.box(
|
208 |
style=me.Style(
|
|
|
180 |
):
|
181 |
for prompt_history in reversed(state.prompt_history):
|
182 |
with me.box(
|
|
|
183 |
on_click=on_click_history_prompt,
|
184 |
+
key=f"prompt-{prompt_history['index']}",
|
185 |
style=me.Style(
|
186 |
background=me.theme_var("surface-container"),
|
|
|
|
|
|
|
187 |
border_radius=5,
|
188 |
cursor="pointer",
|
189 |
margin=me.Margin.symmetric(vertical=10),
|
|
|
199 |
display="grid",
|
200 |
grid_template_columns="1fr 2fr 35fr" if state.menu_open else "1fr 40fr",
|
201 |
height="100vh",
|
202 |
+
),
|
203 |
):
|
204 |
with me.box(
|
205 |
style=me.Style(
|
prompt/base_examples.txt
CHANGED
@@ -1,3 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
This section provides examples of Mesop code usage. Each example is wrapped in <example> tags.
|
2 |
|
3 |
<example>
|
@@ -1850,4 +1960,3 @@ def card(resource: Resource):
|
|
1850 |
)
|
1851 |
|
1852 |
<example>
|
1853 |
-
|
|
|
1 |
+
Layout in Mesop is very similar to using HTML and CSS for styling, so you can use
|
2 |
+
your expertise in HTML / CSS to layout Mesop apps.
|
3 |
+
|
4 |
+
Note that there are some limitations and differences. You will need to use me.box as a
|
5 |
+
replacement for HTML tags such as divs, span, header, aside, etc. The me.box component
|
6 |
+
behaves most close to a div.
|
7 |
+
|
8 |
+
Mesop also relies on inline styles. It also does not support all css styles yet, so you
|
9 |
+
will need to check the me.Style API for what is supported.
|
10 |
+
|
11 |
+
Here is an example of a layout in HTML/CSS.
|
12 |
+
|
13 |
+
First the CSS:
|
14 |
+
|
15 |
+
```css
|
16 |
+
<style>
|
17 |
+
.container {
|
18 |
+
display: flex;
|
19 |
+
flex-direction: column;
|
20 |
+
height: 100vh;
|
21 |
+
}
|
22 |
+
.header {
|
23 |
+
background-color: #333;
|
24 |
+
color: white;
|
25 |
+
padding: 1rem;
|
26 |
+
}
|
27 |
+
.content {
|
28 |
+
display: flex;
|
29 |
+
flex: 1;
|
30 |
+
}
|
31 |
+
.sidebar {
|
32 |
+
background-color: #f0f0f0;
|
33 |
+
width: 200px;
|
34 |
+
padding: 1rem;
|
35 |
+
}
|
36 |
+
.main {
|
37 |
+
flex: 1;
|
38 |
+
padding: 1rem;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
```
|
42 |
+
|
43 |
+
Next the HTML:
|
44 |
+
|
45 |
+
```html
|
46 |
+
<div class="container">
|
47 |
+
<div class="header">
|
48 |
+
<h1>My Website</h1>
|
49 |
+
</div>
|
50 |
+
<div class="content">
|
51 |
+
<div class="sidebar">
|
52 |
+
<h2>Sidebar</h2>
|
53 |
+
<p>Sidebar content</p>
|
54 |
+
</div>
|
55 |
+
<div class="main">
|
56 |
+
<h2>Main Content</h2>
|
57 |
+
<p>This is the main content area. You can add your page-specific content here.</p>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
```
|
62 |
+
|
63 |
+
In Mesop, this looks like:
|
64 |
+
|
65 |
+
```python
|
66 |
+
import mesop as me
|
67 |
+
|
68 |
+
STYLE_CONTAINER = me.Style(
|
69 |
+
display="flex",
|
70 |
+
flex_direction="column",
|
71 |
+
height="100vh",
|
72 |
+
)
|
73 |
+
STYLE_HEADER = me.Style(
|
74 |
+
background="#333",
|
75 |
+
color="white",
|
76 |
+
padding=me.Padding.all("1rem"),
|
77 |
+
)
|
78 |
+
|
79 |
+
STYLE_CONTENT = me.Style(
|
80 |
+
display="flex",
|
81 |
+
flex_grow=1,
|
82 |
+
)
|
83 |
+
|
84 |
+
STYLE_SIDEBAR = me.Style(
|
85 |
+
background="#f0f0f0",
|
86 |
+
width="200px",
|
87 |
+
padding=me.Padding.all("1rem"),
|
88 |
+
)
|
89 |
+
|
90 |
+
STYLE_MAIN = me.Style(
|
91 |
+
flex_grow=1,
|
92 |
+
padding=me.Padding.all("1rem"),
|
93 |
+
)
|
94 |
+
|
95 |
+
@me.page()
|
96 |
+
def app():
|
97 |
+
with me.box(style=STYLE_CONTAINER):
|
98 |
+
with me.box(style=STYLE_HEADER):
|
99 |
+
me.text("My Website", type="headline-4")
|
100 |
+
|
101 |
+
with me.box(style=STYLE_CONTENT):
|
102 |
+
with me.box(style=STYLE_SIDEBAR):
|
103 |
+
me.text("Sidebar", type="headline-5")
|
104 |
+
me.text("Sidebar content")
|
105 |
+
|
106 |
+
with me.box(style=STYLE_MAIN):
|
107 |
+
me.text("Main Content", type="headline-5")
|
108 |
+
me.text("This is the main content area. You can add your page-specific content here")
|
109 |
+
```
|
110 |
+
|
111 |
This section provides examples of Mesop code usage. Each example is wrapped in <example> tags.
|
112 |
|
113 |
<example>
|
|
|
1960 |
)
|
1961 |
|
1962 |
<example>
|
|
prompt/chat_elements_examples.txt
CHANGED
@@ -1,3 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
This section provides examples of elements that can be used for composing chat UIs in Mesop. Each example is wrapped in <example> tags.
|
2 |
|
3 |
<example>
|
|
|
1 |
+
Layout in Mesop is very similar to using HTML and CSS for styling, so you can use
|
2 |
+
your expertise in HTML / CSS to layout Mesop apps.
|
3 |
+
|
4 |
+
Note that there are some limitations and differences. You will need to use me.box as a
|
5 |
+
replacement for HTML tags such as divs, span, header, aside, etc. The me.box component
|
6 |
+
behaves most close to a div.
|
7 |
+
|
8 |
+
Mesop also relies on inline styles. It also does not support all css styles yet, so you
|
9 |
+
will need to check the me.Style API for what is supported.
|
10 |
+
|
11 |
+
Here is an example of a layout in HTML/CSS.
|
12 |
+
|
13 |
+
First the CSS:
|
14 |
+
|
15 |
+
```css
|
16 |
+
<style>
|
17 |
+
.container {
|
18 |
+
display: flex;
|
19 |
+
flex-direction: column;
|
20 |
+
height: 100vh;
|
21 |
+
}
|
22 |
+
.header {
|
23 |
+
background-color: #333;
|
24 |
+
color: white;
|
25 |
+
padding: 1rem;
|
26 |
+
}
|
27 |
+
.content {
|
28 |
+
display: flex;
|
29 |
+
flex: 1;
|
30 |
+
}
|
31 |
+
.sidebar {
|
32 |
+
background-color: #f0f0f0;
|
33 |
+
width: 200px;
|
34 |
+
padding: 1rem;
|
35 |
+
}
|
36 |
+
.main {
|
37 |
+
flex: 1;
|
38 |
+
padding: 1rem;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
```
|
42 |
+
|
43 |
+
Next the HTML:
|
44 |
+
|
45 |
+
```html
|
46 |
+
<div class="container">
|
47 |
+
<div class="header">
|
48 |
+
<h1>My Website</h1>
|
49 |
+
</div>
|
50 |
+
<div class="content">
|
51 |
+
<div class="sidebar">
|
52 |
+
<h2>Sidebar</h2>
|
53 |
+
<p>Sidebar content</p>
|
54 |
+
</div>
|
55 |
+
<div class="main">
|
56 |
+
<h2>Main Content</h2>
|
57 |
+
<p>This is the main content area. You can add your page-specific content here.</p>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
```
|
62 |
+
|
63 |
+
In Mesop, this looks like:
|
64 |
+
|
65 |
+
```python
|
66 |
+
import mesop as me
|
67 |
+
|
68 |
+
STYLE_CONTAINER = me.Style(
|
69 |
+
display="flex",
|
70 |
+
flex_direction="column",
|
71 |
+
height="100vh",
|
72 |
+
)
|
73 |
+
STYLE_HEADER = me.Style(
|
74 |
+
background="#333",
|
75 |
+
color="white",
|
76 |
+
padding=me.Padding.all("1rem"),
|
77 |
+
)
|
78 |
+
|
79 |
+
STYLE_CONTENT = me.Style(
|
80 |
+
display="flex",
|
81 |
+
flex_grow=1,
|
82 |
+
)
|
83 |
+
|
84 |
+
STYLE_SIDEBAR = me.Style(
|
85 |
+
background="#f0f0f0",
|
86 |
+
width="200px",
|
87 |
+
padding=me.Padding.all("1rem"),
|
88 |
+
)
|
89 |
+
|
90 |
+
STYLE_MAIN = me.Style(
|
91 |
+
flex_grow=1,
|
92 |
+
padding=me.Padding.all("1rem"),
|
93 |
+
)
|
94 |
+
|
95 |
+
@me.page()
|
96 |
+
def app():
|
97 |
+
with me.box(style=STYLE_CONTAINER):
|
98 |
+
with me.box(style=STYLE_HEADER):
|
99 |
+
me.text("My Website", type="headline-4")
|
100 |
+
|
101 |
+
with me.box(style=STYLE_CONTENT):
|
102 |
+
with me.box(style=STYLE_SIDEBAR):
|
103 |
+
me.text("Sidebar", type="headline-5")
|
104 |
+
me.text("Sidebar content")
|
105 |
+
|
106 |
+
with me.box(style=STYLE_MAIN):
|
107 |
+
me.text("Main Content", type="headline-5")
|
108 |
+
me.text("This is the main content area. You can add your page-specific content here")
|
109 |
+
```
|
110 |
+
|
111 |
+
|
112 |
This section provides examples of elements that can be used for composing chat UIs in Mesop. Each example is wrapped in <example> tags.
|
113 |
|
114 |
<example>
|