JUNGU commited on
Commit
db341eb
Β·
1 Parent(s): fc78741

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -2
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