ginipick commited on
Commit
ad98527
ยท
verified ยท
1 Parent(s): 7886a98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -46
app.py CHANGED
@@ -1057,52 +1057,7 @@ async def enhance_text_with_ai(text_content: str, title: str) -> str:
1057
  # ์›๋ณธ ํ…์ŠคํŠธ ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜ (AI ํ–ฅ์ƒ ๊ธฐ๋Šฅ ๋น„ํ™œ์„ฑํ™”)
1058
  return text_content
1059
 
1060
-
1061
- # ์ปจํ…์ŠคํŠธ ํฌ๊ธฐ๋ฅผ ๊ณ ๋ คํ•˜์—ฌ ํ…์ŠคํŠธ๊ฐ€ ๋„ˆ๋ฌด ๊ธธ๋ฉด ์•ž๋ถ€๋ถ„๋งŒ ์‚ฌ์šฉ
1062
- max_context_length = 60000
1063
- if len(text_content) > max_context_length:
1064
- text_to_process = text_content[:max_context_length] + "...(์ดํ•˜ ์ƒ๋žต)"
1065
- else:
1066
- text_to_process = text_content
1067
-
1068
- # OpenAI API ํ˜ธ์ถœํ•˜์—ฌ ํ…์ŠคํŠธ ๊ตฌ์กฐํ™”
1069
- try:
1070
- system_prompt = """
1071
- ๋‹น์‹ ์€ ํ…์ŠคํŠธ๋ฅผ ์ž˜ ๊ตฌ์กฐํ™”๋œ ์ „์ž์ฑ… ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค.
1072
- ์ œ๊ณต๋œ ์›๋ณธ ํ…์ŠคํŠธ๋ฅผ ๋ถ„์„ํ•˜๊ณ , ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐœ์„ ํ•ด์ฃผ์„ธ์š”:
1073
-
1074
- 1. ๋…ผ๋ฆฌ์ ์ธ ์„น์…˜์œผ๋กœ ๋‚˜๋ˆ„๊ณ  ์ ์ ˆํ•œ ์ œ๋ชฉ๊ณผ ๋ถ€์ œ๋ชฉ ์ถ”๊ฐ€
1075
- 2. ๋‹จ๋ฝ์„ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๊ตฌ์„ฑํ•˜๊ณ  ๊ฐ€๋…์„ฑ ๊ฐœ์„ 
1076
- 3. ์ค‘์š”ํ•œ ๋‚ด์šฉ์€ ๊ฐ•์กฐํ•˜๊ฑฐ๋‚˜ ์š”์•ฝํ•˜์—ฌ ํ‘œ์‹œ
1077
- 4. ์›๋ณธ ๋‚ด์šฉ์˜ ์˜๋ฏธ์™€ ๋งฅ๋ฝ์€ ์œ ์ง€ํ•˜๋ฉด์„œ ๊น”๋”ํ•˜๊ฒŒ ์ •๋ฆฌ
1078
- 5. ๋งž์ถค๋ฒ•๊ณผ ๋ฌธ๋ฒ• ์˜ค๋ฅ˜ ์ˆ˜์ •
1079
-
1080
- ์›๋ณธ ๋‚ด์šฉ์„ ๋ชจ๋‘ ์œ ์ง€ํ•˜๋˜, ์ž˜ ์ •๋ฆฌ๋œ ์ „์ž์ฑ…์ฒ˜๋Ÿผ ๋ณด์ด๋„๋ก ๊ตฌ์กฐํ™”ํ•ด์ฃผ์„ธ์š”.
1081
- ์ˆ˜์ •๋ณธ์„ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•˜๊ณ , ์›๋ณธ ๋‚ด์šฉ์„ ๋ชจ๋‘ ํฌํ•จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
1082
- """
1083
-
1084
- response = openai_client.chat.completions.create(
1085
- model="gpt-4.1-mini",
1086
- messages=[
1087
- {"role": "system", "content": system_prompt},
1088
- {"role": "user", "content": f"์ œ๋ชฉ: {title}\n\n์›๋ณธ ํ…์ŠคํŠธ:\n{text_to_process}"}
1089
- ],
1090
- temperature=0.7,
1091
- max_tokens=4000,
1092
- timeout=60.0
1093
- )
1094
-
1095
- enhanced_text = response.choices[0].message.content
1096
- return enhanced_text
1097
-
1098
- except Exception as api_error:
1099
- logger.error(f"AI ํ…์ŠคํŠธ ํ–ฅ์ƒ ์˜ค๋ฅ˜: {api_error}")
1100
- # ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ์›๋ณธ ํ…์ŠคํŠธ ๋ฐ˜ํ™˜
1101
- return text_content
1102
-
1103
- except Exception as e:
1104
- logger.error(f"AI ํ…์ŠคํŠธ ํ–ฅ์ƒ ์˜ค๋ฅ˜: {e}")
1105
- return text_content
1106
 
1107
  # ํ…์ŠคํŠธ ํŒŒ์ผ์„ PDF๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์—”๋“œํฌ์ธํŠธ
1108
  @app.post("/api/text-to-pdf")
 
1057
  # ์›๋ณธ ํ…์ŠคํŠธ ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜ (AI ํ–ฅ์ƒ ๊ธฐ๋Šฅ ๋น„ํ™œ์„ฑํ™”)
1058
  return text_content
1059
 
1060
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1061
 
1062
  # ํ…์ŠคํŠธ ํŒŒ์ผ์„ PDF๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์—”๋“œํฌ์ธํŠธ
1063
  @app.post("/api/text-to-pdf")