Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,31 @@ def generate_annotated_text(text):
|
|
31 |
)
|
32 |
return response['choices'][0]['message']['content']
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# Streamlit μ±μ μ λͺ© λ° μ€λͺ
|
37 |
st.title("μ±μ·¨κΈ°μ€ κΈ°λ° νμμ νΉμ± λ° νλ νκ° μμ±")
|
@@ -67,12 +91,18 @@ if st.button("νκ° μμ±"):
|
|
67 |
sentences = []
|
68 |
for line in result_lines:
|
69 |
if line.strip().startswith('("'):
|
70 |
-
# ("λ‘ μμνλ λΆλΆμ μ κ±°νκ³ λ¬Έμ₯λ§ μΆμΆ
|
71 |
sentence = line.split('",')[0].lstrip('("').strip()
|
72 |
sentences.append(sentence)
|
73 |
|
74 |
# λ¬Έμ₯μ λΌλμ€ λ²νΌμΌλ‘ νμ
|
75 |
selected_sentence = st.radio("λ¬Έμ₯μ μ ννμΈμ:", sentences)
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
|
|
|
31 |
)
|
32 |
return response['choices'][0]['message']['content']
|
33 |
|
34 |
+
#μ μ¬ν λ¬Έμ₯ μμ± ν¨μ
|
35 |
+
def generate_similar_sentences(base_sentence, num_sentences):
|
36 |
+
generated_sentences = []
|
37 |
+
for _ in range(num_sentences):
|
38 |
+
response = openai.ChatCompletion.create(
|
39 |
+
model="gpt-3.5-turbo-16k",
|
40 |
+
messages=[
|
41 |
+
{
|
42 |
+
"role": "system",
|
43 |
+
"content": "μ μ¬ν λ¬Έμ₯ μμ±\n μ νλ λ¬Έμ₯μ κΈ°λ°νμ¬ νμμ νΉμ± λ° νλμ λν νκ° μμ λ¬Έμ₯μ 30κ° μμ±ν©λλ€."
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"role": "user",
|
47 |
+
"content": base_sentence
|
48 |
+
}
|
49 |
+
],
|
50 |
+
temperature=1,
|
51 |
+
max_tokens=10000,
|
52 |
+
top_p=1,
|
53 |
+
frequency_penalty=0,
|
54 |
+
presence_penalty=0
|
55 |
+
)
|
56 |
+
generated_sentences.append(response.choices[0].message['content'].strip())
|
57 |
+
return generated_sentences
|
58 |
+
|
59 |
|
60 |
# Streamlit μ±μ μ λͺ© λ° μ€λͺ
|
61 |
st.title("μ±μ·¨κΈ°μ€ κΈ°λ° νμμ νΉμ± λ° νλ νκ° μμ±")
|
|
|
91 |
sentences = []
|
92 |
for line in result_lines:
|
93 |
if line.strip().startswith('("'):
|
|
|
94 |
sentence = line.split('",')[0].lstrip('("').strip()
|
95 |
sentences.append(sentence)
|
96 |
|
97 |
# λ¬Έμ₯μ λΌλμ€ λ²νΌμΌλ‘ νμ
|
98 |
selected_sentence = st.radio("λ¬Έμ₯μ μ ννμΈμ:", sentences)
|
99 |
|
100 |
+
# μ μ¬ν λ¬Έμ₯ μμ± λ²νΌ μΆκ°
|
101 |
+
if st.button("μ μ¬ν 문ꡬ μμ±"):
|
102 |
+
with st.spinner('λ¬Έμ₯ μμ±μ€...'):
|
103 |
+
similar_sentences = generate_similar_sentences(selected_sentence, 30)
|
104 |
+
for sentence in similar_sentences:
|
105 |
+
st.write(sentence)
|
106 |
+
|
107 |
|
108 |
|