-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
132 lines (114 loc) · 3.67 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import mesop as me
from data_model import State
from prompts import send_prompt
from conversations import model_conversation
ROOT_BOX_STYLE = me.Style(
background="#e7f2ff",
height="100%",
font_family="Inter",
display="flex",
flex_direction="column",
)
STYLESHEETS = [
"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"
]
def header():
def navigate_home(e: me.ClickEvent):
me.navigate("/")
state = me.state(State)
state.conversations = []
with me.box(
on_click=navigate_home,
style=me.Style(
cursor="pointer",
padding=me.Padding.all(16),
),
):
me.text(
text="Gemini Text to SQL",
style=me.Style(
font_weight=500,
font_size=24,
color="#3D3929",
letter_spacing="0.3px",
),
)
@me.page(path="/", stylesheets=STYLESHEETS)
def app():
state = me.state(State)
with me.box(style=ROOT_BOX_STYLE):
header()
with me.box(
style=me.Style(
display="flex",
justify_content="center",
)
):
with me.box(
style=me.Style(
width="min(680px, 100%)",
padding=me.Padding(top=24, bottom=24),
)
):
me.text(
text="SQL Database name : example, nama table sales_order, kolom : (order_id, partner_id, item_id, item_quantity, total_selling_price, sales_channel, order_date, customer_id.)",
style=me.Style(
font_weight=500,
font_size=16,
color="#3D3929",
letter_spacing="0.3px",
),
)
promp_input()
models = len(state.conversations)
models_px = models * 680
with me.box(
style=me.Style(
background="#e7f2ff",
width=f"min({models_px}px, calc(100% - 32px))",
height=500,
display="grid",
gap=16,
grid_template_columns=f"repeat({models}, 1fr)",
flex_grow=1,
margin=me.Margin.symmetric(horizontal="auto"),
padding=me.Padding.symmetric(horizontal=16),
)
):
model_conversation()
def promp_input():
state = me.state(State)
with me.box(
style=me.Style(
border_radius=16,
padding=me.Padding.all(8),
background="white",
display="flex",
width="100%",
)
):
with me.box(style=me.Style(flex_grow=1)):
me.textarea(
value=state.input,
placeholder="Enter a prompt",
on_blur=on_blur,
style=me.Style(
padding=me.Padding(top=16, left=16),
outline="none",
width="100%",
border=me.Border.all(me.BorderSide(style="none")),
),
)
with me.box(
style=me.Style(
padding=me.Padding(top=16, left=16),
)
):
me.button(
label="SUBMIT",
type="stroked",
on_click=send_prompt
)
def on_blur(e: me.InputBlurEvent):
state = me.state(State)
state.input = e.value