DeL-TaiseiOzaki
commited on
Commit
·
54c69b5
1
Parent(s):
560aacd
app.py
CHANGED
@@ -75,6 +75,9 @@ with st.sidebar:
|
|
75 |
st.stop()
|
76 |
|
77 |
st.write("Using Claude model")
|
|
|
|
|
|
|
78 |
|
79 |
st.divider()
|
80 |
st.subheader("📌 使い方")
|
@@ -82,6 +85,9 @@ with st.sidebar:
|
|
82 |
1. GitHubリポジトリのURLを入力
|
83 |
2. スキャンを実行
|
84 |
3. コードについて質問(最大5ターンの会話が可能)
|
|
|
|
|
|
|
85 |
""")
|
86 |
|
87 |
st.subheader("🔍 スキャン対象")
|
@@ -124,38 +130,38 @@ if st.button("スキャン開始", disabled=not repo_url):
|
|
124 |
except Exception as e:
|
125 |
st.error(f"エラーが発生しました: {str(e)}")
|
126 |
|
127 |
-
if st.session_state.repo_content:
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
if st.session_state.temp_dir and Path(st.session_state.temp_dir).exists():
|
161 |
try:
|
|
|
75 |
st.stop()
|
76 |
|
77 |
st.write("Using Claude model")
|
78 |
+
|
79 |
+
# LLM機能の切り替え
|
80 |
+
use_llm = st.toggle("LLMによるコード解説を有効にする", value=True, key="use_llm")
|
81 |
|
82 |
st.divider()
|
83 |
st.subheader("📌 使い方")
|
|
|
85 |
1. GitHubリポジトリのURLを入力
|
86 |
2. スキャンを実行
|
87 |
3. コードについて質問(最大5ターンの会話が可能)
|
88 |
+
""") if use_llm else st.markdown("""
|
89 |
+
1. GitHubリポジトリのURLを入力
|
90 |
+
2. スキャンを実行してコードを解析
|
91 |
""")
|
92 |
|
93 |
st.subheader("🔍 スキャン対象")
|
|
|
130 |
except Exception as e:
|
131 |
st.error(f"エラーが発生しました: {str(e)}")
|
132 |
|
133 |
+
if st.session_state.repo_content and st.session_state.use_llm:
|
134 |
+
st.divider()
|
135 |
+
st.subheader("💭 コードについて質問する")
|
136 |
+
|
137 |
+
for message in st.session_state.llm_service.conversation_history:
|
138 |
+
if message.role == "assistant":
|
139 |
+
st.markdown(f'<div class="chat-message assistant-message">{message.content}</div>',
|
140 |
+
unsafe_allow_html=True)
|
141 |
+
|
142 |
+
query = st.text_area(
|
143 |
+
"質問を入力してください",
|
144 |
+
placeholder="例: このコードの主な機能は何ですか?"
|
145 |
+
)
|
146 |
+
|
147 |
+
col1, col2 = st.columns([1, 5])
|
148 |
+
with col1:
|
149 |
+
if st.button("履歴クリア"):
|
150 |
+
st.session_state.llm_service.clear_history()
|
151 |
+
st.rerun()
|
152 |
+
|
153 |
+
with col2:
|
154 |
+
if st.button("質問する", disabled=not query):
|
155 |
+
with st.spinner('回答を生成中...'):
|
156 |
+
response, error = st.session_state.llm_service.get_response(
|
157 |
+
st.session_state.repo_content,
|
158 |
+
query
|
159 |
+
)
|
160 |
+
|
161 |
+
if error:
|
162 |
+
st.error(error)
|
163 |
+
else:
|
164 |
+
st.rerun()
|
165 |
|
166 |
if st.session_state.temp_dir and Path(st.session_state.temp_dir).exists():
|
167 |
try:
|