Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,6 +81,8 @@ if 'selected_sentence' not in st.session_state:
|
|
81 |
st.session_state.selected_sentence = None
|
82 |
if 'similar_sentences' not in st.session_state:
|
83 |
st.session_state.similar_sentences = []
|
|
|
|
|
84 |
|
85 |
# "ํ๊ฐ ์์ฑ" ๋ฒํผ ํด๋ฆญ ์์ ๋์
|
86 |
if st.button("ํ๊ฐ ์์ฑ"):
|
@@ -101,10 +103,13 @@ if st.button("ํ๊ฐ ์์ฑ"):
|
|
101 |
sentences.append(sentence)
|
102 |
|
103 |
|
104 |
-
# ๋ฌธ์ฅ์ ๋ผ๋์ค ๋ฒํผ์ผ๋ก ํ์ ๋ฐ ์ ํ๋ ๋ฌธ์ฅ ์ ์ฅ
|
105 |
-
selected_index = st.radio("๋ฌธ์ฅ์ ์ ํํ์ธ์:", range(len(sentences)), format_func=lambda x: sentences[x])
|
106 |
-
st.session_state.selected_sentence = sentences[selected_index] if sentences else None
|
107 |
|
|
|
|
|
|
|
108 |
# # ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
109 |
# if st.button("์ ์ฌํ ๋ฌธ๊ตฌ ์์ฑ") and st.session_state.get('selected_sentence'):
|
110 |
# with st.spinner('๋ฌธ์ฅ ์์ฑ์ค...'):
|
@@ -112,14 +117,19 @@ if st.button("ํ๊ฐ ์์ฑ"):
|
|
112 |
# for sentence in st.session_state.similar_sentences:
|
113 |
# st.write(sentence)
|
114 |
|
115 |
-
# ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ
|
116 |
-
if st.
|
117 |
-
if st.
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
# ์์ฑ๋ ๊ฒฐ๊ณผ ๋ฐ ์ ์ฌํ ๋ฌธ์ฅ๋ค ์ถ๋ ฅ
|
122 |
if st.session_state.get('generated_result'):
|
123 |
exec(st.session_state.generated_result.replace('```', ''))
|
124 |
-
for sentence in st.session_state.similar_sentences:
|
125 |
st.write(sentence)
|
|
|
81 |
st.session_state.selected_sentence = None
|
82 |
if 'similar_sentences' not in st.session_state:
|
83 |
st.session_state.similar_sentences = []
|
84 |
+
if 'selected_index' not in st.session_state:
|
85 |
+
st.session_state.selected_index = 0
|
86 |
|
87 |
# "ํ๊ฐ ์์ฑ" ๋ฒํผ ํด๋ฆญ ์์ ๋์
|
88 |
if st.button("ํ๊ฐ ์์ฑ"):
|
|
|
103 |
sentences.append(sentence)
|
104 |
|
105 |
|
106 |
+
# # ๋ฌธ์ฅ์ ๋ผ๋์ค ๋ฒํผ์ผ๋ก ํ์ ๋ฐ ์ ํ๋ ๋ฌธ์ฅ ์ ์ฅ
|
107 |
+
# selected_index = st.radio("๋ฌธ์ฅ์ ์ ํํ์ธ์:", range(len(sentences)), format_func=lambda x: sentences[x])
|
108 |
+
# st.session_state.selected_sentence = sentences[selected_index] if sentences else None
|
109 |
|
110 |
+
#๋๋ฒ๊น
|
111 |
+
st.session_state.selected_index = st.radio("๋ฌธ์ฅ์ ์ ํํ์ธ์:", range(len(sentences)), format_func=lambda x: sentences[x], key="selected_index")
|
112 |
+
|
113 |
# # ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
114 |
# if st.button("์ ์ฌํ ๋ฌธ๊ตฌ ์์ฑ") and st.session_state.get('selected_sentence'):
|
115 |
# with st.spinner('๋ฌธ์ฅ ์์ฑ์ค...'):
|
|
|
117 |
# for sentence in st.session_state.similar_sentences:
|
118 |
# st.write(sentence)
|
119 |
|
120 |
+
# ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
121 |
+
if st.button("์ ์ฌํ ๋ฌธ๊ตฌ ์์ฑ"):
|
122 |
+
if st.session_state.get('generated_result'):
|
123 |
+
# annotated_text ๊ฒฐ๊ณผ์์ ๋ค์ ๋ฌธ์ฅ ์ถ์ถ
|
124 |
+
result_lines = st.session_state.generated_result.split('\n')
|
125 |
+
sentences = [line[start_idx + 2:line.find('",', start_idx)].strip() for line in result_lines if (start_idx := line.find('("')) != -1]
|
126 |
+
if sentences:
|
127 |
+
selected_sentence = sentences[st.session_state.selected_index]
|
128 |
+
with st.spinner('๋ฌธ์ฅ ์์ฑ์ค...'):
|
129 |
+
st.session_state.similar_sentences = generate_similar_sentences(selected_sentence)
|
130 |
|
131 |
# ์์ฑ๋ ๊ฒฐ๊ณผ ๋ฐ ์ ์ฌํ ๋ฌธ์ฅ๋ค ์ถ๋ ฅ
|
132 |
if st.session_state.get('generated_result'):
|
133 |
exec(st.session_state.generated_result.replace('```', ''))
|
134 |
+
for sentence in st.session_state.get('similar_sentences', []):
|
135 |
st.write(sentence)
|