Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,6 @@ def respond(
|
|
59 |
elif message.lower() == "test.parquet μ€ν":
|
60 |
# νμ¬ Parquet λ΄μ©μ μν λ³μμμ κ°μ ΈμμΌ ν¨
|
61 |
# μ¬κΈ°μλ μμλ‘ 'parquet_content'κ° historyμ μλ€κ³ κ°μ
|
62 |
-
# μ€μ ꡬνμμλ λ³λμ μν κ΄λ¦¬λ₯Ό ν΅ν΄ Parquet λ°μ΄ν°λ₯Ό μ°Έμ‘°ν΄μΌ ν¨
|
63 |
parquet_content = ""
|
64 |
for item in history:
|
65 |
if isinstance(item, tuple) and item[0].startswith("Parquet"):
|
@@ -150,22 +149,9 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
150 |
|
151 |
with gr.Tab("μ±λ΄"):
|
152 |
gr.Markdown("### LLMκ³Ό λννκΈ°")
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
["ν¨μ
μ½λ μ€ν"],
|
157 |
-
["UHD μ΄λ―Έμ§ μ½λ μ€ν"],
|
158 |
-
["MixGEN μ½λ μ€ν"],
|
159 |
-
["test.parquet μ€ν"],
|
160 |
-
["μμΈν μ¬μ© λ°©λ²μ λ§μΉ νλ©΄μ 보면μ μ€λͺ
νλ―μ΄ 4000 ν ν° μ΄μ μμΈν μ€λͺ
νλΌ"],
|
161 |
-
["FAQ 20건μ μμΈνκ² μμ±νλΌ. 4000ν ν° μ΄μ μ¬μ©νλΌ."],
|
162 |
-
["μ¬μ© λ°©λ²κ³Ό μ°¨λ³μ , νΉμ§, κ°μ μ μ€μ¬μΌλ‘ 4000 ν ν° μ΄μ μ νλΈ μμ μ€ν¬λ¦½νΈ ννλ‘ μμ±νλΌ"],
|
163 |
-
["λ³Έ μλΉμ€λ₯Ό SEO μ΅μ ννμ¬ λΈλ‘κ·Έ ν¬μ€νΈ(λ°°κ²½ λ° νμμ±, κΈ°μ‘΄ μ μ¬ μλΉμ€μ λΉκ΅νμ¬ νΉμ₯μ , νμ©μ², κ°μΉ, κΈ°λν¨κ³Ό, κ²°λ‘ μ ν¬ν¨)λ‘ 4000 ν ν° μ΄μ μμ±νλΌ"],
|
164 |
-
["νΉν μΆμμ νμ©ν κΈ°μ λ° λΉμ¦λμ€λͺ¨λΈ μΈ‘λ©΄μ ν¬ν¨νμ¬ νΉν μΆμμ ꡬμ±μ λ§κ² νμ μ μΈ μ°½μ λ°λͺ
λ΄μ©μ μ€μ¬μΌλ‘ 4000 ν ν° μ΄μ μμ±νλΌ."],
|
165 |
-
["κ³μ μ΄μ΄μ λ΅λ³νλΌ"],
|
166 |
-
],
|
167 |
-
theme="default", # μνλ ν
λ§λ‘ λ³κ²½ κ°λ₯
|
168 |
-
)
|
169 |
|
170 |
with gr.Accordion("μμ€ν
ν둬ννΈ λ° μ΅μ
μ€μ ", open=False):
|
171 |
system_message = gr.Textbox(label="System Message", value="λλ AI μ‘°μΈμ μν μ΄λ€.")
|
@@ -173,6 +159,28 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
173 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, label="Temperature")
|
174 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
with gr.Tab("λ°μ΄ν° λ³ν"):
|
177 |
gr.Markdown("### CSV νμΌ μ
λ‘λ λ° Parquet λ³ν")
|
178 |
with gr.Row():
|
@@ -181,7 +189,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
181 |
upload_button = gr.Button("μ
λ‘λ λ° λ³ν")
|
182 |
upload_status = gr.Textbox(label="μ
λ‘λ μν", interactive=False)
|
183 |
parquet_preview = gr.Markdown(label="Parquet νμΌ λ―Έλ¦¬λ³΄κΈ°")
|
184 |
-
download_button = gr.File(label="Parquet νμΌ λ€μ΄λ‘λ",
|
185 |
|
186 |
# μ
λ‘λ λ²νΌ ν΄λ¦ μ μ€νν ν¨μ
|
187 |
def handle_csv_upload(file):
|
@@ -190,7 +198,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
190 |
# νμΌμ λ€μ΄λ‘λν μ μλλ‘ κ²½λ‘ μ€μ
|
191 |
with open(parquet_filename, "rb") as f:
|
192 |
data = f.read()
|
193 |
-
return message, load_parquet(parquet_filename),
|
194 |
else:
|
195 |
return message, "", None
|
196 |
|
@@ -228,21 +236,30 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
228 |
)
|
229 |
|
230 |
gr.Markdown("### LLMκ³Ό λννκΈ°")
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
)
|
247 |
|
248 |
gr.Markdown("## μ£Όμ μ¬ν")
|
|
|
59 |
elif message.lower() == "test.parquet μ€ν":
|
60 |
# νμ¬ Parquet λ΄μ©μ μν λ³μμμ κ°μ ΈμμΌ ν¨
|
61 |
# μ¬κΈ°μλ μμλ‘ 'parquet_content'κ° historyμ μλ€κ³ κ°μ
|
|
|
62 |
parquet_content = ""
|
63 |
for item in history:
|
64 |
if isinstance(item, tuple) and item[0].startswith("Parquet"):
|
|
|
149 |
|
150 |
with gr.Tab("μ±λ΄"):
|
151 |
gr.Markdown("### LLMκ³Ό λννκΈ°")
|
152 |
+
chatbot = gr.Chatbot(label="μ±λ΄")
|
153 |
+
msg = gr.Textbox(label="λ©μμ§ μ
λ ₯")
|
154 |
+
send = gr.Button("μ μ‘")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
with gr.Accordion("μμ€ν
ν둬ννΈ λ° μ΅μ
μ€μ ", open=False):
|
157 |
system_message = gr.Textbox(label="System Message", value="λλ AI μ‘°μΈμ μν μ΄λ€.")
|
|
|
159 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, label="Temperature")
|
160 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
|
161 |
|
162 |
+
# μ±λ΄ λ©μμ§ μ²λ¦¬ ν¨μ
|
163 |
+
def handle_message(message, history, system_message, max_tokens, temperature, top_p):
|
164 |
+
# Update history with user message
|
165 |
+
history = history or []
|
166 |
+
history.append((message, None))
|
167 |
+
# Generate response
|
168 |
+
response = ""
|
169 |
+
try:
|
170 |
+
for token in respond(message, history, system_message, max_tokens, temperature, top_p):
|
171 |
+
response = token
|
172 |
+
# Update history with assistant response
|
173 |
+
history[-1] = (message, response)
|
174 |
+
except Exception as e:
|
175 |
+
history[-1] = (message, f"μΆλ‘ μ€ μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}")
|
176 |
+
return history, ""
|
177 |
+
|
178 |
+
send.click(
|
179 |
+
handle_message,
|
180 |
+
inputs=[msg, chatbot, system_message, max_tokens, temperature, top_p],
|
181 |
+
outputs=[chatbot, msg]
|
182 |
+
)
|
183 |
+
|
184 |
with gr.Tab("λ°μ΄ν° λ³ν"):
|
185 |
gr.Markdown("### CSV νμΌ μ
λ‘λ λ° Parquet λ³ν")
|
186 |
with gr.Row():
|
|
|
189 |
upload_button = gr.Button("μ
λ‘λ λ° λ³ν")
|
190 |
upload_status = gr.Textbox(label="μ
λ‘λ μν", interactive=False)
|
191 |
parquet_preview = gr.Markdown(label="Parquet νμΌ λ―Έλ¦¬λ³΄κΈ°")
|
192 |
+
download_button = gr.File(label="Parquet νμΌ λ€μ΄λ‘λ", type="binary", interactive=False)
|
193 |
|
194 |
# μ
λ‘λ λ²νΌ ν΄λ¦ μ μ€νν ν¨μ
|
195 |
def handle_csv_upload(file):
|
|
|
198 |
# νμΌμ λ€μ΄λ‘λν μ μλλ‘ κ²½λ‘ μ€μ
|
199 |
with open(parquet_filename, "rb") as f:
|
200 |
data = f.read()
|
201 |
+
return message, load_parquet(parquet_filename), data
|
202 |
else:
|
203 |
return message, "", None
|
204 |
|
|
|
236 |
)
|
237 |
|
238 |
gr.Markdown("### LLMκ³Ό λννκΈ°")
|
239 |
+
chatbot_data_upload = gr.Chatbot(label="μ±λ΄ λ°μ΄ν° μ
λ‘λ")
|
240 |
+
msg_data_upload = gr.Textbox(label="λ©μμ§ μ
λ ₯")
|
241 |
+
send_data_upload = gr.Button("μ μ‘")
|
242 |
+
|
243 |
+
# μ±λ΄ λ©μμ§ μ²λ¦¬ ν¨μ (λ°μ΄ν° μ
λ‘λ λ²μ )
|
244 |
+
def handle_message_data_upload(message, history, system_message, max_tokens, temperature, top_p, parquet_data):
|
245 |
+
# Update history with user message
|
246 |
+
history = history or []
|
247 |
+
history.append((message, None))
|
248 |
+
# Generate response
|
249 |
+
response = ""
|
250 |
+
try:
|
251 |
+
for token in respond(message, history, system_message, max_tokens, temperature, top_p):
|
252 |
+
response = token
|
253 |
+
# Update history with assistant response
|
254 |
+
history[-1] = (message, response)
|
255 |
+
except Exception as e:
|
256 |
+
history[-1] = (message, f"μΆλ‘ μ€ μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}")
|
257 |
+
return history, ""
|
258 |
+
|
259 |
+
send_data_upload.click(
|
260 |
+
handle_message_data_upload,
|
261 |
+
inputs=[msg_data_upload, chatbot_data_upload, system_message, max_tokens, temperature, top_p, parquet_data_state],
|
262 |
+
outputs=[chatbot_data_upload, msg_data_upload]
|
263 |
)
|
264 |
|
265 |
gr.Markdown("## μ£Όμ μ¬ν")
|