v2
Browse files
app.py
CHANGED
@@ -33,9 +33,9 @@ def get_gym(bmi,slide, temp, API_KEY, model="gpt-3.5-turbo"):
|
|
33 |
)
|
34 |
return response.choices[0].message.content
|
35 |
|
36 |
-
def BMI(
|
37 |
-
|
38 |
-
bmi = int(
|
39 |
if bmi < 18.5:
|
40 |
return str(bmi)[:5], "過輕"
|
41 |
elif bmi < 24:
|
@@ -52,15 +52,20 @@ def BMI(height, weight) -> int:
|
|
52 |
|
53 |
|
54 |
# 建立 components
|
55 |
-
|
56 |
-
label="
|
57 |
-
info="
|
58 |
-
placeholder="Type your
|
59 |
|
60 |
-
|
61 |
-
label="
|
62 |
-
info="
|
63 |
-
placeholder="Type your
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
output_bmi = gr.Textbox(
|
66 |
value="",
|
@@ -128,8 +133,9 @@ with gr.Blocks() as demo:
|
|
128 |
""")
|
129 |
with gr.Column():
|
130 |
with gr.Row():
|
131 |
-
|
132 |
-
|
|
|
133 |
|
134 |
with gr.Row():
|
135 |
output_bmi.render() # 顯示BMI值結果
|
@@ -137,7 +143,7 @@ with gr.Blocks() as demo:
|
|
137 |
|
138 |
btn.render() # 顯示計算BMI值按鈕
|
139 |
btn.click(fn=BMI,
|
140 |
-
inputs=[
|
141 |
outputs=[output_bmi,output_state])
|
142 |
|
143 |
advice.render() # 顯示AI建議結果的文字框
|
|
|
33 |
)
|
34 |
return response.choices[0].message.content
|
35 |
|
36 |
+
def BMI(year, month) -> int:
|
37 |
+
year = int(year) / 100
|
38 |
+
bmi = int(month) / (year * year)
|
39 |
if bmi < 18.5:
|
40 |
return str(bmi)[:5], "過輕"
|
41 |
elif bmi < 24:
|
|
|
52 |
|
53 |
|
54 |
# 建立 components
|
55 |
+
year = gr.Textbox(
|
56 |
+
label="生年",
|
57 |
+
info="輸入你的西元出生年份",
|
58 |
+
placeholder="Type your birth year here...")
|
59 |
|
60 |
+
month = gr.Textbox(
|
61 |
+
label="生月",
|
62 |
+
info="輸入你的出生月份",
|
63 |
+
placeholder="Type your birthday month here...",)
|
64 |
+
|
65 |
+
day = gr.Textbox(
|
66 |
+
label="生日",
|
67 |
+
info="輸入你的出生日子",
|
68 |
+
placeholder="Type your birthday day here...",)
|
69 |
|
70 |
output_bmi = gr.Textbox(
|
71 |
value="",
|
|
|
133 |
""")
|
134 |
with gr.Column():
|
135 |
with gr.Row():
|
136 |
+
year.render() # 顯示年
|
137 |
+
month.render() # 顯示月
|
138 |
+
day.render() # 顯示日
|
139 |
|
140 |
with gr.Row():
|
141 |
output_bmi.render() # 顯示BMI值結果
|
|
|
143 |
|
144 |
btn.render() # 顯示計算BMI值按鈕
|
145 |
btn.click(fn=BMI,
|
146 |
+
inputs=[year, month],
|
147 |
outputs=[output_bmi,output_state])
|
148 |
|
149 |
advice.render() # 顯示AI建議結果的文字框
|