tomo2chin2 commited on
Commit
36e642f
·
verified ·
1 Parent(s): e1112dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -27
app.py CHANGED
@@ -52,40 +52,40 @@ def enhance_font_awesome_layout(html_code):
52
  margin-right: 8px !important;
53
  vertical-align: middle !important;
54
  }
55
-
56
  /* テキスト内のアイコン位置調整 */
57
- h1 [class*="fa-"], h2 [class*="fa-"], h3 [class*="fa-"],
58
  h4 [class*="fa-"], h5 [class*="fa-"], h6 [class*="fa-"] {
59
  vertical-align: middle !important;
60
  margin-right: 10px !important;
61
  }
62
-
63
  /* 特定パターンの修正 */
64
  .fa + span, .fas + span, .far + span, .fab + span,
65
  span + .fa, span + .fas, span + .far + span {
66
  display: inline-block !important;
67
  margin-left: 5px !important;
68
  }
69
-
70
  /* カード内アイコン修正 */
71
  .card [class*="fa-"], .card-body [class*="fa-"] {
72
  float: none !important;
73
  clear: none !important;
74
  position: relative !important;
75
  }
76
-
77
  /* アイコンと文字が重なる場合の調整 */
78
  li [class*="fa-"], p [class*="fa-"] {
79
  margin-right: 10px !important;
80
  }
81
-
82
  /* インラインアイコンのスペーシング */
83
  .inline-icon {
84
  display: inline-flex !important;
85
  align-items: center !important;
86
  justify-content: flex-start !important;
87
  }
88
-
89
  /* アイコン後のテキスト */
90
  [class*="fa-"] + span {
91
  display: inline-block !important;
@@ -187,7 +187,6 @@ def generate_html_from_text(text, temperature=0.3, style="standard"):
187
  raise ValueError("GEMINI_API_KEY 環境変数が設定されていません")
188
 
189
  # モデル名の取得(環境変数から、なければデフォルト値)
190
- # ユーザーの要望通り、デフォルト値は gemini-1.5-pro のままにし、環境変数で指定されたモデルを使用する
191
  model_name = os.environ.get("GEMINI_MODEL", "gemini-1.5-pro")
192
  logger.info(f"使用するGeminiモデル: {model_name}")
193
 
@@ -236,23 +235,11 @@ def generate_html_from_text(text, temperature=0.3, style="standard"):
236
  prompt = f"{system_instruction}\n\n{text}"
237
 
238
  # コンテンツ生成
239
- # モデルが gemini-2.5-flash-preview-04-17 の場合のみ thinking_budget=0 を tool_config に含める
240
- if model_name == "gemini-2.5-flash-preview-04-17":
241
- logger.info(f"使用モデルが {model_name} なので tool_config に thinking_budget=0 を追加します。")
242
- response = model.generate_content(
243
- prompt,
244
- generation_config=generation_config,
245
- safety_settings=safety_settings,
246
- tool_config={"code_execution": {"enable": True, "thinking_budget": 0}}
247
- )
248
- else:
249
- logger.info(f"使用モデルが {model_name} なので thinking_budget は追加しません。")
250
- response = model.generate_content(
251
- prompt,
252
- generation_config=generation_config,
253
- safety_settings=safety_settings
254
- )
255
-
256
 
257
  # レスポンスからHTMLを抽出
258
  raw_response = response.text
@@ -782,7 +769,6 @@ with gr.Blocks(title="Full Page Screenshot (テキスト変換対応)", theme=gr
782
  )
783
 
784
  # 環境変数情報を表示
785
- # デフォルトは gemini-1.5-pro のままにし、環境変数で指定されたモデルが表示されるようにする
786
  gemini_model = os.environ.get("GEMINI_MODEL", "gemini-1.5-pro")
787
  gr.Markdown(f"""
788
  ## APIエンドポイント
@@ -801,4 +787,4 @@ app = gr.mount_gradio_app(app, iface, path="/")
801
  if __name__ == "__main__":
802
  import uvicorn
803
  logger.info("Starting Uvicorn server for local development...")
804
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
52
  margin-right: 8px !important;
53
  vertical-align: middle !important;
54
  }
55
+
56
  /* テキスト内のアイコン位置調整 */
57
+ h1 [class*="fa-"], h2 [class*="fa-"], h3 [class*="fa-"],
58
  h4 [class*="fa-"], h5 [class*="fa-"], h6 [class*="fa-"] {
59
  vertical-align: middle !important;
60
  margin-right: 10px !important;
61
  }
62
+
63
  /* 特定パターンの修正 */
64
  .fa + span, .fas + span, .far + span, .fab + span,
65
  span + .fa, span + .fas, span + .far + span {
66
  display: inline-block !important;
67
  margin-left: 5px !important;
68
  }
69
+
70
  /* カード内アイコン修正 */
71
  .card [class*="fa-"], .card-body [class*="fa-"] {
72
  float: none !important;
73
  clear: none !important;
74
  position: relative !important;
75
  }
76
+
77
  /* アイコンと文字が重なる場合の調整 */
78
  li [class*="fa-"], p [class*="fa-"] {
79
  margin-right: 10px !important;
80
  }
81
+
82
  /* インラインアイコンのスペーシング */
83
  .inline-icon {
84
  display: inline-flex !important;
85
  align-items: center !important;
86
  justify-content: flex-start !important;
87
  }
88
+
89
  /* アイコン後のテキスト */
90
  [class*="fa-"] + span {
91
  display: inline-block !important;
 
187
  raise ValueError("GEMINI_API_KEY 環境変数が設定されていません")
188
 
189
  # モデル名の取得(環境変数から、なければデフォルト値)
 
190
  model_name = os.environ.get("GEMINI_MODEL", "gemini-1.5-pro")
191
  logger.info(f"使用するGeminiモデル: {model_name}")
192
 
 
235
  prompt = f"{system_instruction}\n\n{text}"
236
 
237
  # コンテンツ生成
238
+ response = model.generate_content(
239
+ prompt,
240
+ generation_config=generation_config,
241
+ safety_settings=safety_settings
242
+ )
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
  # レスポンスからHTMLを抽出
245
  raw_response = response.text
 
769
  )
770
 
771
  # 環境変数情報を表示
 
772
  gemini_model = os.environ.get("GEMINI_MODEL", "gemini-1.5-pro")
773
  gr.Markdown(f"""
774
  ## APIエンドポイント
 
787
  if __name__ == "__main__":
788
  import uvicorn
789
  logger.info("Starting Uvicorn server for local development...")
790
+ uvicorn.run(app, host="0.0.0.0", port=7860)