Update app.py
Browse files
app.py
CHANGED
@@ -161,10 +161,7 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
161 |
- ํ
์คํธ์ ์ผํ๊ฐ ์์ผ๋ฉด ํฐ๋ฐ์ดํ๋ก ๊ฐ์ธ๊ธฐ
|
162 |
- ํฐ๋ฐ์ดํ๋ ๋ฐฑ์ฌ๋์๋ก ์ด์ค์ผ์ดํ ์ฒ๋ฆฌ
|
163 |
- ๊ฐ ํ์ ์๋ก์ด ์ค๋ก ๊ตฌ๋ถ
|
164 |
-
- ๋ชจ๋ ํ๋๋ ์ผํ๋ก ๊ตฌ๋ถ
|
165 |
-
|
166 |
-
์
๋ ฅ ํ
์คํธ:
|
167 |
-
"""
|
168 |
|
169 |
full_prompt = f"{system_prompt}\n\n{input_text}\n\n์ถ๋ ฅ:"
|
170 |
|
@@ -172,8 +169,8 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
172 |
response = ""
|
173 |
stream = hf_client.text_generation(
|
174 |
prompt=full_prompt,
|
175 |
-
max_new_tokens=4000,
|
176 |
-
temperature=0.3,
|
177 |
top_p=0.9,
|
178 |
stream=True,
|
179 |
)
|
@@ -182,12 +179,14 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
182 |
if msg:
|
183 |
response += msg
|
184 |
|
185 |
-
#
|
186 |
-
|
|
|
|
|
|
|
187 |
|
188 |
# CSV ํ์ ๊ฒ์ฆ
|
189 |
try:
|
190 |
-
# StringIO๋ฅผ ์ฌ์ฉํ์ฌ CSV ํ์ ๊ฒ์ฆ
|
191 |
from io import StringIO
|
192 |
import csv
|
193 |
csv.reader(StringIO(processed_text))
|
@@ -196,7 +195,7 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
196 |
return "LLM์ด ์ฌ๋ฐ๋ฅธ CSV ํ์์ ์์ฑํ์ง ๋ชปํ์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์."
|
197 |
|
198 |
except Exception as e:
|
199 |
-
error_message = f"์ ์ฒ๋ฆฌ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}
|
200 |
print(error_message)
|
201 |
return error_message
|
202 |
|
|
|
161 |
- ํ
์คํธ์ ์ผํ๊ฐ ์์ผ๋ฉด ํฐ๋ฐ์ดํ๋ก ๊ฐ์ธ๊ธฐ
|
162 |
- ํฐ๋ฐ์ดํ๋ ๋ฐฑ์ฌ๋์๋ก ์ด์ค์ผ์ดํ ์ฒ๋ฆฌ
|
163 |
- ๊ฐ ํ์ ์๋ก์ด ์ค๋ก ๊ตฌ๋ถ
|
164 |
+
- ๋ชจ๋ ํ๋๋ ์ผํ๋ก ๊ตฌ๋ถ"""
|
|
|
|
|
|
|
165 |
|
166 |
full_prompt = f"{system_prompt}\n\n{input_text}\n\n์ถ๋ ฅ:"
|
167 |
|
|
|
169 |
response = ""
|
170 |
stream = hf_client.text_generation(
|
171 |
prompt=full_prompt,
|
172 |
+
max_new_tokens=4000,
|
173 |
+
temperature=0.3,
|
174 |
top_p=0.9,
|
175 |
stream=True,
|
176 |
)
|
|
|
179 |
if msg:
|
180 |
response += msg
|
181 |
|
182 |
+
# <EOS_TOKEN> ์ด์ ๊น์ง๋ง ์ถ์ถ
|
183 |
+
if "<EOS_TOKEN>" in response:
|
184 |
+
processed_text = response.split("<EOS_TOKEN>")[0].strip()
|
185 |
+
else:
|
186 |
+
processed_text = response.strip()
|
187 |
|
188 |
# CSV ํ์ ๊ฒ์ฆ
|
189 |
try:
|
|
|
190 |
from io import StringIO
|
191 |
import csv
|
192 |
csv.reader(StringIO(processed_text))
|
|
|
195 |
return "LLM์ด ์ฌ๋ฐ๋ฅธ CSV ํ์์ ์์ฑํ์ง ๋ชปํ์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์."
|
196 |
|
197 |
except Exception as e:
|
198 |
+
error_message = f"์ ์ฒ๋ฆฌ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
199 |
print(error_message)
|
200 |
return error_message
|
201 |
|