ginipick commited on
Commit
8871a08
ยท
verified ยท
1 Parent(s): b50c10b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -144,6 +144,7 @@ def text_to_parquet(text: str) -> Tuple[str, str, str]:
144
  print(error_message)
145
  return error_message, "", ""
146
 
 
147
  def preprocess_text_with_llm(input_text: str) -> str:
148
  if not input_text.strip():
149
  return "์ž…๋ ฅ ํ…์ŠคํŠธ๊ฐ€ ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค."
@@ -162,32 +163,23 @@ def preprocess_text_with_llm(input_text: str) -> str:
162
  - ํฐ๋”ฐ์˜ดํ‘œ๋Š” ๋ฐฑ์Šฌ๋ž˜์‹œ๋กœ ์ด์Šค์ผ€์ดํ”„ ์ฒ˜๋ฆฌ
163
  - ๊ฐ ํ–‰์€ ์ƒˆ๋กœ์šด ์ค„๋กœ ๊ตฌ๋ถ„
164
  - ๋ชจ๋“  ํ•„๋“œ๋Š” ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„
165
-
166
- ์ž…๋ ฅ ํ…์ŠคํŠธ:
167
  """
168
 
169
- full_prompt = f"{system_prompt}\n\n{input_text}\n\n์ถœ๋ ฅ:"
170
-
171
  try:
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
  )
180
 
181
- for msg in stream:
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))
@@ -200,6 +192,7 @@ def preprocess_text_with_llm(input_text: str) -> str:
200
  print(error_message)
201
  return error_message
202
 
 
203
  # CSS ์„ค์ •
204
  css = """
205
  footer {
 
144
  print(error_message)
145
  return error_message, "", ""
146
 
147
+
148
  def preprocess_text_with_llm(input_text: str) -> str:
149
  if not input_text.strip():
150
  return "์ž…๋ ฅ ํ…์ŠคํŠธ๊ฐ€ ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค."
 
163
  - ํฐ๋”ฐ์˜ดํ‘œ๋Š” ๋ฐฑ์Šฌ๋ž˜์‹œ๋กœ ์ด์Šค์ผ€์ดํ”„ ์ฒ˜๋ฆฌ
164
  - ๊ฐ ํ–‰์€ ์ƒˆ๋กœ์šด ์ค„๋กœ ๊ตฌ๋ถ„
165
  - ๋ชจ๋“  ํ•„๋“œ๋Š” ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„
166
+ - <EOS_TOKEN>์ด๋‚˜ ๋ถˆํ•„์š”ํ•œ ํ…์ŠคํŠธ๋Š” ์ œ๊ฑฐ
 
167
  """
168
 
 
 
169
  try:
170
+ response = hf_client.text_generation(
171
+ prompt=f"{system_prompt}\n\n{input_text}\n\n์ถœ๋ ฅ:",
172
+ max_new_tokens=4000,
173
+ temperature=0.3,
 
174
  top_p=0.9,
175
+ stream=False
176
  )
177
 
178
+ # ์‘๋‹ต์—์„œ <EOS_TOKEN> ์ด์ „๊นŒ์ง€๋งŒ ์ถ”์ถœ
179
+ processed_text = response.split("<EOS_TOKEN>")[0].strip()
 
 
 
 
180
 
181
  # CSV ํ˜•์‹ ๊ฒ€์ฆ
182
  try:
 
183
  from io import StringIO
184
  import csv
185
  csv.reader(StringIO(processed_text))
 
192
  print(error_message)
193
  return error_message
194
 
195
+
196
  # CSS ์„ค์ •
197
  css = """
198
  footer {