fantaxy commited on
Commit
2a768e3
ยท
verified ยท
1 Parent(s): ea001e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -150,15 +150,20 @@ def suggest_title(category, style, topic, references1, references2, references3)
150
  max_tokens = 5000
151
  temperature = 0.8
152
  top_p = 0.95
153
- combined_prompt = f"{category_prompt}\n\n{style_prompt}\n\n์ถ”๊ฐ€ ์ง€์‹œ์‚ฌํ•ญ: ์ ˆ๋Œ€๋กœ ์ œ๋ชฉ ์•ž์— ๋ฒˆํ˜ธ๋ฅผ ๋ถ™์ด์ง€ ๋งˆ์„ธ์š”."
154
  modified_text, input_tokens, output_tokens, total_tokens = call_api(full_content, combined_prompt, max_tokens, temperature, top_p)
155
 
156
  # ๋ฒˆํ˜ธ์™€ ์ (.)์„ ์ œ๊ฑฐํ•˜๊ณ  ๊ฐ ์ค„์„ ์ •๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
157
  titles = [line.strip() for line in modified_text.split('\n') if line.strip()]
158
  titles = [re.sub(r'^\d+\.\s*', '', title) for title in titles]
159
 
 
 
 
160
  token_usage_message = f"[์ž…๋ ฅ ํ† ํฐ์ˆ˜: {input_tokens}]\n[์ถœ๋ ฅ ํ† ํฐ์ˆ˜: {output_tokens}]\n[์ด ํ† ํฐ์ˆ˜: {total_tokens}]"
161
  return "\n".join(titles), token_usage_message
 
 
162
 
163
  def process_all_titles(category, style, topic):
164
  # ์ œ๋ชฉ ์ถ”์ฒœ
@@ -627,6 +632,9 @@ def process_all_titles(category, style, topic, num_titles):
627
 
628
  # ๋นˆ ๋ฌธ์ž์—ด์ด๋‚˜ '###' ๋“ฑ์˜ ๋ถˆํ•„์š”ํ•œ ๋ฌธ์ž์—ด ์ œ๊ฑฐ
629
  titles = [title.strip() for title in titles if title.strip() and not title.strip().startswith('###')]
 
 
 
630
 
631
  results = []
632
  for title in titles[:num_titles]:
 
150
  max_tokens = 5000
151
  temperature = 0.8
152
  top_p = 0.95
153
+ combined_prompt = f"{category_prompt}\n\n{style_prompt}\n\n์ถ”๊ฐ€ ์ง€์‹œ์‚ฌํ•ญ: ์ ˆ๋Œ€๋กœ ์ œ๋ชฉ์— '๋ธ”๋กœ๊ทธ'๋‚˜ '์ œ๋ชฉ'์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ํฌํ•จํ•˜์ง€ ๋งˆ์„ธ์š”. ๊ฐ ์ œ์•ˆ์€ ์‹ค์ œ ํฌ์ŠคํŠธ ์ œ๋ชฉ์œผ๋กœ ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค."
154
  modified_text, input_tokens, output_tokens, total_tokens = call_api(full_content, combined_prompt, max_tokens, temperature, top_p)
155
 
156
  # ๋ฒˆํ˜ธ์™€ ์ (.)์„ ์ œ๊ฑฐํ•˜๊ณ  ๊ฐ ์ค„์„ ์ •๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
157
  titles = [line.strip() for line in modified_text.split('\n') if line.strip()]
158
  titles = [re.sub(r'^\d+\.\s*', '', title) for title in titles]
159
 
160
+ # "๋ธ”๋กœ๊ทธ"์™€ "์ œ๋ชฉ"์ด๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ํฌํ•จ๋œ ์ œ๋ชฉ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.
161
+ titles = [title for title in titles if "๋ธ”๋กœ๊ทธ" not in title and "์ œ๋ชฉ" not in title]
162
+
163
  token_usage_message = f"[์ž…๋ ฅ ํ† ํฐ์ˆ˜: {input_tokens}]\n[์ถœ๋ ฅ ํ† ํฐ์ˆ˜: {output_tokens}]\n[์ด ํ† ํฐ์ˆ˜: {total_tokens}]"
164
  return "\n".join(titles), token_usage_message
165
+
166
+
167
 
168
  def process_all_titles(category, style, topic):
169
  # ์ œ๋ชฉ ์ถ”์ฒœ
 
632
 
633
  # ๋นˆ ๋ฌธ์ž์—ด์ด๋‚˜ '###' ๋“ฑ์˜ ๋ถˆํ•„์š”ํ•œ ๋ฌธ์ž์—ด ์ œ๊ฑฐ
634
  titles = [title.strip() for title in titles if title.strip() and not title.strip().startswith('###')]
635
+
636
+ # "๋ธ”๋กœ๊ทธ"์™€ "์ œ๋ชฉ"์ด๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ํฌํ•จ๋œ ์ œ๋ชฉ์„ ์ œ๊ฑฐ
637
+ titles = [title for title in titles if "๋ธ”๋กœ๊ทธ" not in title and "์ œ๋ชฉ" not in title]
638
 
639
  results = []
640
  for title in titles[:num_titles]: