MakiAi commited on
Commit
d4330ab
·
verified ·
1 Parent(s): 2de0e99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +615 -59
app.py CHANGED
@@ -1,64 +1,620 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
 
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
-
9
-
10
- def respond(
11
- message,
12
- history: list[tuple[str, str]],
13
- system_message,
14
- max_tokens,
15
- temperature,
16
- top_p,
17
- ):
18
- messages = [{"role": "system", "content": system_message}]
19
-
20
- for val in history:
21
- if val[0]:
22
- messages.append({"role": "user", "content": val[0]})
23
- if val[1]:
24
- messages.append({"role": "assistant", "content": val[1]})
25
-
26
- messages.append({"role": "user", "content": message})
27
-
28
- response = ""
29
-
30
- for message in client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- stream=True,
34
- temperature=temperature,
35
- top_p=top_p,
36
- ):
37
- token = message.choices[0].delta.content
38
-
39
- response += token
40
- yield response
41
-
42
-
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
- demo = gr.ChatInterface(
47
- respond,
48
- additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
- gr.Slider(
53
- minimum=0.1,
54
- maximum=1.0,
55
- value=0.95,
56
- step=0.05,
57
- label="Top-p (nucleus sampling)",
58
- ),
59
- ],
60
- )
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
 
63
  if __name__ == "__main__":
64
- demo.launch()
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import time
3
+ import pandas as pd
4
 
5
+ # 和水(WA-SUI)テーマの作成
6
+ def create_wa_sui_theme():
7
+ return gr.Theme(
8
+ primary_hue="blue",
9
+ secondary_hue="cyan",
10
+ neutral_hue="slate",
11
+ text_size="md",
12
+ spacing_size="lg",
13
+ radius_size="sm",
14
+ font=[
15
+ "Hiragino Sans",
16
+ "Noto Sans JP",
17
+ "Yu Gothic",
18
+ "system-ui",
19
+ "sans-serif"
20
+ ],
21
+ font_mono=[
22
+ "SF Mono",
23
+ "Monaco",
24
+ "monospace"
25
+ ]
26
+ ).set(
27
+ # 和水カラーパレット
28
+ body_background_fill="#ffffff", # 純白の背景
29
+ body_text_color="#025159", # WA-from-above-4: 深海の静寂
30
+ button_primary_background_fill="#03658C", # WA-from-above-2: 深い海
31
+ button_primary_background_fill_hover="#025159", # WA-from-above-4: より深い海
32
+ button_primary_text_color="#ffffff", # WA-from-above-1: 水面の輝き
33
+ button_secondary_background_fill="#03A6A6", # WA-from-above-5: ティールの調和
34
+ button_secondary_background_fill_hover="#037F8C", # WA-from-above-3: 中間の深さ
35
+ button_secondary_text_color="#ffffff", # WA-from-above-4: 深海
36
+ input_background_fill="#ffffff", # 純白
37
+ input_border_color="#03A6A6", # WA-from-above-5: ティール
38
+ input_border_color_focus="#03658C", # WA-from-above-2: フォーカス時
39
+ block_background_fill="#ffffff", # 純白
40
+ block_border_color="#037F8C", # WA-from-above-3: 境界
41
+ panel_background_fill="#ffffff", # 純白
42
+ panel_border_color="#037F8C", # WA-from-above-3: パネル境界
43
+ slider_color="#03658C", # WA-from-above-2: スライダー
44
+ checkbox_label_text_color="#ffffff", # チェックボックスの文字色を白に
45
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ # 豊富なUIコンポーネントのデモ
48
+ def create_comprehensive_demo():
49
+ theme = create_wa_sui_theme()
50
+
51
+ # データ用のサンプル
52
+ sample_data = pd.DataFrame({
53
+ "商品名": ["碧海ラテ", "水面煎茶", "深海玄米茶", "潮風ほうじ茶"],
54
+ "価格": [450, 300, 280, 320],
55
+ "在庫": [15, 25, 8, 12],
56
+ "評価": [4.8, 4.5, 4.2, 4.6]
57
+ })
58
+
59
+ # 関数定義
60
+ def greet(name, mood, age, subscribe, hobbies_selected, prefecture_selected, satisfaction_level):
61
+ if not name:
62
+ return "名前を入力してください。"
63
+
64
+ age_msg = f"({age}歳)" if age else ""
65
+ subscribe_msg = "ニュースレターの購読ありがとうございます!" if subscribe else ""
66
+ hobbies_msg = f"趣味: {', '.join(hobbies_selected)}" if hobbies_selected else "趣味: 未選択"
67
+ prefecture_msg = f"出身: {prefecture_selected}"
68
+
69
+ # 満足度のNone値を処理
70
+ if satisfaction_level is None:
71
+ satisfaction_msg = "満足度: 未設定"
72
+ else:
73
+ satisfaction_msg = f"満足度: {int(satisfaction_level)}/10"
74
+
75
+ greetings = {
76
+ "🌊 爽やか": f"{name}さん{age_msg}、今��は海のように爽やかですね!🌊",
77
+ "💧 静寂": f"こんにちは、{name}さん{age_msg}。水のように静かな一日ですね。",
78
+ "🏖️ 穏やか": f"{name}さん{age_msg}、穏やかな波のような心地よい日ですね。🏖️"
79
+ }
80
+ result = greetings.get(mood, f"こんにちは、{name}さん{age_msg}。")
81
+ result += f"\n{hobbies_msg}"
82
+ result += f"\n{prefecture_msg}"
83
+ result += f"\n{satisfaction_msg}"
84
+ if subscribe_msg:
85
+ result += f"\n{subscribe_msg}"
86
+ return result
87
+
88
+ def generate_haiku(season, style):
89
+ haikus = {
90
+ ("🌊 海", "古典"): "青い海\n波音響きて\n心澄む",
91
+ ("🌊 海", "現代"): "海見つめ\nインスタ映えする\n青い空",
92
+ ("💧 雨", "古典"): "雨滴りて\n水面に広がる\n静寂かな",
93
+ ("💧 雨", "現代"): "雨の日は\nカフェで海を\n眺めつつ",
94
+ ("🌙 月", "古典"): "月影が\n水面に映りて\n揺らめけり",
95
+ ("🌙 月", "現代"): "月夜には\n海カフェでまったり\nティータイム",
96
+ ("❄️ 雪", "古典"): "雪降りて\n海も静寂に\n包まれん",
97
+ ("❄️ 雪", "現代"): "雪景色\n海と空とが\n一つなり"
98
+ }
99
+ return haikus.get((season, style), "季語なし\n心に響きて\n句となりぬ")
100
+
101
+ def process_data(data, filter_price):
102
+ if data is None:
103
+ return sample_data
104
+
105
+ df = pd.DataFrame(data)
106
+ if filter_price:
107
+ df = df[df['価格'] >= filter_price]
108
+ return df
109
+
110
+ def add_chat_message(message, history):
111
+ if message:
112
+ responses = [
113
+ "海のように深いご質問ですね!",
114
+ "波のようにゆったりと考えてみましょう。",
115
+ "なるほど、潮の満ち引きのように理解できます。",
116
+ "水面に映る月のように美しい発想ですね!",
117
+ "一緒に海風を感じながら考えてみましょう。"
118
+ ]
119
+ import random
120
+ response = random.choice(responses)
121
+ history.append([message, response])
122
+ return history, ""
123
+
124
+ # クリア機能の修正
125
+ def clear_all_inputs():
126
+ return [
127
+ "", # name_input
128
+ 25, # age_input
129
+ "💧 静寂", # mood_selector
130
+ False, # subscribe_check
131
+ [], # hobbies
132
+ "神奈川県", # prefecture
133
+ 8, # satisfaction
134
+ "", # hobbies_debug
135
+ "神奈川県, 満足度: 8", # status_debug
136
+ "8 (type: int)", # satisfaction_debug
137
+ "" # result_output
138
+ ]
139
+
140
+ # 趣味選択の変更を監視する関数
141
+ def update_hobbies_debug(selected_hobbies):
142
+ if selected_hobbies:
143
+ return ", ".join(selected_hobbies)
144
+ else:
145
+ return "未選択"
146
+
147
+ # 都道府県と満足度の変更を監視する関数
148
+ def update_status_debug(prefecture_val, satisfaction_val):
149
+ if satisfaction_val is None:
150
+ return f"{prefecture_val}, 満足度: 未設定"
151
+ else:
152
+ return f"{prefecture_val}, 満足度: {int(satisfaction_val)}"
153
+
154
+ # 満足度の変更を監視する関数(専用)
155
+ def update_satisfaction_debug(satisfaction_val):
156
+ if satisfaction_val is None:
157
+ return "None (未設定)"
158
+ else:
159
+ return f"{satisfaction_val} (type: {type(satisfaction_val).__name__})"
160
+
161
+ with gr.Blocks(theme=theme, title="WA-SUI 和水") as demo:
162
+
163
+ # ヘッダー
164
+ gr.HTML("""
165
+ <div style='text-align: center; margin-bottom: 2rem; padding: 2rem; background: linear-gradient(135deg, #03658C 0%, #AED3F2 100%); color: white; border-radius: 12px; box-shadow: 0 8px 32px rgba(3, 101, 140, 0.3);'>
166
+ <h1 style='font-size: 3rem; margin-bottom: 0.5rem; text-shadow: 2px 2px 4px rgba(2, 81, 89, 0.5); color: white;'>WA-SUI 和水</h1>
167
+ <p style='font-size: 1.2rem; margin: 0; opacity: 0.9; color: white;'>〜 水の流れのような調和とデザイン 〜</p>
168
+ </div>
169
+ """)
170
+
171
+ with gr.Tabs():
172
+
173
+ # 基本入力コンポーネント
174
+ with gr.Tab("🌊 基本入力"):
175
+ gr.Markdown("### 様々な入力コンポーネント")
176
+
177
+ with gr.Row():
178
+ with gr.Column():
179
+ name_input = gr.Textbox(
180
+ label="🌊 お名前",
181
+ placeholder="海野太郎",
182
+ info="フルネームを入力してください"
183
+ )
184
+
185
+ age_input = gr.Number(
186
+ label="🎂 年齢",
187
+ minimum=0,
188
+ maximum=120,
189
+ value=25
190
+ )
191
+
192
+ mood_selector = gr.Radio(
193
+ choices=["🌊 爽やか", "💧 静寂", "🏖️ 穏やか"],
194
+ label="🎭 今日の気分",
195
+ value="💧 静寂"
196
+ )
197
+
198
+ subscribe_check = gr.Checkbox(
199
+ label="📧 海のお便りを購読する",
200
+ value=False
201
+ )
202
+
203
+ with gr.Column():
204
+ hobbies = gr.CheckboxGroup(
205
+ choices=["🏄‍♂️ サーフィン", "🐠 釣り", "🌊 海水浴", "🏃‍♂️ ジョギング", "🍵 茶道", "🎨 水彩画"],
206
+ label="趣味(複数選択可)",
207
+ value=["🐠 釣り"],
208
+ interactive=True
209
+ )
210
+
211
+ prefecture = gr.Dropdown(
212
+ choices=["北海道", "神奈川県", "静岡県", "愛知県", "三重県", "沖縄県"],
213
+ label="🗾 都道府県(海に近い県)",
214
+ value="神奈川県",
215
+ interactive=True
216
+ )
217
+
218
+ satisfaction = gr.Slider(
219
+ minimum=1,
220
+ maximum=10,
221
+ value=8,
222
+ step=1,
223
+ label="🌊 満足度(波の高さで表現:1-10)",
224
+ interactive=True,
225
+ show_label=True
226
+ )
227
+
228
+ # デバッグ用:選択された趣味を表示
229
+ hobbies_debug = gr.Textbox(
230
+ label="🔍 選択中の趣味(デバッグ用)",
231
+ interactive=False,
232
+ value="🐠 釣り"
233
+ )
234
+
235
+ # デバッグ用:都道府県と満足度を表示
236
+ status_debug = gr.Textbox(
237
+ label="🔍 都道府県・満足度(デバッグ用)",
238
+ interactive=False,
239
+ value="神奈川県, 満足度: 8"
240
+ )
241
+
242
+ # デバッグ用:満足度の生の値を表示
243
+ satisfaction_debug = gr.Textbox(
244
+ label="🔍 満足度の生の値(デバッグ用)",
245
+ interactive=False,
246
+ value="8"
247
+ )
248
+
249
+ with gr.Row():
250
+ submit_btn = gr.Button("🌊 情報を送信", variant="primary", size="lg")
251
+ clear_btn = gr.Button("🗑️ クリア", variant="secondary")
252
+
253
+ result_output = gr.Textbox(
254
+ label="💌 結果",
255
+ interactive=False,
256
+ lines=4
257
+ )
258
+
259
+ # イベントハンドラーの修正
260
+ submit_btn.click(
261
+ fn=greet,
262
+ inputs=[name_input, mood_selector, age_input, subscribe_check, hobbies, prefecture, satisfaction],
263
+ outputs=result_output
264
+ )
265
+
266
+ # クリアボタンの修正
267
+ clear_btn.click(
268
+ fn=clear_all_inputs,
269
+ inputs=None,
270
+ outputs=[name_input, age_input, mood_selector, subscribe_check,
271
+ hobbies, prefecture, satisfaction, hobbies_debug, status_debug, satisfaction_debug, result_output]
272
+ )
273
+
274
+ # 趣味選択の変更を監視
275
+ hobbies.change(
276
+ fn=update_hobbies_debug,
277
+ inputs=[hobbies],
278
+ outputs=[hobbies_debug]
279
+ )
280
+
281
+ # 都道府県と満足度の変更を監視
282
+ prefecture.change(
283
+ fn=update_status_debug,
284
+ inputs=[prefecture, satisfaction],
285
+ outputs=[status_debug]
286
+ )
287
+
288
+ satisfaction.change(
289
+ fn=update_status_debug,
290
+ inputs=[prefecture, satisfaction],
291
+ outputs=[status_debug]
292
+ )
293
+
294
+ # 満足度専用の監視
295
+ satisfaction.change(
296
+ fn=update_satisfaction_debug,
297
+ inputs=[satisfaction],
298
+ outputs=[satisfaction_debug]
299
+ )
300
+
301
+ # 俳句生成
302
+ with gr.Tab("🎋 海の俳句工房"):
303
+ gr.Markdown("### AI海洋俳句生成システム")
304
+
305
+ with gr.Row():
306
+ with gr.Column():
307
+ season_selector = gr.Radio(
308
+ choices=["🌊 海", "💧 雨", "🌙 月", "❄️ 雪"],
309
+ label="🌊 季語を選択",
310
+ value="🌊 海"
311
+ )
312
+
313
+ style_selector = gr.Radio(
314
+ choices=["古典", "現代"],
315
+ label="🎨 スタイル",
316
+ value="古典"
317
+ )
318
+
319
+ haiku_btn = gr.Button("🌊 俳句を作る", variant="primary", size="lg")
320
+
321
+ with gr.Column(scale=2):
322
+ haiku_result = gr.Textbox(
323
+ label="📜 生成された俳句",
324
+ interactive=False,
325
+ lines=5,
326
+ placeholder="ここに美しい海の俳句が表示されます...",
327
+ )
328
+
329
+ gr.Markdown("""
330
+ **俳句の説明:**
331
+ - **古典**: 伝統的な海の表現スタイル
332
+ - **現代**: 現代的な海の言葉遣い
333
+ """)
334
+
335
+ haiku_btn.click(
336
+ fn=generate_haiku,
337
+ inputs=[season_selector, style_selector],
338
+ outputs=haiku_result
339
+ )
340
+
341
+ # データ表示
342
+ with gr.Tab("📊 海のデータ"):
343
+ gr.Markdown("### データ表示コンポーネント")
344
+
345
+ with gr.Row():
346
+ with gr.Column():
347
+ price_filter = gr.Slider(
348
+ minimum=200,
349
+ maximum=500,
350
+ value=300,
351
+ step=50,
352
+ label="💰 最低価格フィルター"
353
+ )
354
+
355
+ refresh_btn = gr.Button("🔄 データ更新", variant="secondary")
356
+
357
+ # JSON表示
358
+ json_data = gr.JSON(
359
+ value={
360
+ "店舗名": "海風カフェ 碧",
361
+ "営業時間": "9:00-21:00",
362
+ "定休日": "火曜日",
363
+ "メニュー数": 15,
364
+ "人気商品": ["碧海ラテ", "海風スイーツセット"]
365
+ },
366
+ label="📋 店舗情報(JSON)"
367
+ )
368
+
369
+ with gr.Column(scale=2):
370
+ # データフレーム表示
371
+ data_display = gr.DataFrame(
372
+ value=sample_data,
373
+ label="🌊 海のメニューデータ",
374
+ interactive=True,
375
+ wrap=True
376
+ )
377
+
378
+ # ラベル表示
379
+ label_display = gr.Label(
380
+ value={
381
+ "海の見える店": 0.95,
382
+ "潮風感じる": 0.88,
383
+ "青い空気": 0.75,
384
+ "波音聞こえる": 0.62
385
+ },
386
+ label="🏆 海のカフェ評価スコア"
387
+ )
388
+
389
+ refresh_btn.click(
390
+ fn=process_data,
391
+ inputs=[data_display, price_filter],
392
+ outputs=data_display
393
+ )
394
+
395
+ # チャットボット
396
+ with gr.Tab("💬 海のチャットボット"):
397
+ gr.Markdown("### 海風AIアシスタントと会話")
398
+
399
+ with gr.Row():
400
+ with gr.Column(scale=2):
401
+ chatbot = gr.Chatbot(
402
+ value=[["こんにちは!", "こんにちは!海風カフェ碧のAIアシスタントです。海のようにゆったりとお手伝いさせていただきます🌊"]],
403
+ label="🤖 海風AIアシスタント",
404
+ height=400
405
+ )
406
+
407
+ with gr.Row():
408
+ chat_input = gr.Textbox(
409
+ placeholder="波のようにメッセージを入力してください...",
410
+ label="",
411
+ scale=4
412
+ )
413
+ send_btn = gr.Button("🌊 送信", variant="primary", scale=1)
414
+
415
+ # クイック返信ボタン
416
+ with gr.Row():
417
+ quick1 = gr.Button("☕ 海のメニューは?", size="sm")
418
+ quick2 = gr.Button("🕐 営業時間は?", size="sm")
419
+ quick3 = gr.Button("📍 海までの道は?", size="sm")
420
+
421
+ with gr.Column():
422
+ gr.Markdown("### 💡 海の便利機能")
423
+
424
+ gr.Markdown("""
425
+ **質問例:**
426
+ - 海を眺められるメニュー
427
+ - 潮風を感じる営業時間
428
+ - 海辺へのアクセス方法
429
+ - 海の見える席の予約
430
+ - 海風イベント情報
431
+ """)
432
+
433
+ # アコーディオン
434
+ with gr.Accordion("🔧 詳細設定", open=False):
435
+ temperature = gr.Slider(
436
+ minimum=0.1,
437
+ maximum=2.0,
438
+ value=0.7,
439
+ step=0.1,
440
+ label="🌡️ 応答の流動性(波の動き)"
441
+ )
442
+
443
+ max_tokens = gr.Slider(
444
+ minimum=50,
445
+ maximum=500,
446
+ value=150,
447
+ step=25,
448
+ label="📏 最大応答長(潮の満ち引き)"
449
+ )
450
+
451
+ # チャット機能の実装
452
+ send_btn.click(
453
+ fn=add_chat_message,
454
+ inputs=[chat_input, chatbot],
455
+ outputs=[chatbot, chat_input]
456
+ )
457
+
458
+ chat_input.submit(
459
+ fn=add_chat_message,
460
+ inputs=[chat_input, chatbot],
461
+ outputs=[chatbot, chat_input]
462
+ )
463
+
464
+ # クイック返信の修正
465
+ def quick_reply_1(history):
466
+ new_history = history + [["海のメニューは?", "碧海ラテと海風スイーツセットが人気です!季節限定の潮風もちもおすすめです。🌊"]]
467
+ return new_history
468
+
469
+ def quick_reply_2(history):
470
+ new_history = history + [["営業時間は?", "海の見える時間、9:00-21:00で営業しています。定休日は火曜日です。🌅🌅"]]
471
+ return new_history
472
+
473
+ def quick_reply_3(history):
474
+ new_history = history + [["海までの道は?", "JR東海道線「大磯駅」から徒歩5分です。海岸線沿いの青い建物が目印です。🏖️"]]
475
+ return new_history
476
+
477
+ quick1.click(
478
+ fn=quick_reply_1,
479
+ inputs=[chatbot],
480
+ outputs=[chatbot]
481
+ )
482
+
483
+ quick2.click(
484
+ fn=quick_reply_2,
485
+ inputs=[chatbot],
486
+ outputs=[chatbot]
487
+ )
488
+
489
+ quick3.click(
490
+ fn=quick_reply_3,
491
+ inputs=[chatbot],
492
+ outputs=[chatbot]
493
+ )
494
+
495
+ # テーマ設定
496
+ with gr.Tab("🌊 WA-SUI設定"):
497
+ gr.Markdown("### WA-SUI(和水)テーマの哲学")
498
+
499
+ # カラーパレット表示
500
+ gr.HTML("""
501
+ <div style='display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin: 2rem 0;'>
502
+ <div style='padding: 1.5rem; background: #ffffff; border: 2px solid #037F8C; border-radius: 12px; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(174, 211, 242, 0.3);'>
503
+ <h4 style='color: #025159; margin-top: 0;'>🤍 純白の背景</h4>
504
+ <div style='width: 100%; height: 60px; background: #ffffff; border: 2px solid #AED3F2; border-radius: 8px; margin: 1rem 0; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'></div>
505
+ <p style='font-size: 0.9rem; color: #025159; margin: 0;'>#ffffff - メイン背景</p>
506
+ </div>
507
+ <div style='padding: 1.5rem; background: #ffffff; border: 2px solid #037F8C; border-radius: 12px; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(174, 211, 242, 0.3);'>
508
+ <h4 style='color: #025159; margin-top: 0;'>🌊 水面の輝き</h4>
509
+ <div style='width: 100%; height: 60px; background: #AED3F2; border-radius: 8px; margin: 1rem 0; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'></div>
510
+ <p style='font-size: 0.9rem; color: #025159; margin: 0;'>#AED3F2 - アクセント</p>
511
+ </div>
512
+ <div style='padding: 1.5rem; background: #ffffff; border: 2px solid #037F8C; border-radius: 12px; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(3, 101, 140, 0.3);'>
513
+ <h4 style='color: #025159; margin-top: 0;'>🌀 深い海</h4>
514
+ <div style='width: 100%; height: 60px; background: #03658C; border-radius: 8px; margin: 1rem 0; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'></div>
515
+ <p style='font-size: 0.9rem; color: #025159; margin: 0;'>#03658C - プライマリ</p>
516
+ </div>
517
+ <div style='padding: 1.5rem; background: #ffffff; border: 2px solid #037F8C; border-radius: 12px; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(3, 127, 140, 0.3);'>
518
+ <h4 style='color: #025159; margin-top: 0;'>🌊 中間の深さ</h4>
519
+ <div style='width: 100%; height: 60px; background: #037F8C; border-radius: 8px; margin: 1rem 0; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'></div>
520
+ <p style='font-size: 0.9rem; color: #025159; margin: 0;'>#037F8C - ボーダー</p>
521
+ </div>
522
+ <div style='padding: 1.5rem; background: #ffffff; border: 2px solid #037F8C; border-radius: 12px; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(1, 80, 89, 0.3);'>
523
+ <h4 style='color: #025159; margin-top: 0;'>🕳️ 深海の静寂</h4>
524
+ <div style='width: 100%; height: 60px; background: #025159; border-radius: 8px; margin: 1rem 0; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'></div>
525
+ <p style='font-size: 0.9rem; color: #025159; margin: 0;'>#025159 - テキスト</p>
526
+ </div>
527
+ <div style='padding: 1.5rem; background: #ffffff; border: 2px solid #037F8C; border-radius: 12px; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(3, 165, 165, 0.3);'>
528
+ <h4 style='color: #025159; margin-top: 0;'>💎 ティールの調和</h4>
529
+ <div style='width: 100%; height: 60px; background: #03A6A6; border-radius: 8px; margin: 1rem 0; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'></div>
530
+ <p style='font-size: 0.9rem; color: #025159; margin: 0;'>#03A6A6 - セカンダリ</p>
531
+ </div>
532
+ </div>
533
+ """)
534
+
535
+ gr.Markdown("""
536
+ ### 🌊 WA-SUI(和水)デザイン哲学
537
+
538
+ **流(りゅう)- Flow**
539
+ - 水の自然な流れを表現
540
+ - 要素間の滑らかな遷移
541
+ - ユーザーの操作における流動性
542
+
543
+ **調(ちょう)- Harmony**
544
+ - 純白の背景: 清潔で読みやすい基盤
545
+ - 水面の輝き: 美しいアクセントカラー
546
+ - 深い海: 信頼感のある主要アクション
547
+ - 中間の深さ: バランスの取れた境界
548
+ - 深海の静寂: 読みやすいテキスト
549
+ - ティールの調和: 優美なセカンダリアクション
550
+
551
+ **透(とう)- Transparency**
552
+ - 直感的で透明な操作性
553
+ - 水のような清らかさ
554
+ - 心地よいユーザー体験
555
+ - 海の広がりのような開放感
556
+
557
+ **和(わ)- Japanese Harmony**
558
+ - 日本の美意識との融合
559
+ - 水と技術の調和
560
+ - 現代と伝統の共存
561
+ - 心の安らぎを与える設計
562
+ """)
563
+
564
+ # デモコンポーネント
565
+ gr.Markdown("### 🛠️ WA-SUI コンポーネント実装")
566
+
567
+ with gr.Row():
568
+ demo_slider = gr.Slider(0, 100, 50, label="🌊 波の高さ")
569
+ demo_checkbox = gr.Checkbox(True, label="☑️ 海風を感じる")
570
+ demo_radio = gr.Radio(["凪", "波", "嵐"], label="📻 海の状態", value="波")
571
+
572
+ with gr.Row():
573
+ demo_dropdown = gr.Dropdown(["深海", "浅瀬", "潮だまり"], label="📋 海の深さ")
574
+ demo_number = gr.Number(label="🔢 波の数", value=108)
575
+ demo_textbox = gr.Textbox(label="📝 海への想い", placeholder="海のように広い心で...")
576
+
577
+ # ボタンバリエーション
578
+ gr.Markdown("### 🔘 WA-SUI アクション")
579
+ with gr.Row():
580
+ gr.Button("🌊 波を起こす", variant="primary")
581
+ gr.Button("💧 静寂にする", variant="secondary")
582
+ gr.Button("⛔ 嵐を止める", variant="stop")
583
+
584
+ # 海の音効果(デモ用)
585
+ gr.Markdown("### 🎵 海の音効果")
586
+ with gr.Row():
587
+ wave_sound = gr.Audio(label="🌊 波の音", interactive=False)
588
+ rain_sound = gr.Audio(label="☔ 雨の音", interactive=False)
589
+
590
+ gr.Markdown("""
591
+ ### 📚 WA-SUI 使用ガイド
592
+
593
+ **適用シーン:**
594
+ - 🏖️ 海辺のカフェ・レストラン
595
+ - 🏊‍♂️ フィットネス・スパアプリ
596
+ - 🧘‍♀️ 瞑想・リラクゼーションアプリ
597
+ - 🌊 海洋関連の教育アプリ
598
+ - 💧 水質管理システム
599
+
600
+ **デザイン原則:**
601
+ - 流れるような操作感
602
+ - 海の深さを表現した階層
603
+ - 水の透明感を活かしたレイアウト
604
+ - 日本的な美意識の組み込み
605
+ """)
606
+
607
+ return demo
608
 
609
+ # アプリケーションの実行
610
  if __name__ == "__main__":
611
+ print("WA-SUI(和水)- 海と水のテーマ UIコンポーネント集")
612
+ print("=" * 60)
613
+
614
+ app = create_comprehensive_demo()
615
+ app.launch(
616
+ share=True,
617
+ server_name="0.0.0.0",
618
+ server_port=7871,
619
+ show_error=True
620
+ )