Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# ============================================================
|
| 2 |
-
# π¦ SME Credit Risk Assessment
|
| 3 |
# Final Project | AI Engineering Bootcamp Batch 10
|
| 4 |
# Author: 1na37
|
| 5 |
# ============================================================
|
|
@@ -282,19 +282,19 @@ with st.sidebar:
|
|
| 282 |
)
|
| 283 |
st.markdown("---")
|
| 284 |
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
st.
|
| 298 |
|
| 299 |
st.markdown("---")
|
| 300 |
st.markdown(T('sidebar_stack', lang))
|
|
@@ -306,40 +306,6 @@ with st.sidebar:
|
|
| 306 |
st.markdown(stack_items[lang])
|
| 307 |
st.caption(T('sidebar_footer', lang))
|
| 308 |
|
| 309 |
-
# ============================================================
|
| 310 |
-
# AMBIL API KEY
|
| 311 |
-
# ============================================================
|
| 312 |
-
def _get_key(session_key: str, secret_name: str) -> str:
|
| 313 |
-
manual = st.session_state.get(session_key, "")
|
| 314 |
-
if isinstance(manual, str) and manual.strip():
|
| 315 |
-
return manual.strip()
|
| 316 |
-
return _read_secret(secret_name)
|
| 317 |
-
|
| 318 |
-
openrouter_key = _get_key("or_manual_input", "OPENROUTER_API_KEY")
|
| 319 |
-
gemini_key = _get_key("gem_manual_input", "GEMINI_API_KEY")
|
| 320 |
-
groq_key = _get_key("groq_manual_input", "GROQ_API_KEY")
|
| 321 |
-
|
| 322 |
-
def _key_source(session_key, secret_name):
|
| 323 |
-
manual = st.session_state.get(session_key, "")
|
| 324 |
-
if isinstance(manual, str) and manual.strip():
|
| 325 |
-
return "β
manual"
|
| 326 |
-
try:
|
| 327 |
-
if st.secrets[secret_name]:
|
| 328 |
-
return "β
secret"
|
| 329 |
-
except Exception:
|
| 330 |
-
pass
|
| 331 |
-
if os.environ.get(secret_name, ""):
|
| 332 |
-
return "β
env"
|
| 333 |
-
return "β"
|
| 334 |
-
|
| 335 |
-
with st.sidebar:
|
| 336 |
-
st.markdown("---")
|
| 337 |
-
st.caption(
|
| 338 |
-
f"π OR: {_key_source('or_manual_input','OPENROUTER_API_KEY')} "
|
| 339 |
-
f"Gem: {_key_source('gem_manual_input','GEMINI_API_KEY')} "
|
| 340 |
-
f"Groq: {_key_source('groq_manual_input','GROQ_API_KEY')}"
|
| 341 |
-
)
|
| 342 |
-
|
| 343 |
# ============================================================
|
| 344 |
# LOAD MODEL & RAG
|
| 345 |
# ============================================================
|
|
|
|
| 1 |
# ============================================================
|
| 2 |
+
# π¦ SME Credit Risk Assessment
|
| 3 |
# Final Project | AI Engineering Bootcamp Batch 10
|
| 4 |
# Author: 1na37
|
| 5 |
# ============================================================
|
|
|
|
| 282 |
)
|
| 283 |
st.markdown("---")
|
| 284 |
|
| 285 |
+
# Baca API key langsung dari secrets
|
| 286 |
+
openrouter_key = _read_secret("OPENROUTER_API_KEY")
|
| 287 |
+
gemini_key = _read_secret("GEMINI_API_KEY")
|
| 288 |
+
groq_key = _read_secret("GROQ_API_KEY")
|
| 289 |
+
|
| 290 |
+
# Tampilkan status key (β
/β)
|
| 291 |
+
st.caption(
|
| 292 |
+
f"π **OpenRouter:** {'β
' if openrouter_key else 'β'} "
|
| 293 |
+
f"**Gemini:** {'β
' if gemini_key else 'β'} "
|
| 294 |
+
f"**Groq:** {'β
' if groq_key else 'β'}"
|
| 295 |
+
)
|
| 296 |
+
if not any([openrouter_key, gemini_key, groq_key]):
|
| 297 |
+
st.warning("β οΈ Tidak ada API key terdeteksi. Chat akan menggunakan fallback.")
|
| 298 |
|
| 299 |
st.markdown("---")
|
| 300 |
st.markdown(T('sidebar_stack', lang))
|
|
|
|
| 306 |
st.markdown(stack_items[lang])
|
| 307 |
st.caption(T('sidebar_footer', lang))
|
| 308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
# ============================================================
|
| 310 |
# LOAD MODEL & RAG
|
| 311 |
# ============================================================
|