Bargerya commited on
Commit
8697be1
1 Parent(s): 194601c
Files changed (1) hide show
  1. app.py +20 -14
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(height, weight) -> int:
37
- height = int(height) / 100
38
- bmi = int(weight) / (height * height)
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
- height = gr.Textbox(
56
- label="身高",
57
- info="輸入你的身高(cm)",
58
- placeholder="Type your hiegh here...")
59
 
60
- weight = gr.Textbox(
61
- label="體重",
62
- info="輸入你的體重(kg)",
63
- placeholder="Type your weight here...",)
 
 
 
 
 
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
- height.render() # 顯示身高輸入框
132
- weight.render() # 顯示體重輸入框
 
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=[height, weight],
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建議結果的文字框