Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ import tempfile
|
|
| 15 |
import time
|
| 16 |
import os
|
| 17 |
import logging
|
| 18 |
-
import
|
| 19 |
|
| 20 |
# 正しいGemini関連のインポート
|
| 21 |
import google.generativeai as genai
|
|
@@ -109,25 +109,25 @@ def enhance_font_awesome_layout(html_code):
|
|
| 109 |
return f'<html><head>{fa_fix_css}</head>' + html_code + '</html>'
|
| 110 |
|
| 111 |
def load_system_instruction():
|
| 112 |
-
"""HuggingFace
|
| 113 |
try:
|
| 114 |
-
#
|
| 115 |
-
logger.info("HuggingFace
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
|
| 129 |
except Exception as e:
|
| 130 |
-
#
|
| 131 |
error_msg = f"システムインストラクションの読み込みに失敗: {str(e)}"
|
| 132 |
logger.error(error_msg)
|
| 133 |
raise ValueError(error_msg)
|
|
|
|
| 15 |
import time
|
| 16 |
import os
|
| 17 |
import logging
|
| 18 |
+
from huggingface_hub import hf_hub_download # 追加: HuggingFace Hubからファイルを直接ダウンロード
|
| 19 |
|
| 20 |
# 正しいGemini関連のインポート
|
| 21 |
import google.generativeai as genai
|
|
|
|
| 109 |
return f'<html><head>{fa_fix_css}</head>' + html_code + '</html>'
|
| 110 |
|
| 111 |
def load_system_instruction():
|
| 112 |
+
"""HuggingFaceリポジトリからprompt.txtを直接ダウンロードして読み込む"""
|
| 113 |
try:
|
| 114 |
+
# ファイルを直接ダウンロード
|
| 115 |
+
logger.info("HuggingFaceリポジトリからprompt.txtをダウンロード中...")
|
| 116 |
+
file_path = hf_hub_download(
|
| 117 |
+
repo_id="tomo2chin2/GURAREKOstlyle",
|
| 118 |
+
filename="prompt.txt",
|
| 119 |
+
repo_type="dataset"
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# ファイルを読み込む
|
| 123 |
+
with open(file_path, 'r', encoding='utf-8') as file:
|
| 124 |
+
instruction = file.read()
|
| 125 |
+
|
| 126 |
+
logger.info(f"システムインストラクションを正常に読み込みました: {len(instruction)}バイト")
|
| 127 |
+
return instruction
|
| 128 |
|
| 129 |
except Exception as e:
|
| 130 |
+
# エラーが発生した場合
|
| 131 |
error_msg = f"システムインストラクションの読み込みに失敗: {str(e)}"
|
| 132 |
logger.error(error_msg)
|
| 133 |
raise ValueError(error_msg)
|