ginipick commited on
Commit
b25fdc4
β€’
1 Parent(s): 8871a08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -162,21 +162,26 @@ def preprocess_text_with_llm(input_text: str) -> str:
162
  - ν…μŠ€νŠΈμ— μ‰Όν‘œκ°€ 있으면 ν°λ”°μ˜΄ν‘œλ‘œ 감싸기
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:
@@ -188,7 +193,7 @@ def preprocess_text_with_llm(input_text: str) -> str:
188
  return "LLM이 μ˜¬λ°”λ₯Έ CSV ν˜•μ‹μ„ μƒμ„±ν•˜μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•΄μ£Όμ„Έμš”."
189
 
190
  except Exception as e:
191
- error_message = f"μ „μ²˜λ¦¬ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}\n{traceback.format_exc()}"
192
  print(error_message)
193
  return error_message
194
 
 
162
  - ν…μŠ€νŠΈμ— μ‰Όν‘œκ°€ 있으면 ν°λ”°μ˜΄ν‘œλ‘œ 감싸기
163
  - ν°λ”°μ˜΄ν‘œλŠ” λ°±μŠ¬λž˜μ‹œλ‘œ μ΄μŠ€μΌ€μ΄ν”„ 처리
164
  - 각 행은 μƒˆλ‘œμš΄ μ€„λ‘œ ꡬ뢄
165
+ - λͺ¨λ“  ν•„λ“œλŠ” μ‰Όν‘œλ‘œ ꡬ뢄"""
166
+
167
+ full_prompt = f"{system_prompt}\n\n{input_text}\n\n좜λ ₯:"
168
 
169
  try:
170
+ response = ""
171
+ stream = hf_client.text_generation(
172
+ prompt=full_prompt,
173
  max_new_tokens=4000,
174
  temperature=0.3,
175
  top_p=0.9,
176
+ stream=True,
177
  )
178
 
179
+ for msg in stream:
180
+ if msg:
181
+ response += msg
182
+
183
+ # 응닡 μ •μ œ
184
+ processed_text = response.strip()
185
 
186
  # CSV ν˜•μ‹ 검증
187
  try:
 
193
  return "LLM이 μ˜¬λ°”λ₯Έ CSV ν˜•μ‹μ„ μƒμ„±ν•˜μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•΄μ£Όμ„Έμš”."
194
 
195
  except Exception as e:
196
+ error_message = f"μ „μ²˜λ¦¬ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}"
197
  print(error_message)
198
  return error_message
199