ginipick commited on
Commit
12e6818
ยท
verified ยท
1 Parent(s): b3be69b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
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
- processed_text = response.strip()
 
 
 
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)}\n{traceback.format_exc()}"
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