Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +10 -19
streamlit_app.py
CHANGED
@@ -66,26 +66,17 @@ st.markdown("---")
|
|
66 |
# ์ฌ์ด๋๋ฐ ์ค์
|
67 |
st.sidebar.header("๐๏ธ ์นดํผ ์์ฑ ์ค์ ")
|
68 |
|
|
|
|
|
|
|
69 |
|
70 |
-
#
|
71 |
-
default_api_key = os.getenv("GEMINI_API_KEY", "")
|
72 |
-
|
73 |
-
# 2. st.sidebar.text_input์ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์์๊ฒ API ํค๋ฅผ ์
๋ ฅ๋ฐ๊ฑฐ๋,
|
74 |
-
# ํ๊ฒฝ๋ณ์์์ ๊ฐ์ ธ์จ ๊ฐ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋ณด์ฌ์ค
|
75 |
-
api_key_value = st.sidebar.text_input(
|
76 |
-
"๐ Gemini API ํค",
|
77 |
-
value=default_api_key,
|
78 |
-
type="password",
|
79 |
-
help="ํ๊ฒฝ๋ณ์์ GEMINI_API_KEY๋ก ์ค์ ํ๋ฉด ์๋ ์
๋ ฅ๋ฉ๋๋ค",
|
80 |
-
key="gemini_api_key_input"
|
81 |
-
)
|
82 |
-
|
83 |
-
# 3. ์ฌ์ฉ์๊ฐ ์
๋ ฅํ๊ฑฐ๋ ํ๊ฒฝ๋ณ์์์ ๊ฐ์ ธ์จ API ํค ๊ฐ์ ์ฌ์ฉ
|
84 |
if not api_key_value:
|
85 |
-
st.
|
86 |
-
st.info("
|
|
|
87 |
st.stop()
|
88 |
-
|
89 |
|
90 |
# ์์คํ
์ด๊ธฐํ (์บ์ฑ) - ์๋ฒ ๋ฉ ํ์!
|
91 |
@st.cache_resource(show_spinner=False)
|
@@ -337,7 +328,7 @@ def generate_copy_with_rag(user_req, category_filter, target_aud, brand_tn, crea
|
|
337 |
similarities = cosine_similarity(query_embedding, filtered_embeddings_for_search)[0]
|
338 |
num_to_select = min(num_references, len(similarities))
|
339 |
# numpy๋ฅผ ์ฌ๊ธฐ์ ๋ค์ ์ํฌํธํ์ฌ ์ฌ์ฉ (np ๋ณ์นญ ์ฌ์ฉ)
|
340 |
-
import numpy as np_generate_rag
|
341 |
top_similarity_indices = np_generate_rag.argsort(similarities)[::-1][:num_to_select]
|
342 |
|
343 |
reference_copies = []
|
@@ -490,4 +481,4 @@ if os.getenv("DEBUG_MODE") == "true":
|
|
490 |
st.sidebar.write("Numpy ๋ฒ์ (Global): Not imported or error")
|
491 |
|
492 |
# torch๋ ์ง์ ์ฌ์ฉํ์ง ์์ผ๋ฏ๋ก, sentence_transformers ๋ด๋ถ ๋ฒ์ ์ ์๊ธฐ๋ ์ด๋ ค์
|
493 |
-
st.sidebar.write(f"google-generativeai ๋ฒ์ : {genai.__version__}")
|
|
|
66 |
# ์ฌ์ด๋๋ฐ ์ค์
|
67 |
st.sidebar.header("๐๏ธ ์นดํผ ์์ฑ ์ค์ ")
|
68 |
|
69 |
+
# --- API ํค ์ฒ๋ฆฌ ๋ณ๊ฒฝ ---
|
70 |
+
# ํ๊ฒฝ๋ณ์์์ API ํค๋ฅผ ์ง์ ๊ฐ์ ธ์ต๋๋ค.
|
71 |
+
api_key_value = os.getenv("GEMINI_API_KEY")
|
72 |
|
73 |
+
# API ํค๊ฐ ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ ์ฑ ์ค๋จ ๋ฐ ์๋ด ๋ฉ์์ง ํ์
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
if not api_key_value:
|
75 |
+
st.error(" critical: ๐ GEMINI_API_KEY ํ๊ฒฝ ๋ณ์๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.")
|
76 |
+
st.info("Hugging Face Spaces์ 'Settings' -> 'Repository secrets'์์ 'GEMINI_API_KEY'๋ฅผ ์ถ๊ฐํด์ฃผ์ธ์.")
|
77 |
+
st.info("์ ํ๋ฆฌ์ผ์ด์
์ด ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ๋ ค๋ฉด API ํค๊ฐ ๋ฐ๋์ ํ์ํฉ๋๋ค.")
|
78 |
st.stop()
|
79 |
+
# --- API ํค ์ฒ๋ฆฌ ๋ณ๊ฒฝ ๋ ---
|
80 |
|
81 |
# ์์คํ
์ด๊ธฐํ (์บ์ฑ) - ์๋ฒ ๋ฉ ํ์!
|
82 |
@st.cache_resource(show_spinner=False)
|
|
|
328 |
similarities = cosine_similarity(query_embedding, filtered_embeddings_for_search)[0]
|
329 |
num_to_select = min(num_references, len(similarities))
|
330 |
# numpy๋ฅผ ์ฌ๊ธฐ์ ๋ค์ ์ํฌํธํ์ฌ ์ฌ์ฉ (np ๋ณ์นญ ์ฌ์ฉ)
|
331 |
+
import numpy as np_generate_rag
|
332 |
top_similarity_indices = np_generate_rag.argsort(similarities)[::-1][:num_to_select]
|
333 |
|
334 |
reference_copies = []
|
|
|
481 |
st.sidebar.write("Numpy ๋ฒ์ (Global): Not imported or error")
|
482 |
|
483 |
# torch๋ ์ง์ ์ฌ์ฉํ์ง ์์ผ๋ฏ๋ก, sentence_transformers ๋ด๋ถ ๋ฒ์ ์ ์๊ธฐ๋ ์ด๋ ค์
|
484 |
+
st.sidebar.write(f"google-generativeai ๋ฒ์ : {genai.__version__}")
|