Update app.py
Browse files
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)
|