ginipick commited on
Commit
d85f577
โ€ข
1 Parent(s): b25fdc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -144,7 +144,6 @@ def text_to_parquet(text: str) -> Tuple[str, str, str]:
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 "์ž…๋ ฅ ํ…์ŠคํŠธ๊ฐ€ ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค."
@@ -162,7 +161,10 @@ def preprocess_text_with_llm(input_text: str) -> str:
162
  - ํ…์ŠคํŠธ์— ์‰ผํ‘œ๊ฐ€ ์žˆ์œผ๋ฉด ํฐ๋”ฐ์˜ดํ‘œ๋กœ ๊ฐ์‹ธ๊ธฐ
163
  - ํฐ๋”ฐ์˜ดํ‘œ๋Š” ๋ฐฑ์Šฌ๋ž˜์‹œ๋กœ ์ด์Šค์ผ€์ดํ”„ ์ฒ˜๋ฆฌ
164
  - ๊ฐ ํ–‰์€ ์ƒˆ๋กœ์šด ์ค„๋กœ ๊ตฌ๋ถ„
165
- - ๋ชจ๋“  ํ•„๋“œ๋Š” ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„"""
 
 
 
166
 
167
  full_prompt = f"{system_prompt}\n\n{input_text}\n\n์ถœ๋ ฅ:"
168
 
@@ -170,8 +172,8 @@ def preprocess_text_with_llm(input_text: str) -> str:
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
  )
@@ -185,6 +187,7 @@ def preprocess_text_with_llm(input_text: str) -> str:
185
 
186
  # CSV ํ˜•์‹ ๊ฒ€์ฆ
187
  try:
 
188
  from io import StringIO
189
  import csv
190
  csv.reader(StringIO(processed_text))
@@ -193,11 +196,10 @@ def preprocess_text_with_llm(input_text: str) -> str:
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
 
200
-
201
  # CSS ์„ค์ •
202
  css = """
203
  footer {
@@ -495,4 +497,4 @@ with gr.Blocks(css=css) as demo:
495
  gr.Markdown("### [email protected]", elem_id="initial-description")
496
 
497
  if __name__ == "__main__":
498
- demo.launch(share=True)
 
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 "์ž…๋ ฅ ํ…์ŠคํŠธ๊ฐ€ ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค."
 
161
  - ํ…์ŠคํŠธ์— ์‰ผํ‘œ๊ฐ€ ์žˆ์œผ๋ฉด ํฐ๋”ฐ์˜ดํ‘œ๋กœ ๊ฐ์‹ธ๊ธฐ
162
  - ํฐ๋”ฐ์˜ดํ‘œ๋Š” ๋ฐฑ์Šฌ๋ž˜์‹œ๋กœ ์ด์Šค์ผ€์ดํ”„ ์ฒ˜๋ฆฌ
163
  - ๊ฐ ํ–‰์€ ์ƒˆ๋กœ์šด ์ค„๋กœ ๊ตฌ๋ถ„
164
+ - ๋ชจ๋“  ํ•„๋“œ๋Š” ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„
165
+
166
+ ์ž…๋ ฅ ํ…์ŠคํŠธ:
167
+ """
168
 
169
  full_prompt = f"{system_prompt}\n\n{input_text}\n\n์ถœ๋ ฅ:"
170
 
 
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
  )
 
187
 
188
  # CSV ํ˜•์‹ ๊ฒ€์ฆ
189
  try:
190
+ # StringIO๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ CSV ํ˜•์‹ ๊ฒ€์ฆ
191
  from io import StringIO
192
  import csv
193
  csv.reader(StringIO(processed_text))
 
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
 
 
203
  # CSS ์„ค์ •
204
  css = """
205
  footer {
 
497
  gr.Markdown("### [email protected]", elem_id="initial-description")
498
 
499
  if __name__ == "__main__":
500
+ demo.launch(share=True)