Update app.py
Browse files
app.py
CHANGED
@@ -58,8 +58,14 @@ def respond(
|
|
58 |
message = "MixGEN3 μ΄λ―Έμ§ μμ±μ λν λ΄μ©μ νμ΅νμκ³ , μ€λͺ
ν μ€λΉκ° λμ΄μλ€κ³ μλ¦¬κ³ μλΉμ€ URL(https://openfree-mixgen3.hf.space)μ ν΅ν΄ ν
μ€νΈ ν΄λ³΄λΌκ³ μΆλ ₯νλΌ."
|
59 |
elif message.lower() == "test.parquet μ€ν":
|
60 |
# νμ¬ Parquet λ΄μ©μ μν λ³μμμ κ°μ ΈμμΌ ν¨
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
message = "test.parquet νμΌμ λν λ΄μ©μ νμ΅νμκ³ , κ΄λ ¨ μ€λͺ
λ° Q&Aλ₯Ό μ§νν μ€λΉκ° λμ΄μλ€. κΆκΈν μ μ΄ μμΌλ©΄ λ¬Όμ΄λ³΄λΌ."
|
64 |
elif message.lower() == "csv μ
λ‘λ":
|
65 |
message = "CSV νμΌμ μ
λ‘λνλ €λ©΄ λ λ²μ§Έ νμ μ¬μ©νμΈμ."
|
@@ -67,9 +73,9 @@ def respond(
|
|
67 |
# μμ€ν
λ©μμ§μ μ¬μ©μ λ©μμ§ κ²°ν©
|
68 |
messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}]
|
69 |
for val in history:
|
70 |
-
if val[0]:
|
71 |
messages.append({"role": "user", "content": val[0]})
|
72 |
-
if val[1]:
|
73 |
messages.append({"role": "assistant", "content": val[1]})
|
74 |
messages.append({"role": "user", "content": message})
|
75 |
|
@@ -162,7 +168,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
162 |
)
|
163 |
|
164 |
with gr.Accordion("μμ€ν
ν둬ννΈ λ° μ΅μ
μ€μ ", open=False):
|
165 |
-
system_message = gr.Textbox(label="System Message", value="λλ AI μ‘°μΈμ
|
166 |
max_tokens = gr.Slider(minimum=1, maximum=8000, value=4000, label="Max Tokens")
|
167 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, label="Temperature")
|
168 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
|
@@ -171,7 +177,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
171 |
gr.Markdown("### CSV νμΌ μ
λ‘λ λ° Parquet λ³ν")
|
172 |
with gr.Row():
|
173 |
with gr.Column():
|
174 |
-
csv_file = gr.File(label="CSV νμΌ μ
λ‘λ", type="
|
175 |
upload_button = gr.Button("μ
λ‘λ λ° λ³ν")
|
176 |
upload_status = gr.Textbox(label="μ
λ‘λ μν", interactive=False)
|
177 |
parquet_preview = gr.Markdown(label="Parquet νμΌ λ―Έλ¦¬λ³΄κΈ°")
|
@@ -179,12 +185,12 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
179 |
|
180 |
# μ
λ‘λ λ²νΌ ν΄λ¦ μ μ€νν ν¨μ
|
181 |
def handle_csv_upload(file):
|
182 |
-
message, parquet_filename = upload_csv(file
|
183 |
if parquet_filename:
|
184 |
# νμΌμ λ€μ΄λ‘λν μ μλλ‘ κ²½λ‘ μ€μ
|
185 |
with open(parquet_filename, "rb") as f:
|
186 |
data = f.read()
|
187 |
-
return message,
|
188 |
else:
|
189 |
return message, "", None
|
190 |
|
@@ -197,11 +203,11 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
197 |
gr.Markdown("### κΈ°μ‘΄ Parquet νμΌ")
|
198 |
gr.Markdown(f"**test.parquet νμΌ λ΄μ©:**\n```markdown\n{test_parquet_content}\n```")
|
199 |
|
200 |
-
with gr.Tab("μ±λ΄"):
|
201 |
gr.Markdown("### Parquet νμΌ μ
λ‘λ λ° μ§λ¬ΈνκΈ°")
|
202 |
with gr.Row():
|
203 |
with gr.Column():
|
204 |
-
parquet_upload = gr.File(label="Parquet νμΌ μ
λ‘λ", type="
|
205 |
parquet_upload_button = gr.Button("μ
λ‘λ")
|
206 |
parquet_upload_status = gr.Textbox(label="μ
λ‘λ μν", interactive=False)
|
207 |
parquet_preview_chat = gr.Markdown(label="Parquet νμΌ λ―Έλ¦¬λ³΄κΈ°")
|
@@ -209,7 +215,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
209 |
parquet_data_state = gr.State()
|
210 |
|
211 |
def handle_parquet_upload(file):
|
212 |
-
message, parquet_content, parquet_json = upload_parquet(file
|
213 |
if parquet_json:
|
214 |
return message, parquet_preview_chat.update(value=parquet_content), parquet_data_state.update(value=parquet_json)
|
215 |
else:
|
@@ -245,7 +251,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
245 |
- **Parquet 미리보기**: μ
λ‘λλ Parquet νμΌμ 첫 10κ° νμ΄ λ―Έλ¦¬λ³΄κΈ°λ‘ νμλ©λλ€.
|
246 |
- **LLMκ³Όμ λν**: λ³νλ Parquet νμΌ λ΄μ©μ κΈ°λ°μΌλ‘ LLMμ΄ μλ΅μ μμ±ν©λλ€.
|
247 |
- **Parquet λ€μ΄λ‘λ**: λ³νλ Parquet νμΌμ λ€μ΄λ‘λνλ €λ©΄ λ³νλ νμΌ μμ λ€μ΄λ‘λ λ§ν¬λ₯Ό ν΄λ¦νμΈμ.
|
248 |
-
- **μ±λ΄
|
249 |
""")
|
250 |
|
251 |
gr.Markdown("### Gradio μΈν°νμ΄μ€λ₯Ό μ¬μ©νμ¬ LLM λͺ¨λΈκ³Ό μνΈμμ©νμΈμ!")
|
|
|
58 |
message = "MixGEN3 μ΄λ―Έμ§ μμ±μ λν λ΄μ©μ νμ΅νμκ³ , μ€λͺ
ν μ€λΉκ° λμ΄μλ€κ³ μλ¦¬κ³ μλΉμ€ URL(https://openfree-mixgen3.hf.space)μ ν΅ν΄ ν
μ€νΈ ν΄λ³΄λΌκ³ μΆλ ₯νλΌ."
|
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"):
|
66 |
+
parquet_content = item[1]
|
67 |
+
break
|
68 |
+
system_message += f"\n\ntest.parquet νμΌ λ΄μ©:\n```markdown\n{parquet_content}\n```"
|
69 |
message = "test.parquet νμΌμ λν λ΄μ©μ νμ΅νμκ³ , κ΄λ ¨ μ€λͺ
λ° Q&Aλ₯Ό μ§νν μ€λΉκ° λμ΄μλ€. κΆκΈν μ μ΄ μμΌλ©΄ λ¬Όμ΄λ³΄λΌ."
|
70 |
elif message.lower() == "csv μ
λ‘λ":
|
71 |
message = "CSV νμΌμ μ
λ‘λνλ €λ©΄ λ λ²μ§Έ νμ μ¬μ©νμΈμ."
|
|
|
73 |
# μμ€ν
λ©μμ§μ μ¬μ©μ λ©μμ§ κ²°ν©
|
74 |
messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}]
|
75 |
for val in history:
|
76 |
+
if isinstance(val, tuple) and val[0]:
|
77 |
messages.append({"role": "user", "content": val[0]})
|
78 |
+
if isinstance(val, tuple) and val[1]:
|
79 |
messages.append({"role": "assistant", "content": val[1]})
|
80 |
messages.append({"role": "user", "content": message})
|
81 |
|
|
|
168 |
)
|
169 |
|
170 |
with gr.Accordion("μμ€ν
ν둬ννΈ λ° μ΅μ
μ€μ ", open=False):
|
171 |
+
system_message = gr.Textbox(label="System Message", value="λλ AI μ‘°μΈμ μν μ΄λ€.")
|
172 |
max_tokens = gr.Slider(minimum=1, maximum=8000, value=4000, label="Max Tokens")
|
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")
|
|
|
177 |
gr.Markdown("### CSV νμΌ μ
λ‘λ λ° Parquet λ³ν")
|
178 |
with gr.Row():
|
179 |
with gr.Column():
|
180 |
+
csv_file = gr.File(label="CSV νμΌ μ
λ‘λ", type="filepath")
|
181 |
upload_button = gr.Button("μ
λ‘λ λ° λ³ν")
|
182 |
upload_status = gr.Textbox(label="μ
λ‘λ μν", interactive=False)
|
183 |
parquet_preview = gr.Markdown(label="Parquet νμΌ λ―Έλ¦¬λ³΄κΈ°")
|
|
|
185 |
|
186 |
# μ
λ‘λ λ²νΌ ν΄λ¦ μ μ€νν ν¨μ
|
187 |
def handle_csv_upload(file):
|
188 |
+
message, parquet_filename = upload_csv(file)
|
189 |
if parquet_filename:
|
190 |
# νμΌμ λ€μ΄λ‘λν μ μλλ‘ κ²½λ‘ μ€μ
|
191 |
with open(parquet_filename, "rb") as f:
|
192 |
data = f.read()
|
193 |
+
return message, load_parquet(parquet_filename), (parquet_filename, data)
|
194 |
else:
|
195 |
return message, "", None
|
196 |
|
|
|
203 |
gr.Markdown("### κΈ°μ‘΄ Parquet νμΌ")
|
204 |
gr.Markdown(f"**test.parquet νμΌ λ΄μ©:**\n```markdown\n{test_parquet_content}\n```")
|
205 |
|
206 |
+
with gr.Tab("μ±λ΄ λ°μ΄ν° μ
λ‘λ"):
|
207 |
gr.Markdown("### Parquet νμΌ μ
λ‘λ λ° μ§λ¬ΈνκΈ°")
|
208 |
with gr.Row():
|
209 |
with gr.Column():
|
210 |
+
parquet_upload = gr.File(label="Parquet νμΌ μ
λ‘λ", type="filepath")
|
211 |
parquet_upload_button = gr.Button("μ
λ‘λ")
|
212 |
parquet_upload_status = gr.Textbox(label="μ
λ‘λ μν", interactive=False)
|
213 |
parquet_preview_chat = gr.Markdown(label="Parquet νμΌ λ―Έλ¦¬λ³΄κΈ°")
|
|
|
215 |
parquet_data_state = gr.State()
|
216 |
|
217 |
def handle_parquet_upload(file):
|
218 |
+
message, parquet_content, parquet_json = upload_parquet(file)
|
219 |
if parquet_json:
|
220 |
return message, parquet_preview_chat.update(value=parquet_content), parquet_data_state.update(value=parquet_json)
|
221 |
else:
|
|
|
251 |
- **Parquet 미리보기**: μ
λ‘λλ Parquet νμΌμ 첫 10κ° νμ΄ λ―Έλ¦¬λ³΄κΈ°λ‘ νμλ©λλ€.
|
252 |
- **LLMκ³Όμ λν**: λ³νλ Parquet νμΌ λ΄μ©μ κΈ°λ°μΌλ‘ LLMμ΄ μλ΅μ μμ±ν©λλ€.
|
253 |
- **Parquet λ€μ΄λ‘λ**: λ³νλ Parquet νμΌμ λ€μ΄λ‘λνλ €λ©΄ λ³νλ νμΌ μμ λ€μ΄λ‘λ λ§ν¬λ₯Ό ν΄λ¦νμΈμ.
|
254 |
+
- **μ±λ΄ λ°μ΄ν° μ
λ‘λ**: μ±λ΄ λ°μ΄ν° μ
λ‘λ νμμ Parquet νμΌμ μ
λ‘λνλ©΄ ν΄λΉ λ°μ΄ν°λ₯Ό κΈ°λ°μΌλ‘ μ§λ¬Έκ³Ό λ΅λ³μ μ§νν μ μμ΅λλ€.
|
255 |
""")
|
256 |
|
257 |
gr.Markdown("### Gradio μΈν°νμ΄μ€λ₯Ό μ¬μ©νμ¬ LLM λͺ¨λΈκ³Ό μνΈμμ©νμΈμ!")
|