Spaces:
Sleeping
Sleeping
DeL-TaiseiOzaki
commited on
Commit
·
31a278f
1
Parent(s):
b545e4b
結果のダウロード機能追加
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ from core.file_scanner import FileScanner
|
|
| 5 |
from pathlib import Path
|
| 6 |
from datetime import datetime
|
| 7 |
from services.llm_service import LLMService
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# ページ設定
|
| 10 |
st.set_page_config(
|
|
@@ -47,6 +49,18 @@ def clone_repository(repo_url: str) -> Path:
|
|
| 47 |
git.Repo.clone_from(repo_url, temp_dir)
|
| 48 |
return temp_dir
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# セッション状態の初期化
|
| 51 |
if 'repo_content' not in st.session_state:
|
| 52 |
st.session_state.repo_content = None
|
|
@@ -101,6 +115,15 @@ if st.button("スキャン開始", disabled=not repo_url):
|
|
| 101 |
if st.session_state.repo_content:
|
| 102 |
st.divider()
|
| 103 |
st.subheader("💭 コードについて質問する")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# 会話履歴の表示(アシスタントの回答のみ)
|
| 106 |
for message in st.session_state.llm_service.conversation_history:
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
from datetime import datetime
|
| 7 |
from services.llm_service import LLMService
|
| 8 |
+
from core.file_scanner import FileInfo
|
| 9 |
+
from typing import List
|
| 10 |
|
| 11 |
# ページ設定
|
| 12 |
st.set_page_config(
|
|
|
|
| 49 |
git.Repo.clone_from(repo_url, temp_dir)
|
| 50 |
return temp_dir
|
| 51 |
|
| 52 |
+
def create_download_content(files: List[FileInfo]) -> str:
|
| 53 |
+
content = "# スキャン結果\n\n"
|
| 54 |
+
for file in files:
|
| 55 |
+
content += f"## {file.path}\n"
|
| 56 |
+
content += f"サイズ: {file.formatted_size}\n"
|
| 57 |
+
content += f"エンコーディング: {file.encoding or '不明'}\n\n"
|
| 58 |
+
if file.content:
|
| 59 |
+
content += f"```{file.extension[1:] if file.extension else ''}\n"
|
| 60 |
+
content += file.content
|
| 61 |
+
content += "\n```\n\n"
|
| 62 |
+
return content
|
| 63 |
+
|
| 64 |
# セッション状態の初期化
|
| 65 |
if 'repo_content' not in st.session_state:
|
| 66 |
st.session_state.repo_content = None
|
|
|
|
| 115 |
if st.session_state.repo_content:
|
| 116 |
st.divider()
|
| 117 |
st.subheader("💭 コードについて質問する")
|
| 118 |
+
|
| 119 |
+
# スキャン結果のダウンロードボタン
|
| 120 |
+
scan_result = create_download_content(files) # filesはスキャン結果
|
| 121 |
+
st.download_button(
|
| 122 |
+
label="スキャン結果をダウンロード",
|
| 123 |
+
data=scan_result,
|
| 124 |
+
file_name=f"scan_result_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md",
|
| 125 |
+
mime="text/markdown"
|
| 126 |
+
)
|
| 127 |
|
| 128 |
# 会話履歴の表示(アシスタントの回答のみ)
|
| 129 |
for message in st.session_state.llm_service.conversation_history:
|